I'm creating a flutter project that can run on android & web platform. I'm having problem with viewing html on web platform.
I used a plugin webview_flutter to view html on android platform but this plugin doesn't support 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!));
}
}
I actually ended up using html_view instead of the
HtmlElementViewas thisplatformViewRegistrystill creates conflict when I run the whole code on android.Here's my code:
But still thankful for your suggestions. Thank you!