I m creating a flutter project that can run on android & web platform. I m having problem with viewing html on web platform.
我在海底平台上使用了“金字眼”的原始网站概览,但这一原始图象并不支持网络平台。
import package:webview_flutter/webview_flutter.dart ;
class HelpScreen extends StatefulWidget {
const HelpScreen({super.key});
@override
HelpScreenState createState() {
return HelpScreenState();
}
}
class HelpScreenState extends State<HelpScreen> {
WebViewController? _controller;
@override
Widget build(BuildContext? context) {
// https://pub.dev/packages/webview_flutter
_controller = WebViewController()
..setJavaScriptMode(JavaScriptMode.unrestricted)
..setBackgroundColor(const Color(0x00000000))
..setNavigationDelegate(
NavigationDelegate(
onProgress: (int progress) {
// Update loading bar.
},
onPageStarted: (String url) {},
onPageFinished: (String url) {},
onWebResourceError: (WebResourceError error) {},
onNavigationRequest: (NavigationRequest request) {
return NavigationDecision.navigate;
},
),
)
..loadFlutterAsset("assets/Help.html");
return Scaffold(
appBar: AppBar(
title: Text(
help .tr,
style: AppStyle.buildToolbarCommandTextStyle(),
),
backgroundColor: AppStyle.logoGreen,
),
body: WebViewWidget(controller: _controller!));
}
}