Skip to content

Commit

Permalink
fromJson method parameters value changed with dynamic
Browse files Browse the repository at this point in the history
  • Loading branch information
E-MRE committed Jun 7, 2024
1 parent b92ad19 commit 782e43d
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions lib/src/impl/type_registry.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,8 @@ class _TypeRegistry {
'Type is not registered. Did you forget to register it?',
);
}
if (json is Map<String, dynamic>) {
if (json is Map<String, dynamic> || json is List) {
value = handler.fromJson(json);
} else if (json is List<Map<String, dynamic>>) {
value = json.map(handler.fromJson).toList();
} else {
throw ArgumentError('Type mismatch. Expected Map<String,dynamic> '
'but got ${json.runtimeType}.');
Expand Down Expand Up @@ -74,7 +72,7 @@ class _TypeRegistry {
}
}

T? _noop<T>(Map<String, dynamic> json) {
T? _noop<T>(dynamic json) {
throw UnimplementedError();
}

Expand All @@ -87,7 +85,7 @@ class _TypeHandler<T> {

final int? typeId;

final T? Function(Map<String, dynamic> json) fromJson;
final T? Function(dynamic json) fromJson;

bool handlesValue(dynamic value) {
return value is T;
Expand Down

0 comments on commit 782e43d

Please sign in to comment.