get method

Future<Resource?> get({
  1. required Dstu2ResourceType resourceType,
  2. required String id,
  3. String? pw,
})

function used to save a new resource in the db

Implementation

Future<Resource?> get({
  required Dstu2ResourceType resourceType,
  required String id,
  String? pw,
}) async {
  await _ensureInit(pw: pw);
  final Box<Map<dynamic, dynamic>> box =
      await _getBox(resourceType: resourceType, pw: pw);
  final Map<dynamic, dynamic>? resourceMap = box.get(id);

  try {
    return resourceMap == null
        ? null
        : Resource.fromJson(
            jsonDecode(jsonEncode(resourceMap)) as Map<String, dynamic>);
  } catch (e, s) {
    print(e);
    print(s);
    return null;
  }
}