admin管理员组

文章数量:1287164

How can I load different local HTML files into a WebView in Flutter depending on the language and whether the dark or light mode is active? Unless the system language is set to German, should the English language files be loaded depending on whether the dark or light mode is active?

I have tried it with the following code

 void initState() {
super.initState();
if(languageCode == "de" && Theme.of(context).brightness == Brightness.light){

  _controller = WebViewController();
  _controller.loadFlutterAsset('assets/html/heading_de.html');
}else if(languageCode == "de" && Theme.of(context).brightness == Brightness.dark) {
   _controller = WebViewController();
  _controller.loadFlutterAsset('assets/html/heading_de.html');     
}

}

Widget build(BuildContext context) {
return Scaffold(
  appBar: AppBar(),
  body: WebViewWidget(controller: _controller),
);

} }

But without success.

Can someone please give me a tip on the best way to do this.

Best regards Petra Ritter

本文标签: How to load different HTML files in a webView on flutterStack Overflow