fromJson static method

AddAccountSchema? fromJson(
  1. dynamic value
)

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

Implementation

// ignore: prefer_constructors_over_static_methods
static AddAccountSchema? 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'username'),
          'Required key "AddAccountSchema[username]" is missing from JSON.');
      assert(json[r'username'] != null,
          'Required key "AddAccountSchema[username]" has a null value in JSON.');
      assert(json.containsKey(r'password'),
          'Required key "AddAccountSchema[password]" is missing from JSON.');
      assert(json[r'password'] != null,
          'Required key "AddAccountSchema[password]" has a null value in JSON.');
      assert(json.containsKey(r'email'),
          'Required key "AddAccountSchema[email]" is missing from JSON.');
      assert(json[r'email'] != null,
          'Required key "AddAccountSchema[email]" has a null value in JSON.');
      return true;
    }());

    return AddAccountSchema(
      username: mapValueOfType<String>(json, r'username')!,
      password: mapValueOfType<String>(json, r'password')!,
      email: mapValueOfType<String>(json, r'email')!,
    );
  }
  return null;
}