fromMap method
Creates a List<TModel> from a map
of type Map<String, DynamicMap> decoded from Json.
The number of elements output can be limited by specifying limit
.
JsonからデコードされたMap<String, DynamicMap>型のmap
からList<TModel>を作成します。
limit
を指定することで出力される要素数を制限することが可能です。
Implementation
@protected
Future<List<TModel>> fromMap(Map<String, DynamicMap> map, int? limit) async {
final res = <TModel>[];
final sorted = modelQuery.sort(List.from(map.entries));
for (final tmp in sorted) {
final key =
tmp.key.replaceAll("/", "").replaceAll("?", "").replaceAll("&", "");
if (key.isEmpty) {
continue;
}
final value = create(key);
final filtered = value.filterOnLoad(
ModelFieldValue.fromMap(Map<String, dynamic>.unmodifiable(tmp.value)),
);
if (filtered.isEmpty) {
value._value = null;
} else {
value._value = value.fromMap(filtered);
}
res.add(value);
}
return limit != null ? res.sublist(0, min(limit, res.length)) : res;
}