StringOr<T extends Object>.fromJson constructor
StringOr<T extends Object>.fromJson (
- dynamic json,
- T fromJsonT(
- 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',
);
}
}