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

support LocalStorage #51

Merged
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ private void openUrl(MethodCall call, MethodChannel.Result result) {
boolean clearCache = call.argument("clearCache");
boolean clearCookies = call.argument("clearCookies");
boolean withZoom = call.argument("withZoom");
boolean withLocalStorage = call.argument("withLocalStorage");

if (webViewManager == null || webViewManager.closed == true) {
webViewManager = new WebviewManager(activity);
Expand All @@ -77,7 +78,8 @@ private void openUrl(MethodCall call, MethodChannel.Result result) {
clearCookies,
userAgent,
url,
withZoom
withZoom,
withLocalStorage
);
result.success(null);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,11 @@ private void clearCache() {
webView.clearFormData();
}

void openUrl(boolean withJavascript, boolean clearCache, boolean hidden, boolean clearCookies, String userAgent, String url, boolean withZoom) {
void openUrl(boolean withJavascript, boolean clearCache, boolean hidden, boolean clearCookies, String userAgent, String url, boolean withZoom, boolean withLocalStorage) {
webView.getSettings().setJavaScriptEnabled(withJavascript);
webView.getSettings().setBuiltInZoomControls(withZoom);
webView.getSettings().setSupportZoom(withZoom);
webView.getSettings().setDomStorageEnabled(withLocalStorage);

if (clearCache) {
clearCache();
Expand Down
1 change: 1 addition & 0 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class MyApp extends StatelessWidget {
title: new Text("Widget webview"),
),
withZoom: true,
withLocalStorage: true,
)
},
);
Expand Down
9 changes: 7 additions & 2 deletions lib/src/base.dart
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ class FlutterWebviewPlugin {
/// android: Not implemented yet
/// - [userAgent]: set the User-Agent of WebView
/// - [withZoom]: enable zoom on webview
/// - [withLocalStorage] enable localStorage API on Webview
/// Currently Android only.
/// It is always enabled in UIWebView of iOS and can not be disabled.
Future<Null> launch(String url,
{bool withJavascript,
bool clearCache,
Expand All @@ -76,7 +79,8 @@ class FlutterWebviewPlugin {
bool enableAppScheme,
Rect rect,
String userAgent,
bool withZoom}) async {
bool withZoom,
bool withLocalStorage}) async {
Map<String, dynamic> args = {
"url": url,
"withJavascript": withJavascript ?? true,
Expand All @@ -85,7 +89,8 @@ class FlutterWebviewPlugin {
"clearCookies": clearCookies ?? false,
"enableAppScheme": enableAppScheme ?? true,
"userAgent": userAgent,
"withZoom": withZoom ?? false
"withZoom": withZoom ?? false,
"withLocalStorage": withLocalStorage ?? true
};
if (rect != null) {
args["rect"] = {
Expand Down
7 changes: 5 additions & 2 deletions lib/src/webview_scaffold.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class WebviewScaffold extends StatefulWidget {
final List<Widget> persistentFooterButtons;
final Widget bottomNavigationBar;
final bool withZoom;
final bool withLocalStorage;

WebviewScaffold(
{Key key,
Expand All @@ -30,7 +31,8 @@ class WebviewScaffold extends StatefulWidget {
this.primary: true,
this.persistentFooterButtons,
this.bottomNavigationBar,
this.withZoom})
this.withZoom,
this.withLocalStorage})
: super(key: key);

@override
Expand Down Expand Up @@ -64,7 +66,8 @@ class _WebviewScaffoldState extends State<WebviewScaffold> {
enableAppScheme: widget.enableAppScheme,
userAgent: widget.userAgent,
rect: _rect,
withZoom: widget.withZoom);
withZoom: widget.withZoom,
withLocalStorage: widget.withLocalStorage);
} else {
Rect rect = _buildRect(context);
if (_rect != rect) {
Expand Down