load static method

void load(
  1. String path,
  2. bool crashIfNoLegalConfigFile,
  3. void onDone(
    1. AppcastItem? version
    )
)

Implementation

static void load(String path, bool crashIfNoLegalConfigFile, void Function(AppcastItem? version) onDone) {
  rootBundle.loadString(path).then((value) {
    final appcast = Appcast.fromJson(List<Map<String, dynamic>>.from(json.decode(value)));
    onDone.call(appcast.best()!);
  }).catchError((err) {
    debugPrint("[UpgradeManager] Cannot load current version info from path: $path, with error: ${err.toString()}");
    if (!crashIfNoLegalConfigFile) {
      onDone.call(null);
      return;
    }
    if (Platform.isAndroid) { SystemNavigator.pop(); } else { exit(0); }
  });
}