fromJson static method

Folder? fromJson(
  1. dynamic value
)

Returns a new Folder instance and imports its values from value if it's a Map, null otherwise.

Implementation

// ignore: prefer_constructors_over_static_methods
static Folder? fromJson(dynamic value) {
  if (value is Map) {
    final json = value.cast<String, dynamic>();

    // Ensure that the map contains the required keys.
    // Note 1: the values aren't checked for validity beyond being non-null.
    // Note 2: this code is stripped in release mode!
    assert(() {
      assert(json.containsKey(r'id'), 'Required key "Folder[id]" is missing from JSON.');
      assert(json[r'id'] != null, 'Required key "Folder[id]" has a null value in JSON.');
      assert(json.containsKey(r'name'), 'Required key "Folder[name]" is missing from JSON.');
      assert(json[r'name'] != null, 'Required key "Folder[name]" has a null value in JSON.');
      assert(json.containsKey(r'path'), 'Required key "Folder[path]" is missing from JSON.');
      assert(json[r'path'] != null, 'Required key "Folder[path]" has a null value in JSON.');
      assert(json.containsKey(r'createdAt'), 'Required key "Folder[createdAt]" is missing from JSON.');
      assert(json[r'createdAt'] != null, 'Required key "Folder[createdAt]" has a null value in JSON.');
      assert(json.containsKey(r'updatedAt'), 'Required key "Folder[updatedAt]" is missing from JSON.');
      assert(json[r'updatedAt'] != null, 'Required key "Folder[updatedAt]" has a null value in JSON.');
      return true;
    }());

    return Folder(
      id: mapValueOfType<String>(json, r'id')!,
      provider: mapValueOfType<String>(json, r'provider'),
      accountId: mapValueOfType<String>(json, r'accountId'),
      name: mapValueOfType<String>(json, r'name')!,
      parentId: mapValueOfType<String>(json, r'parentId'),
      path: mapValueOfType<String>(json, r'path')!,
      createdAt: mapDateTime(json, r'createdAt', r'')!,
      updatedAt: mapDateTime(json, r'updatedAt', r'')!,
    );
  }
  return null;
}