Skip to content

On Windows, the API InAppWebViewController.loadFile({required String assetFilePath}) can't work, #2872

Description

@zouzg7829

Current Behavior

Example Code:
InAppWebView( key: webViewKey, initialSettings: settings, onWebViewCreated: (controller) { webViewController = controller; webViewController?.loadFile( assetFilePath: "assets/player/index.html", ); }, )

Debug the app, the DevTools print the message: Unsafe attempt to load URL file:///E:/Projects/flutter/inappwebview/build/windows/x64/runner/Debug/data/flutter_assets/assets/player/index.html from frame with URL file:///E:/Projects/flutter/inappwebview/build/windows/x64/runner/Debug/data/flutter_assets/assets/player/index.html. 'file:' URLs are treated as unique security origins.

Expected Behavior

the api should be ok on windows just
the [https://pub.dev/documentation/flutter_inappwebview/latest/flutter_inappwebview/InAppWebViewController/loadFile.html] described:
`Officially Supported Platforms/Implementations:

Android native WebView (Official API - WebView.loadUrl)
iOS (Official API - WKWebView.load)
MacOS (Official API - WKWebView.load)
Web
Windows (Official API - ICoreWebView2.Navigate)`

Steps with code example to reproduce

Steps with code example to reproduce
InAppWebView(
              key: webViewKey,
              initialSettings: settings,
              onWebViewCreated: (controller) {
                webViewController = controller;
                webViewController?.loadFile(
                  assetFilePath: "assets/player/index.html",
                );
              },
)

Stacktrace/Logs

Stacktrace/Logs
Debug the app, the DevTools print the message: Unsafe attempt to load URL file:///E:/Projects/flutter/inappwebview/build/windows/x64/runner/Debug/data/flutter_assets/assets/player/index.html from frame with URL file:///E:/Projects/flutter/inappwebview/build/windows/x64/runner/Debug/data/flutter_assets/assets/player/index.html. 'file:' URLs are treated as unique security origins.

Flutter version

Flutter 3.47.0-0.1.pre • channel master • https://github.com/flutter/flutter.git Framework • revision 48a522de6b (10 weeks ago) • 2026-05-12 16:34:34 +0800 Engine • hash a5b7bdf5a090b116d4cf8be405c4b4ed6c3f0b86 (revision 4f6c48822f) (2 months ago) • 2026-05-12 06:14:42.000Z Tools • Dart 3.13.0 (build 3.13.0-103.1.beta) • DevTools 2.58.0

Operating System, Device-specific and/or Tool

Windows10

Plugin version

flutter_inappwebview: ^6.1.5

Additional information

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions