Skip to content

Commit

Permalink
Updated readme
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewtsmith committed Sep 26, 2017
1 parent 6cee555 commit c34d9be
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 5 deletions.
40 changes: 40 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Features
- [x] Listen for Redirects
- [x] Add buttons to a navigation bar
- [x] Receive call backs for nav buttons pressed
- [x] WebView loading callbacks
- [x] Supports custom nav bar & button colors ( ios only for now )
- [ ] Advanced nav bar support ( position , enable, disable buttons )
- [ ] Support for nav bar icon buttons
Expand All @@ -26,3 +27,42 @@ To use on Android, make sure to add the the following in your AndroidManifest.xm
<activity android:name="com.apptreesoftware.flutterwebview.WebViewActivity">
</activity>
```

### Example Usage

```
flutterWebView.launch(
"https://apptreesoftware.com",
headers: {
"X-SOME-HEADER": "MyCustomHeader",
},
javaScriptEnabled: false,
toolbarActions: [
new ToolbarAction("Dismiss", 1),
new ToolbarAction("Reload", 2)
],
barColor: Colors.green,
tintColor: Colors.white);
flutterWebView.onToolbarAction.listen((identifier) {
switch (identifier) {
case 1:
flutterWebView.dismiss();
break;
case 2:
reload();
break;
}
});
flutterWebView.listenForRedirect("mobile://test.com", true);
flutterWebView.onWebViewDidStartLoading.listen((url) {
setState(() => _isLoading = true);
});
flutterWebView.onWebViewDidLoad.listen((url) {
setState(() => _isLoading = false);
});
flutterWebView.onRedirect.listen((url) {
flutterWebView.dismiss();
setState(() => _redirectedToUrl = url);
});
```
10 changes: 5 additions & 5 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ class _MyAppState extends State<MyApp> {
return;
}

flutterWebView.launch(
"https://apptreesoftware.com",
flutterWebView.launch("https://apptreesoftware.com",
headers: {
"X-SOME-HEADER": "MyCustomHeader",
},
Expand All @@ -74,6 +73,7 @@ class _MyAppState extends State<MyApp> {
}
});
flutterWebView.listenForRedirect("mobile://test.com", true);

flutterWebView.onWebViewDidStartLoading.listen((url) {
setState(() => _isLoading = true);
});
Expand All @@ -88,10 +88,10 @@ class _MyAppState extends State<MyApp> {

void reload() {
flutterWebView.load(
"https://google.com",
headers: {
"https://google.com",
headers: {
"X-SOME-HEADER": "MyCustomHeader",
},
},
);
}
}

0 comments on commit c34d9be

Please sign in to comment.