loadFile method
Loads the given assetFilePath.
To be able to load your local files (assets, js, css, etc.), you need to add them in the assets section of the pubspec.yaml file, otherwise they cannot be found!
Example of a pubspec.yaml file:
...
# The following section is specific to Flutter.
flutter:
# The following line ensures that the Material Icons font is
# included with your application, so that you can use the icons in
# the material Icons class.
uses-material-design: true
assets:
- assets/index.html
- assets/css/
- assets/images/
...
Example:
...
controller.loadFile(assetFilePath: "assets/index.html");
...
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)
Implementation
Future<void> loadFile({required String assetFilePath}) =>
platform.loadFile(assetFilePath: assetFilePath);