openFile method
Future<void>
openFile({
- required String assetFilePath,
- @Deprecated('Use settings instead') InAppBrowserClassOptions? options,
- InAppBrowserClassSettings? settings,
Opens the PlatformInAppBrowser
instance with the given assetFilePath
file.
options
: Options for the PlatformInAppBrowser
.
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 of a main.dart
file:
...
inAppBrowser.openFile(assetFilePath: "assets/index.html");
...
headers
: The additional headers to be used in the HTTP request for this URL, specified as a map from name to value.
options
: Options for the PlatformInAppBrowser
.
settings
: Settings for the PlatformInAppBrowser
.
Officially Supported Platforms/Implementations:
- Android native WebView
- iOS
- MacOS
- Windows
Implementation
@override
Future<void> openFile(
{required String assetFilePath,
// ignore: deprecated_member_use_from_same_package
@Deprecated('Use settings instead') InAppBrowserClassOptions? options,
InAppBrowserClassSettings? settings}) async {
assert(assetFilePath.isNotEmpty);
Map<String, dynamic> args =
_prepareOpenRequest(options: options, settings: settings);
args.putIfAbsent('assetFilePath', () => assetFilePath);
await _staticChannel.invokeMethod('open', args);
}