import 'dart:io'; import 'package:flutter/material.dart'; import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:huixiang/view_widget/my_appbar.dart'; import 'package:webview_flutter/webview_flutter.dart'; import '../generated/l10n.dart'; class UserServicePage extends StatefulWidget { @override State createState() { return _UserServicePage(); } } class _UserServicePage extends State with WidgetsBindingObserver { var controller = new ScrollController(); late WebViewController _webViewController; @override void initState() { super.initState(); WidgetsBinding.instance.addObserver(this); EasyLoading.show(status: S.current.zhengzaijiazai,maskType: EasyLoadingMaskType.black); _webViewController = WebViewController() ..setJavaScriptMode(JavaScriptMode.unrestricted) ..setNavigationDelegate( NavigationDelegate( onProgress: (int progress) {}, onPageStarted: (String url) {}, onPageFinished: (String url) { EasyLoading.dismiss(); }, onWebResourceError: (WebResourceError error) {}, onNavigationRequest: (NavigationRequest request) { // if (request.url.startsWith('https://www.youtube.com/')) { // return NavigationDecision.prevent; // } return NavigationDecision.navigate; }, ), ) ..loadRequest(Uri.parse("http://huixiang.lotus-wallet.com/user.html")); } @override Widget build(BuildContext context) { return Scaffold( appBar: MyAppBar( title:"用户协议", titleColor: Colors.black, background: Color(0xFFFFFFFF), leadingColor: Colors.black, ), body: Container( width: MediaQuery.of(context).size.width, height: MediaQuery.of(context).size.height, alignment: Alignment.center, child: WebViewWidget( controller: _webViewController, ), ), ); } }