enableDynamicAssets method

void enableDynamicAssets(
  1. String filePath
)

Implementation

void enableDynamicAssets(String filePath){
  print("Adding asset channel for mini program: ${_module.id}");
  NUISystem.setAssetChannel(_module.id, (key) async {
    return (await loadAsset(key))!;
  });
  // print("NUIMiniProgramFileManager, Enabling dynamic assets for $filePath");
  // final String assetFolderPath = Platform.environment['UNIT_TEST_ASSETS'];
  // final String prefix =  'packages/${Platform.environment['APP_NAME']}/';
  // final String channel = _FLUTTER_ASSETS_CHANNEL;
  //
  //
  // ServicesBinding.instance.defaultBinaryMessenger.setMessageHandler(channel, (ByteData message) {
  //   print("NUIMiniProgramFileManager: Received message handler for flutter assets");
  //   String key = utf8.decode(message.buffer.asUint8List());
  //   File asset = isNullOrEmpty(assetFolderPath) ? File(key) : File(path.join(assetFolderPath, key));
  //
  //   if (!asset.existsSync()) {
  //     if (!key.startsWith(prefix)) {
  //       return _sendPlatformMessage(channel, message);
  //     }
  //
  //     key = key.replaceFirst(prefix, '');
  //     asset = !isNullOrEmpty(assetFolderPath) ? File(path.join(assetFolderPath, key)) : File(key);
  //     if (!asset.existsSync()) {
  //       return _sendPlatformMessage(channel, message);
  //     }
  //   }
  //
  //   final Uint8List encoded = Uint8List.fromList(asset.readAsBytesSync());
  //   return Future<ByteData>.value(encoded.buffer.asByteData());
  // });
}