import 'package:flutter/material.dart'; import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:huixiang/generated/l10n.dart'; import 'package:huixiang/view_widget/my_appbar.dart'; import 'package:webview_flutter/webview_flutter.dart'; class ScanWeb extends StatefulWidget { final Map? arguments; ScanWeb({this.arguments}); @override State createState() { return _ScanWeb(); } } class _ScanWeb extends State { var controller = new ScrollController(); late WebViewController _webViewController; String? result; String? title; @override void initState() { super.initState(); result = widget.arguments?["result"]; title = widget.arguments?["title"]; EasyLoading.show(status: S.current.zhengzaijiazai,maskType: EasyLoadingMaskType.black); if (result?.isNotEmpty ?? false) { _webViewController = WebViewController() ..setJavaScriptMode(JavaScriptMode.unrestricted) ..setNavigationDelegate( NavigationDelegate( onProgress: (int progress) { // Update loading bar. }, onPageStarted: (String url) {}, onPageFinished: (String url) {}, onWebResourceError: (WebResourceError error) {}, onNavigationRequest: (NavigationRequest request) { // if (request.url.startsWith('https://www.youtube.com/')) { // return NavigationDecision.prevent; // } return NavigationDecision.navigate; }, ), ) ..loadRequest(Uri.parse(result!)); } } @override Widget build(BuildContext context) { return Scaffold( appBar: MyAppBar( title:title ?? "", titleColor: Colors.black, background: Colors.transparent, leadingColor: Colors.black, ), body: WebViewWidget( controller: _webViewController, ), ); } }