Skip to content
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
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ Future<Null> launch(String url,
Rect rect: null,
String userAgent: null,
bool withZoom: false,
bool withLocalStorage: true});
bool withLocalStorage: true,
bool scrollBar: true});
```
```dart
Future<String> evalJavascript(String code);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ private void openUrl(MethodCall call, MethodChannel.Result result) {
boolean clearCookies = call.argument("clearCookies");
boolean withZoom = call.argument("withZoom");
boolean withLocalStorage = call.argument("withLocalStorage");
boolean scrollBar = call.argument("scrollBar");

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

void openUrl(boolean withJavascript, boolean clearCache, boolean hidden, boolean clearCookies, String userAgent, String url, boolean withZoom, boolean withLocalStorage) {
void openUrl(boolean withJavascript, boolean clearCache, boolean hidden, boolean clearCookies, String userAgent, String url, boolean withZoom, boolean withLocalStorage, boolean scrollBar) {
webView.getSettings().setJavaScriptEnabled(withJavascript);
webView.getSettings().setBuiltInZoomControls(withZoom);
webView.getSettings().setSupportZoom(withZoom);
Expand All @@ -90,6 +90,10 @@ void openUrl(boolean withJavascript, boolean clearCache, boolean hidden, boolean
webView.getSettings().setUserAgentString(userAgent);
}

if(!scrollBar){
webView.setVerticalScrollBarEnabled(false);
}

webView.loadUrl(url);
}

Expand Down
3 changes: 3 additions & 0 deletions ios/Classes/FlutterWebviewPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ - (void)initWebview:(FlutterMethodCall*)call {
_enableAppScheme = call.arguments[@"enableAppScheme"];
NSString *userAgent = call.arguments[@"userAgent"];
NSNumber *withZoom = call.arguments[@"withZoom"];
NSNumber *scrollBar = call.arguments[@"scrollBar"];

if (clearCache != (id)[NSNull null] && [clearCache boolValue]) {
[[NSURLCache sharedURLCache] removeAllCachedResponses];
Expand All @@ -84,6 +85,8 @@ - (void)initWebview:(FlutterMethodCall*)call {
self.webview.navigationDelegate = self;
self.webview.scrollView.delegate = self;
self.webview.hidden = [hidden boolValue];
self.webview.showsHorizontalScrollIndicator = [scrollBar boolValue];
self.webView.showsVerticalScrollIndicator = [scrollBar boolValue];

_enableZoom = [withZoom boolValue];

Expand Down
7 changes: 5 additions & 2 deletions lib/src/base.dart
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ class FlutterWebviewPlugin {
/// It is always enabled in UIWebView of iOS and can not be disabled.
/// - [withLocalUrl]: allow url as a local path
/// Allow local files on iOs > 9.0
/// - [scrollBar]: enable or disable scrollbar
Future<Null> launch(String url,
{bool withJavascript,
bool clearCache,
Expand All @@ -86,7 +87,8 @@ class FlutterWebviewPlugin {
String userAgent,
bool withZoom,
bool withLocalStorage,
bool withLocalUrl}) async {
bool withLocalUrl,
bool scrollBar}) async {
Map<String, dynamic> args = {
"url": url,
"withJavascript": withJavascript ?? true,
Expand All @@ -97,7 +99,8 @@ class FlutterWebviewPlugin {
"userAgent": userAgent,
"withZoom": withZoom ?? false,
"withLocalStorage": withLocalStorage ?? true,
"withLocalUrl": withLocalUrl ?? false
"withLocalUrl": withLocalUrl ?? false,
"scrollBar": scrollBar ?? 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 @@ -19,6 +19,7 @@ class WebviewScaffold extends StatefulWidget {
final bool withZoom;
final bool withLocalStorage;
final bool withLocalUrl;
final bool scrollBar;

WebviewScaffold(
{Key key,
Expand All @@ -34,7 +35,8 @@ class WebviewScaffold extends StatefulWidget {
this.bottomNavigationBar,
this.withZoom,
this.withLocalStorage,
this.withLocalUrl})
this.withLocalUrl,
this.scrollBar})
: super(key: key);

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