parseM3uChannelsWithStatsAsync function
Parse, validate, normalize, and deduplicate M3U channels through Rust, falling back to identical Dart behavior when unavailable.
Implementation
Future<M3uChannelParseResult> parseM3uChannelsWithStatsAsync(
String content,
) async {
if (kIsWeb) {
return _dartChannelsFromResult(_dartParseM3uWithStats(content));
}
if (!await initializeM3uParserBridge()) {
return _dartChannelsFromResult(_dartParseM3uWithStats(content));
}
try {
final result = await native_m3u.parseM3UChannelsWithStats(content: content);
return M3uChannelParseResult(
channels: result.channels.map(_fromNativeChannel).toList(),
stats: M3uParseStats(
parsedCount: result.stats.parsedCount,
skippedCount: result.stats.skippedCount,
malformedCount: result.stats.malformedCount,
// ignore: noop_primitive_operations
elapsedMillis: result.stats.elapsedMillis.toInt(),
),
);
} on Object {
return _dartChannelsFromResult(_dartParseM3uWithStats(content));
}
}