Skip to content

Commit c34d9be

Browse files
committed
Updated readme
1 parent 6cee555 commit c34d9be

2 files changed

Lines changed: 45 additions & 5 deletions

File tree

README.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Features
99
- [x] Listen for Redirects
1010
- [x] Add buttons to a navigation bar
1111
- [x] Receive call backs for nav buttons pressed
12+
- [x] WebView loading callbacks
1213
- [x] Supports custom nav bar & button colors ( ios only for now )
1314
- [ ] Advanced nav bar support ( position , enable, disable buttons )
1415
- [ ] Support for nav bar icon buttons
@@ -26,3 +27,42 @@ To use on Android, make sure to add the the following in your AndroidManifest.xm
2627
<activity android:name="com.apptreesoftware.flutterwebview.WebViewActivity">
2728
</activity>
2829
```
30+
31+
### Example Usage
32+
33+
```
34+
flutterWebView.launch(
35+
"https://apptreesoftware.com",
36+
headers: {
37+
"X-SOME-HEADER": "MyCustomHeader",
38+
},
39+
javaScriptEnabled: false,
40+
toolbarActions: [
41+
new ToolbarAction("Dismiss", 1),
42+
new ToolbarAction("Reload", 2)
43+
],
44+
barColor: Colors.green,
45+
tintColor: Colors.white);
46+
flutterWebView.onToolbarAction.listen((identifier) {
47+
switch (identifier) {
48+
case 1:
49+
flutterWebView.dismiss();
50+
break;
51+
case 2:
52+
reload();
53+
break;
54+
}
55+
});
56+
flutterWebView.listenForRedirect("mobile://test.com", true);
57+
58+
flutterWebView.onWebViewDidStartLoading.listen((url) {
59+
setState(() => _isLoading = true);
60+
});
61+
flutterWebView.onWebViewDidLoad.listen((url) {
62+
setState(() => _isLoading = false);
63+
});
64+
flutterWebView.onRedirect.listen((url) {
65+
flutterWebView.dismiss();
66+
setState(() => _redirectedToUrl = url);
67+
});
68+
```

example/lib/main.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,7 @@ class _MyAppState extends State<MyApp> {
5151
return;
5252
}
5353

54-
flutterWebView.launch(
55-
"https://apptreesoftware.com",
54+
flutterWebView.launch("https://apptreesoftware.com",
5655
headers: {
5756
"X-SOME-HEADER": "MyCustomHeader",
5857
},
@@ -74,6 +73,7 @@ class _MyAppState extends State<MyApp> {
7473
}
7574
});
7675
flutterWebView.listenForRedirect("mobile://test.com", true);
76+
7777
flutterWebView.onWebViewDidStartLoading.listen((url) {
7878
setState(() => _isLoading = true);
7979
});
@@ -88,10 +88,10 @@ class _MyAppState extends State<MyApp> {
8888

8989
void reload() {
9090
flutterWebView.load(
91-
"https://google.com",
92-
headers: {
91+
"https://google.com",
92+
headers: {
9393
"X-SOME-HEADER": "MyCustomHeader",
94-
},
94+
},
9595
);
9696
}
9797
}

0 commit comments

Comments
 (0)