getStorageList function

Future<List> getStorageList(
  1. String key, {
  2. required String listKey,
  3. required dynamic onModels(
    1. Map<String, dynamic> json
    ),
})

var models = await getStorageList(_orderNoKey, listKey: _orderNoForUserKey, onModels: (json) { return BaseKeyValue.fromJson(json); });

Implementation

Future<List> getStorageList(String key,
    {required String listKey,
    required Function(Map<String, dynamic> json) onModels}) async {
  final map = await getStorageMap(key);
  var models = [];
  if (map != null) {
    final list = map[listKey];
    try {
      if (list.length > 0) {
        models = list.map((v) => onModels(v)).toList();
      }
    } catch (e) {
      logDebug(e);
    }
  }
  return models;
}