Flutter 如何获得颤振';使用从本地html加载的本地资产时,是否使用Web视图?

Flutter 如何获得颤振';使用从本地html加载的本地资产时,是否使用Web视图?,flutter,flutter-dependencies,flutterwebviewplugin,Flutter,Flutter Dependencies,Flutterwebviewplugin,我有一个html文件加载css文件,字体和图像文件。目前,我的webview加载时没有加载任何这些辅助文件,没有显示图像,也没有显示css。我试着这样做: loadHtmlFromAssets(); return WebviewScaffold( appBar: AppBar( title: Text("Web", style: TextStyle(color: Colors.black),), backgroundColor: Col

我有一个html文件加载css文件,字体和图像文件。目前,我的webview加载时没有加载任何这些辅助文件,没有显示图像,也没有显示css。我试着这样做:

    loadHtmlFromAssets();
    return WebviewScaffold(
      appBar: AppBar(
        title: Text("Web", style: TextStyle(color: Colors.black),),
        backgroundColor: Colors.white,
        iconTheme: IconThemeData(
            color: Colors.black
        ),
      ),
      url: 'about:blank',
      withZoom: false,
      withJavascript: true,
      allowFileURLs: true,
      withLocalUrl: true,
      localUrlScope: 'assets/maphtml/',
      withLocalStorage: true,
    );

loadHtmlFromAssets() async {
    String fileText = await rootBundle.loadString('assets/maphtml/zemelapis.html');
    flutterWebViewPlugin.reloadUrl(Uri.dataFromString(fileText, mimeType: 'text/html', encoding: Encoding.getByName("utf-8")).toString());
  }
html中的资产假定前缀为zemelapis.html location,例如

<script src="js/image-map-pro.min.js"></script>

您可以在生成Uri之前将js内容添加到html正文中

static void loadHtmlFromAssets(String fileText) async{

String htmlText = await rootBundle.loadString('assets/maphtml/zemelapis.html');
final String jsText = await rootBundle.loadString('assets/maphtml/js/image-map-pro.min.js'); //set exact js file path

//add js to html body
htmlText = '${htmlText}<script>${jsText}</script>';

flutterWebViewPlugin.reloadUrl(Uri.dataFromString(htmlText, mimeType: 'text/html', encoding: Encoding.getByName("utf-8")).toString());
static void loadHtmlFromAssets(字符串文件文本)异步{
String htmlText=await rootBundle.loadString('assets/maphtml/zemelapis.html');
final String jsText=await rootBundle.loadString('assets/maphtml/js/image-map-pro.min.js');//设置确切的js文件路径
//将js添加到html正文
htmlText='${htmlText}${jsText}';
FlightWebViewPlugin.reloadUrl(Uri.dataFromString(htmlText,mimeType:'text/html',编码:encoding.getByName(“utf-8”)).toString();
}