loadFile method Null safety

Future<void> loadFile(
  1. {required String assetFilePath}
)

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");
...

Implementation

Future<void> loadFile({required String assetFilePath}) async {
  assert(assetFilePath.isNotEmpty);
  Map<String, dynamic> args = <String, dynamic>{};
  args.putIfAbsent('assetFilePath', () => assetFilePath);
  await _channel.invokeMethod('loadFile', args);
}