@@ -18,6 +18,13 @@ class BrowserScreen extends StatefulWidget {
1818class _BrowserScreenState extends State <BrowserScreen > {
1919 final _controller = AdBlockerWebviewController .instance;
2020 bool _canGoBack = false ;
21+ String _appbarUrl = "" ;
22+
23+ @override
24+ void initState () {
25+ super .initState ();
26+ _appbarUrl = widget.url.host;
27+ }
2128
2229 @override
2330 Widget build (BuildContext context) {
@@ -36,7 +43,7 @@ class _BrowserScreenState extends State<BrowserScreen> {
3643 },
3744 child: Scaffold (
3845 appBar: AppBar (
39- title: Text (widget.url.host ),
46+ title: Text (_appbarUrl ),
4047 leading: IconButton (
4148 icon: const Icon (Icons .arrow_back),
4249 onPressed: () async {
@@ -75,7 +82,7 @@ class _BrowserScreenState extends State<BrowserScreen> {
7582 },
7683 onLoadFinished: (url) {
7784 debugPrint ('Finished loading: $url ' );
78- _updateNavigationState ();
85+ _updateNavigationState (url );
7986 },
8087 onLoadError: (url, code) {
8188 debugPrint ('Error loading: $url (code: $code )' );
@@ -89,21 +96,22 @@ class _BrowserScreenState extends State<BrowserScreen> {
8996 onProgress: (progress) {
9097 debugPrint ('Loading progress: $progress %' );
9198 },
92- onUrlChanged: (_ ) {
93- _updateNavigationState ();
99+ onUrlChanged: (url ) {
100+ _updateNavigationState (url );
94101 },
95102 ),
96103 ),
97104 );
98105 }
99106
100- Future <void > _updateNavigationState () async {
107+ Future <void > _updateNavigationState (String ? url ) async {
101108 if (! mounted) return ;
102109
103110 final canGoBack = await _controller.canGoBack ();
104111 if (canGoBack != _canGoBack) {
105112 setState (() {
106113 _canGoBack = canGoBack;
114+ _appbarUrl = Uri .tryParse (url ?? "" )? .host ?? "" ;
107115 });
108116 }
109117 }
0 commit comments