Use whereType()
instead of chaining where()
and cast()
.
This commit is contained in:
parent
165dd82813
commit
a4b56e7885
4 changed files with 9 additions and 10 deletions
|
@ -1,3 +1,7 @@
|
||||||
|
# 2.5.0
|
||||||
|
* Support mutable models (again).
|
||||||
|
* Use `whereType()` instead of chaining `where()` and `cast()`.
|
||||||
|
|
||||||
# 2.4.4
|
# 2.4.4
|
||||||
* Remove unnecessary `new` and `const`.
|
* Remove unnecessary `new` and `const`.
|
||||||
|
|
||||||
|
|
|
@ -282,8 +282,7 @@ class ${pascal}Decoder extends Converter<Map, ${pascal}> {
|
||||||
var rc = ReCase(type.typeArguments[0].name);
|
var rc = ReCase(type.typeArguments[0].name);
|
||||||
deserializedRepresentation = "map['$alias'] is Iterable"
|
deserializedRepresentation = "map['$alias'] is Iterable"
|
||||||
" ? List.unmodifiable(((map['$alias'] as Iterable)"
|
" ? List.unmodifiable(((map['$alias'] as Iterable)"
|
||||||
".where((x) => x is Map))"
|
".whereType<Map>())"
|
||||||
".cast<Map>()"
|
|
||||||
".map(${rc.pascalCase}Serializer.fromMap))"
|
".map(${rc.pascalCase}Serializer.fromMap))"
|
||||||
" : $defaultValue";
|
" : $defaultValue";
|
||||||
} else if (isMapToModelType(type)) {
|
} else if (isMapToModelType(type)) {
|
||||||
|
|
|
@ -479,9 +479,7 @@ class AuthorSerializer extends Codec<Author, Map> {
|
||||||
name: map['name'] as String,
|
name: map['name'] as String,
|
||||||
age: map['age'] as int,
|
age: map['age'] as int,
|
||||||
books: map['books'] is Iterable
|
books: map['books'] is Iterable
|
||||||
? List.unmodifiable(
|
? List.unmodifiable(((map['books'] as Iterable).whereType<Map>())
|
||||||
((map['books'] as Iterable).where((x) => x is Map))
|
|
||||||
.cast<Map>()
|
|
||||||
.map(BookSerializer.fromMap))
|
.map(BookSerializer.fromMap))
|
||||||
: null,
|
: null,
|
||||||
newestBook: map['newest_book'] != null
|
newestBook: map['newest_book'] != null
|
||||||
|
|
|
@ -160,9 +160,7 @@ class GamepadSerializer extends Codec<Gamepad, Map> {
|
||||||
static Gamepad fromMap(Map map) {
|
static Gamepad fromMap(Map map) {
|
||||||
return Gamepad(
|
return Gamepad(
|
||||||
buttons: map['buttons'] is Iterable
|
buttons: map['buttons'] is Iterable
|
||||||
? List.unmodifiable(
|
? List.unmodifiable(((map['buttons'] as Iterable).whereType<Map>())
|
||||||
((map['buttons'] as Iterable).where((x) => x is Map))
|
|
||||||
.cast<Map>()
|
|
||||||
.map(GamepadButtonSerializer.fromMap))
|
.map(GamepadButtonSerializer.fromMap))
|
||||||
: null,
|
: null,
|
||||||
dynamicMap: map['dynamic_map'] is Map
|
dynamicMap: map['dynamic_map'] is Map
|
||||||
|
|
Loading…
Reference in a new issue