readCollection<T> static method
Read the collection values using a key
.
Implementation
static Future<List<T>> readCollection<T>(String key,
{Map<Type, dynamic>? modelDecoders}) async {
String? data = await read(key);
if (data == null || data == "") return [];
List<dynamic> listData = jsonDecode(data);
if (!["dynamic", "string", "double", "int"]
.contains(T.toString().toLowerCase())) {
return List.from(listData)
.map((json) =>
dataToModel<T>(data: json, modelDecoders: modelDecoders))
.toList();
}
return List.from(listData).toList().cast();
}