openAsset static method

Future openAsset(
  1. String bookPath, {
  2. EpubLocator? lastLocation,
})

bookPath should be an asset file path. Last location is only available for android.

Implementation

static Future openAsset(String bookPath, {EpubLocator? lastLocation}) async {
  if (extension(bookPath) == '.epub') {
    Map<String, dynamic> agrs = {
      "bookPath": (await Util.getFileFromAsset(bookPath)).path,
      'lastLocation': lastLocation == null ? '' : jsonEncode(lastLocation.toJson()),
    };
    _channel.invokeMethod('setChannel');
    await _channel.invokeMethod('open', agrs);
  } else {
    throw ('${extension(bookPath)} cannot be opened, use an EPUB File');
  }
}