search method

Future<Iterable<Resource>> search({
  1. required Dstu2ResourceType resourceType,
  2. required bool finder(
    1. Map<String, dynamic>
    ),
  3. String? pw,
})

Implementation

Future<Iterable<Resource>> search({
  required Dstu2ResourceType resourceType,
  required bool Function(Map<String, dynamic>) finder,
  String? pw,
}) async {
  await _ensureInit(pw: pw);
  final Box<Map<dynamic, dynamic>> box =
      await _getBox(resourceType: resourceType, pw: pw);
  final Map<dynamic, Map<dynamic, dynamic>> boxData = box.toMap();
  boxData.removeWhere((dynamic key, Map<dynamic, dynamic> value) =>
      !finder(Map<String, dynamic>.from(value)));
  return boxData.values
      .map((Map<dynamic, dynamic> e) =>
          jsonDecode(jsonEncode(e)) as Map<String, dynamic>)
      .map((Map<String, dynamic> e) => Resource.fromJson(e))
      .toList();
}