Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

Commit

Permalink
Add a backgroundColor option to the webview plateform interface
Browse files Browse the repository at this point in the history
  • Loading branch information
e-adrien committed Dec 2, 2021
1 parent 702fada commit b8d71c9
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
@@ -1,3 +1,7 @@
## 1.7.0

* Add an option to set the background color of the webview.

## 1.6.0

* Adds platform interface for cookie manager.
Expand Down
Expand Up @@ -266,6 +266,7 @@ class MethodChannelWebViewPlatform implements WebViewPlatformController {
'userAgent': creationParams.userAgent,
'autoMediaPlaybackPolicy': creationParams.autoMediaPlaybackPolicy.index,
'usesHybridComposition': usesHybridComposition,
'backgroundColor': creationParams.backgroundColor?.value,
'cookies': creationParams.cookies
.map((WebViewCookie cookie) => cookie.toJson())
.toList()
Expand Down
Expand Up @@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'package:flutter/widgets.dart';
import 'package:webview_flutter_platform_interface/src/types/types.dart';

import 'auto_media_playback_policy.dart';
Expand All @@ -22,6 +23,7 @@ class CreationParams {
this.userAgent,
this.autoMediaPlaybackPolicy =
AutoMediaPlaybackPolicy.require_user_action_for_all_media_types,
this.backgroundColor,
this.cookies = const <WebViewCookie>[],
}) : assert(autoMediaPlaybackPolicy != null);

Expand Down Expand Up @@ -56,11 +58,16 @@ class CreationParams {
/// Which restrictions apply on automatic media playback.
final AutoMediaPlaybackPolicy autoMediaPlaybackPolicy;

/// The background color of the webview.
///
/// When null the platform's webview default background color is used.
final Color? backgroundColor;

/// The initial set of cookies to set before the webview does its first load.
final List<WebViewCookie> cookies;

@override
String toString() {
return 'CreationParams(initialUrl: $initialUrl, settings: $webSettings, javascriptChannelNames: $javascriptChannelNames, UserAgent: $userAgent, cookies: $cookies)';
return 'CreationParams(initialUrl: $initialUrl, settings: $webSettings, javascriptChannelNames: $javascriptChannelNames, UserAgent: $userAgent, backgroundColor: $backgroundColor, cookies: $cookies)';
}
}
Expand Up @@ -4,7 +4,7 @@ repository: https://github.com/flutter/plugins/tree/master/packages/webview_flut
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+webview_flutter%22
# NOTE: We strongly prefer non-breaking changes, even at the expense of a
# less-clean API. See https://flutter.dev/go/platform-interface-breaking-changes
version: 1.6.0
version: 1.7.0

environment:
sdk: ">=2.12.0 <3.0.0"
Expand Down

0 comments on commit b8d71c9

Please sign in to comment.