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 reg = RegExp(r"^https?:\/\/");
  var curUrl = _url ?? '';
  if (isEmpty(curUrl) || !reg.hasMatch(curUrl)) {
    return false;
  }
  var result = false;
  var watch = Stopwatch();
  watch.start();
  try {
    result = await bridge.runScriptFromUri(
      curUrl,
      _canUseCodeCache,
      _codeCacheTag,
      (value) {
        watch.stop();
        LogUtils.profile("runScriptFromFile", watch.elapsedMilliseconds);
        callback(value, null);
      },
    );
  } catch (e) {
    callback(-1, StateError(e.toString()));
  }

  return result;
}