fromJson static method

AccountPlan? fromJson(
  1. dynamic value
)

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

Implementation

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

    return AccountPlan(
      tier: mapValueOfType<String>(json, r'tier')!,
      displayName: mapValueOfType<String>(json, r'display_name')!,
      subscriptionStatus: mapValueOfType<String>(json, r'subscription_status')!,
      trialEndsAt: mapDateTime(json, r'trial_ends_at', r''),
    );
  }
  return null;
}