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

Commit

Permalink
put webview with transparent background
Browse files Browse the repository at this point in the history
  • Loading branch information
jaumard committed Mar 13, 2019
1 parent 432f775 commit e36da33
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public class FlutterWebView implements PlatformView, MethodCallHandler {
@SuppressWarnings("unchecked")
FlutterWebView(Context context, BinaryMessenger messenger, int id, Map<String, Object> params) {
webView = new WebView(context);
webView.setBackgroundColor(Color.TRANSPARENT);
// Allow local storage.
webView.getSettings().setDomStorageEnabled(true);

Expand Down Expand Up @@ -101,6 +102,7 @@ public void onMethodCall(MethodCall methodCall, Result result) {
private void loadUrl(MethodCall methodCall, Result result) {
String url = (String) methodCall.arguments;
webView.loadUrl(url);
webView.setBackgroundColor(Color.TRANSPARENT);
result.success(null);
}

Expand Down
7 changes: 7 additions & 0 deletions packages/webview_flutter/ios/Classes/FlutterWebView.m
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ - (instancetype)initWithFrame:(CGRect)frame
configuration.userContentController = userContentController;

_webView = [[WKWebView alloc] initWithFrame:frame configuration:configuration];
_webView.opaque = NO;
_webView.backgroundColor = UIColor.clearColor;
_webView.scrollView.backgroundColor = UIColor.clearColor;

_navigationDelegate = [[FLTWKNavigationDelegate alloc] initWithChannel:_channel];
_webView.navigationDelegate = _navigationDelegate;
__weak __typeof__(self) weakSelf = self;
Expand Down Expand Up @@ -263,6 +267,9 @@ - (bool)loadUrl:(NSString*)url {
}
NSURLRequest* req = [NSURLRequest requestWithURL:nsUrl];
[_webView loadRequest:req];
_webView.opaque = NO;
_webView.backgroundColor = UIColor.clearColor;
_webView.scrollView.backgroundColor = UIColor.clearColor;
return true;
}

Expand Down

0 comments on commit e36da33

Please sign in to comment.