parseListOfList<T, R> function

List<List<R>>? parseListOfList<T, R>(
  1. Object? s,
  2. ParserFunction<T, R> parser, [
  3. List<List<R>>? def
])

Parses s to a List<List<R>>, where R is the result of parse.

def The default value if s is invalid.

Implementation

List<List<R>>? parseListOfList<T, R>(Object? s, ParserFunction<T, R> parser,
    [List<List<R>>? def]) {
  if (s == null) return def;
  if (s is List) {
    return s
        .map((e) => parseListOf(e, parser))
        .where((e) => e != null)
        .cast<List<R>>()
        .toList();
  }
  var elem = parseListOf(s, parser);
  return elem != null ? [elem] : null;
}