Skip to content

Commit b297036

Browse files
committed
Optimize Vec serialization
1 parent 7e1b078 commit b297036

File tree

3 files changed

+15
-16
lines changed

3 files changed

+15
-16
lines changed

lib/src/api/models/effect.g.dart

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/src/api/models/vec.dart

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ import 'size.dart';
1313
part 'vec.g.dart';
1414

1515
/// Represents a vector in 2D space.
16-
@JsonSerializable()
17-
class Vec with SerializableMixin, EquatableMixin {
16+
@JsonSerializable(useDynamics: true)
17+
class Vec with DynamicSerializableMixin, EquatableMixin {
1818
/// X value: Typically the position on the horizontal x axis in 2D space.
1919
final double x;
2020

@@ -139,8 +139,13 @@ class Vec with SerializableMixin, EquatableMixin {
139139
String toString() => 'Vec{x: $x, y: $y}';
140140

141141
/// Creates a [Vec] from the given [json] map.
142-
factory Vec.fromJson(Map json) => _$VecFromJson(json);
142+
factory Vec.fromJson(dynamic json) {
143+
if (json case [num x, num y]) {
144+
return Vec(x.toDouble(), y.toDouble());
145+
}
146+
return _$VecFromJson(json);
147+
}
143148

144149
@override
145-
Map toJson() => _$VecToJson(this);
150+
dynamic toJson() => [x, y];
146151
}

lib/src/api/nodes/web_view_google_maps_properties.g.dart

Lines changed: 5 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)