Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a flag for forcing software rendering on Android #908

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ Future<Null> launch(String url, {
bool geolocationEnabled: false,
bool debuggingEnabled: false,
bool ignoreSSLErrors: false,
bool softwareRender: false,
});
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ void openUrl(MethodCall call, MethodChannel.Result result) {
boolean geolocationEnabled = call.argument("geolocationEnabled");
boolean debuggingEnabled = call.argument("debuggingEnabled");
boolean ignoreSSLErrors = call.argument("ignoreSSLErrors");
boolean softwareRender = call.argument("softwareRender");

if (webViewManager == null || webViewManager.closed == true) {
Map<String, Object> arguments = (Map<String, Object>) call.arguments;
Expand Down Expand Up @@ -162,7 +163,8 @@ void openUrl(MethodCall call, MethodChannel.Result result) {
invalidUrlRegex,
geolocationEnabled,
debuggingEnabled,
ignoreSSLErrors
ignoreSSLErrors,
softwareRender
);
result.success(null);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,8 @@ void openUrl(
String invalidUrlRegex,
boolean geolocationEnabled,
boolean debuggingEnabled,
boolean ignoreSSLErrors
boolean ignoreSSLErrors,
boolean softwareRender
) {
webView.getSettings().setJavaScriptEnabled(withJavascript);
webView.getSettings().setBuiltInZoomControls(withZoom);
Expand Down Expand Up @@ -440,6 +441,10 @@ void openUrl(
webView.setVerticalScrollBarEnabled(false);
}

if (softwareRender) {
webView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
}

if (headers != null) {
webView.loadUrl(url, headers);
} else {
Expand Down
3 changes: 3 additions & 0 deletions lib/src/base.dart
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ class FlutterWebviewPlugin {
/// - [withOverviewMode]: enable overview mode for Android webview ( setLoadWithOverviewMode )
/// - [useWideViewPort]: use wide viewport for Android webview ( setUseWideViewPort )
/// - [ignoreSSLErrors]: use to bypass Android/iOS SSL checks e.g. for self-signed certificates
/// - [softwareRender]: use to force software rendering on Android
Future<void> launch(
String url, {
Map<String, String>? headers,
Expand Down Expand Up @@ -166,6 +167,7 @@ class FlutterWebviewPlugin {
bool geolocationEnabled = false,
bool debuggingEnabled = false,
bool ignoreSSLErrors = false,
bool softwareRender = false,
}) async {
final args = <String, dynamic>{
'url': url,
Expand All @@ -191,6 +193,7 @@ class FlutterWebviewPlugin {
'withOverviewMode': withOverviewMode,
'debuggingEnabled': debuggingEnabled,
'ignoreSSLErrors': ignoreSSLErrors,
'softwareRender' : softwareRender,
};

if (headers != null) {
Expand Down