themeKeyLine function
The line (from 1) of text (a manifest's JSON as written) on which the
key at path under "theme" is written; the "theme" key's when one of
path is not found, null when that is not.
Implementation
int? themeKeyLine(String text, List<String> path) {
var at = 0;
int? found;
for (final key in ['theme', ...path]) {
final m = RegExp('"${RegExp.escape(key)}"\\s*:').allMatches(text, at).firstOrNull;
if (m == null) break;
found = m.start;
at = m.end;
}
return found == null ? null : '\n'.allMatches(text.substring(0, found)).length + 1;
}