reload method

Future<bool> reload()

Implementation

Future<bool> reload() async {
  if (_service == null) {
    throw Exception("Recharge not initilized. Call init() with await.");
  }
  // Reload main isolate. This only reloads the code. Nothing is executed
  // or no data is modified after this.
  final res = await _service!.reloadSources(_mainIsolate!);

  // Log the result of reload. If it was a failure print the message
  // from reload report. This map is not documented. It may change I guess.
  // Hence inside a try catch.
  if (res.success!) {
    print("Reload success");
  } else {
    print("Reload failed");
    try {
      print(res.json!["notices"][0]["message"]);
    } catch (e) {}
  }

  return res.success!;
}