NativeManifest.parse constructor

NativeManifest.parse(
  1. String text, {
  2. required String tag,
})

Reads shasum -a 256 lines (<hex> <path>); # lines are comments. Throws FormatException.

Implementation

factory NativeManifest.parse(String text, {required String tag}) {
  final entries = <String, String>{};
  for (final line in text.split('\n')) {
    if (line.trim().isEmpty || line.startsWith('#')) continue;
    final m = RegExp(r'^([0-9a-f]{64}) [ *](\S+)$').firstMatch(line.trimRight());
    if (m == null) throw FormatException('not a manifest line: $line');
    entries[m[2]!] = m[1]!;
  }
  return NativeManifest._(tag, Map.unmodifiable(entries));
}