StringOr<T extends Object>.fromJson constructor

StringOr<T extends Object>.fromJson(
  1. dynamic json,
  2. T fromJsonT(
    1. Object? value
    )
)

Implementation

factory StringOr.fromJson(
  dynamic json,
  T Function(Object? value) fromJsonT,
) {
  if (json is String) {
    return StringOr<T>(string: json);
  } else if (json is Map) {
    return StringOr<T>(object: fromJsonT(json));
  } else {
    throw ArgumentError.value(
      json,
      'json',
      'Must be a String or Map',
    );
  }
}