Open DavidMGT opened 4 years ago
Issue occurs on: iOS Plugin version: flutter_webview_plugin: any Flutter doctor output:
flutter: 0.1 flutter: ┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── flutter: │ #0 showLog (package:union_flutter/appkit/util/util.dart:1:1207) flutter: │ #1 _WebViewPageState.initState.() (package:union_flutter/module/web_page/web_view_page.dart:33:7) flutter: ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄ flutter: │ 🐛 onUrlChangeed https://pages.yiwuhaoyun.com/rent flutter: └─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── flutter: ┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── flutter: │ #0 showLog (package:union_flutter/appkit/util/util.dart:1:1207) flutter: │ #1 _WebViewPageState.initState.() (package:union_flutter/module/web_page/web_view_page.dart:33:7) flutter: ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄ flutter: │ 🐛 onUrlChangeed http://pages.yiwuhaoyun.com/rent/ ## Steps to Reproduce here is my code import 'dart:core'; import 'package:flutter/material.dart'; import 'package:flutter_webview_plugin/flutter_webview_plugin.dart'; import 'package:union_flutter/appkit/util/util.dart'; class WebViewPage extends StatefulWidget { final String url; final String title; static const String routeName = "/webview"; WebViewPage({this.url, this.title}); _WebViewPageState createState() => _WebViewPageState(); } class _WebViewPageState extends State<WebViewPage> { final flutterWebviewPlugin = new FlutterWebviewPlugin(); final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>(); var lineProgress; @override void initState() { super.initState(); //showLog('WebViewPage ${Uri.encodeFull(widget.url)}'); flutterWebviewPlugin.onUrlChanged.listen((String url) { showLog('onUrlChangeed '+url); }); flutterWebviewPlugin.onProgressChanged.listen((progress) { print(progress); setState(() { lineProgress = progress; }); }); } _progressBar(double progress, BuildContext context) { return LinearProgressIndicator( backgroundColor: Colors.white70.withOpacity(0), value: progress == 1.0 ? 0 : progress, valueColor: new AlwaysStoppedAnimation<Color>(Colors.white), ); } @override Widget build(BuildContext context) { return WebviewScaffold( appBar: AppBar( title: Text(widget.title), bottom: PreferredSize( child: _progressBar(lineProgress, context), preferredSize: Size.fromHeight(3.0), ), ), key: ObjectKey(widget.url), url: Uri.encodeFull(widget.url), withZoom: true, withLocalStorage: true, withJavascript: true, useWideViewPort: true, displayZoomControls: true, withOverviewMode: true, ); } @override void dispose() { super.dispose(); } } 1.the onUrlChange was called twice.and change my url from “https” to "http" 2.I add it in my homepage _pages.add(WebViewPage( url: URLS.RENT_URL, title: '租买货车', )); 3. ... ## Logs
<!-- Run `flutter analyze` and attach any output of that command below. If there are any analysis errors, try resolving them before filing this issue. -->
<!-- Finally, paste the output of running `flutter doctor -v` here. -->
@DavidMGT
static const String routeName = "/webview";
to
static const String routeName = "/";
System info
Issue occurs on: iOS Plugin version: flutter_webview_plugin: any Flutter doctor output: