load method

  1. @override
Future<bool> load(
  1. VoltronBridgeManager bridge,
  2. Callback callback
)
override

Implementation

@override
Future<bool> load(VoltronBridgeManager bridge, Callback callback) async {
  var curFilePath = _filePath??'';
  if (isEmpty(curFilePath)) {
    return false;
  }
  var result = false;
  var watch = Stopwatch();
  watch.start();
  String uri = (!curFilePath.startsWith('file://'))
      ? ('file://$curFilePath')
      : curFilePath;
  try {
    result = await bridge
        .runScriptFromUri(uri, _canUseCodeCache, _codeCacheTag, (value) {
      watch.stop();
      LogUtils.profile("runScriptFromFile", watch.elapsedMilliseconds);
      callback(value, null);
    });
  } catch (e) {
    callback(-1, StateError(e.toString()));
  }

  return result;
}