load method
Implementation
@override
Future<void> load() async {
logger.info('Fetching version info for $_channelRepr from $jsonIndexUrl');
final Map<String, dynamic> raw;
try {
final body = await fetcher.readAsString(jsonIndexUrl);
raw = Map<String, dynamic>.from(jsonDecode(body) as Map);
} on FormatException catch (e) {
throw UfbtValueError('Invalid JSON: ${e.message}');
}
final index = UfbtDirectoryIndex.fromJson(raw);
if (index.channels.isEmpty) {
throw UfbtValueError('Invalid channel: $_channelRepr');
}
final channelData = index.findChannel(channel.id);
if (channelData == null) {
throw UfbtValueError('Invalid channel: $_channelRepr');
}
if (channelData.versions.isEmpty) {
throw UfbtValueError('Empty channel: $_channelRepr');
}
final version = channelData.versions.first;
logger.info('Using version: ${version.version}');
logger.debug('Changelog: ${version.changelog ?? 'None'}');
_versionInfo = version;
}