mirror of
https://github.com/flutter/samples.git
synced 2025-11-10 06:48:26 +00:00
Landing beta changes in master for the new stable release (#747)
This commit is contained in:
@@ -14,29 +14,21 @@ abstract class BuiltComplexObject
|
||||
static Serializer<BuiltComplexObject> get serializer =>
|
||||
_$builtComplexObjectSerializer;
|
||||
|
||||
@nullable
|
||||
String get aString;
|
||||
String? get aString;
|
||||
|
||||
@nullable
|
||||
int get anInt;
|
||||
int? get anInt;
|
||||
|
||||
@nullable
|
||||
double get aDouble;
|
||||
double? get aDouble;
|
||||
|
||||
@nullable
|
||||
BuiltSimpleObject get anObject;
|
||||
BuiltSimpleObject? get anObject;
|
||||
|
||||
@nullable
|
||||
BuiltList<String> get aListOfStrings;
|
||||
BuiltList<String>? get aListOfStrings;
|
||||
|
||||
@nullable
|
||||
BuiltList<int> get aListOfInts;
|
||||
BuiltList<int>? get aListOfInts;
|
||||
|
||||
@nullable
|
||||
BuiltList<double> get aListOfDoubles;
|
||||
BuiltList<double>? get aListOfDoubles;
|
||||
|
||||
@nullable
|
||||
BuiltList<BuiltSimpleObject> get aListOfObjects;
|
||||
BuiltList<BuiltSimpleObject>? get aListOfObjects;
|
||||
|
||||
BuiltComplexObject._();
|
||||
|
||||
|
||||
@@ -20,55 +20,63 @@ class _$BuiltComplexObjectSerializer
|
||||
Iterable<Object> serialize(Serializers serializers, BuiltComplexObject object,
|
||||
{FullType specifiedType = FullType.unspecified}) {
|
||||
final result = <Object>[];
|
||||
if (object.aString != null) {
|
||||
Object? value;
|
||||
value = object.aString;
|
||||
if (value != null) {
|
||||
result
|
||||
..add('aString')
|
||||
..add(serializers.serialize(object.aString,
|
||||
..add(serializers.serialize(value,
|
||||
specifiedType: const FullType(String)));
|
||||
}
|
||||
if (object.anInt != null) {
|
||||
value = object.anInt;
|
||||
if (value != null) {
|
||||
result
|
||||
..add('anInt')
|
||||
..add(serializers.serialize(object.anInt,
|
||||
specifiedType: const FullType(int)));
|
||||
..add(serializers.serialize(value, specifiedType: const FullType(int)));
|
||||
}
|
||||
if (object.aDouble != null) {
|
||||
value = object.aDouble;
|
||||
if (value != null) {
|
||||
result
|
||||
..add('aDouble')
|
||||
..add(serializers.serialize(object.aDouble,
|
||||
..add(serializers.serialize(value,
|
||||
specifiedType: const FullType(double)));
|
||||
}
|
||||
if (object.anObject != null) {
|
||||
value = object.anObject;
|
||||
if (value != null) {
|
||||
result
|
||||
..add('anObject')
|
||||
..add(serializers.serialize(object.anObject,
|
||||
..add(serializers.serialize(value,
|
||||
specifiedType: const FullType(BuiltSimpleObject)));
|
||||
}
|
||||
if (object.aListOfStrings != null) {
|
||||
value = object.aListOfStrings;
|
||||
if (value != null) {
|
||||
result
|
||||
..add('aListOfStrings')
|
||||
..add(serializers.serialize(object.aListOfStrings,
|
||||
..add(serializers.serialize(value,
|
||||
specifiedType:
|
||||
const FullType(BuiltList, const [const FullType(String)])));
|
||||
}
|
||||
if (object.aListOfInts != null) {
|
||||
value = object.aListOfInts;
|
||||
if (value != null) {
|
||||
result
|
||||
..add('aListOfInts')
|
||||
..add(serializers.serialize(object.aListOfInts,
|
||||
..add(serializers.serialize(value,
|
||||
specifiedType:
|
||||
const FullType(BuiltList, const [const FullType(int)])));
|
||||
}
|
||||
if (object.aListOfDoubles != null) {
|
||||
value = object.aListOfDoubles;
|
||||
if (value != null) {
|
||||
result
|
||||
..add('aListOfDoubles')
|
||||
..add(serializers.serialize(object.aListOfDoubles,
|
||||
..add(serializers.serialize(value,
|
||||
specifiedType:
|
||||
const FullType(BuiltList, const [const FullType(double)])));
|
||||
}
|
||||
if (object.aListOfObjects != null) {
|
||||
value = object.aListOfObjects;
|
||||
if (value != null) {
|
||||
result
|
||||
..add('aListOfObjects')
|
||||
..add(serializers.serialize(object.aListOfObjects,
|
||||
..add(serializers.serialize(value,
|
||||
specifiedType: const FullType(
|
||||
BuiltList, const [const FullType(BuiltSimpleObject)])));
|
||||
}
|
||||
@@ -85,7 +93,7 @@ class _$BuiltComplexObjectSerializer
|
||||
while (iterator.moveNext()) {
|
||||
final key = iterator.current as String;
|
||||
iterator.moveNext();
|
||||
final dynamic value = iterator.current;
|
||||
final Object value = iterator.current;
|
||||
switch (key) {
|
||||
case 'aString':
|
||||
result.aString = serializers.deserialize(value,
|
||||
@@ -137,24 +145,24 @@ class _$BuiltComplexObjectSerializer
|
||||
|
||||
class _$BuiltComplexObject extends BuiltComplexObject {
|
||||
@override
|
||||
final String aString;
|
||||
final String? aString;
|
||||
@override
|
||||
final int anInt;
|
||||
final int? anInt;
|
||||
@override
|
||||
final double aDouble;
|
||||
final double? aDouble;
|
||||
@override
|
||||
final BuiltSimpleObject anObject;
|
||||
final BuiltSimpleObject? anObject;
|
||||
@override
|
||||
final BuiltList<String> aListOfStrings;
|
||||
final BuiltList<String>? aListOfStrings;
|
||||
@override
|
||||
final BuiltList<int> aListOfInts;
|
||||
final BuiltList<int>? aListOfInts;
|
||||
@override
|
||||
final BuiltList<double> aListOfDoubles;
|
||||
final BuiltList<double>? aListOfDoubles;
|
||||
@override
|
||||
final BuiltList<BuiltSimpleObject> aListOfObjects;
|
||||
final BuiltList<BuiltSimpleObject>? aListOfObjects;
|
||||
|
||||
factory _$BuiltComplexObject(
|
||||
[void Function(BuiltComplexObjectBuilder) updates]) =>
|
||||
[void Function(BuiltComplexObjectBuilder)? updates]) =>
|
||||
(new BuiltComplexObjectBuilder()..update(updates)).build();
|
||||
|
||||
_$BuiltComplexObject._(
|
||||
@@ -224,62 +232,63 @@ class _$BuiltComplexObject extends BuiltComplexObject {
|
||||
|
||||
class BuiltComplexObjectBuilder
|
||||
implements Builder<BuiltComplexObject, BuiltComplexObjectBuilder> {
|
||||
_$BuiltComplexObject _$v;
|
||||
_$BuiltComplexObject? _$v;
|
||||
|
||||
String _aString;
|
||||
String get aString => _$this._aString;
|
||||
set aString(String aString) => _$this._aString = aString;
|
||||
String? _aString;
|
||||
String? get aString => _$this._aString;
|
||||
set aString(String? aString) => _$this._aString = aString;
|
||||
|
||||
int _anInt;
|
||||
int get anInt => _$this._anInt;
|
||||
set anInt(int anInt) => _$this._anInt = anInt;
|
||||
int? _anInt;
|
||||
int? get anInt => _$this._anInt;
|
||||
set anInt(int? anInt) => _$this._anInt = anInt;
|
||||
|
||||
double _aDouble;
|
||||
double get aDouble => _$this._aDouble;
|
||||
set aDouble(double aDouble) => _$this._aDouble = aDouble;
|
||||
double? _aDouble;
|
||||
double? get aDouble => _$this._aDouble;
|
||||
set aDouble(double? aDouble) => _$this._aDouble = aDouble;
|
||||
|
||||
BuiltSimpleObjectBuilder _anObject;
|
||||
BuiltSimpleObjectBuilder? _anObject;
|
||||
BuiltSimpleObjectBuilder get anObject =>
|
||||
_$this._anObject ??= new BuiltSimpleObjectBuilder();
|
||||
set anObject(BuiltSimpleObjectBuilder anObject) =>
|
||||
set anObject(BuiltSimpleObjectBuilder? anObject) =>
|
||||
_$this._anObject = anObject;
|
||||
|
||||
ListBuilder<String> _aListOfStrings;
|
||||
ListBuilder<String>? _aListOfStrings;
|
||||
ListBuilder<String> get aListOfStrings =>
|
||||
_$this._aListOfStrings ??= new ListBuilder<String>();
|
||||
set aListOfStrings(ListBuilder<String> aListOfStrings) =>
|
||||
set aListOfStrings(ListBuilder<String>? aListOfStrings) =>
|
||||
_$this._aListOfStrings = aListOfStrings;
|
||||
|
||||
ListBuilder<int> _aListOfInts;
|
||||
ListBuilder<int>? _aListOfInts;
|
||||
ListBuilder<int> get aListOfInts =>
|
||||
_$this._aListOfInts ??= new ListBuilder<int>();
|
||||
set aListOfInts(ListBuilder<int> aListOfInts) =>
|
||||
set aListOfInts(ListBuilder<int>? aListOfInts) =>
|
||||
_$this._aListOfInts = aListOfInts;
|
||||
|
||||
ListBuilder<double> _aListOfDoubles;
|
||||
ListBuilder<double>? _aListOfDoubles;
|
||||
ListBuilder<double> get aListOfDoubles =>
|
||||
_$this._aListOfDoubles ??= new ListBuilder<double>();
|
||||
set aListOfDoubles(ListBuilder<double> aListOfDoubles) =>
|
||||
set aListOfDoubles(ListBuilder<double>? aListOfDoubles) =>
|
||||
_$this._aListOfDoubles = aListOfDoubles;
|
||||
|
||||
ListBuilder<BuiltSimpleObject> _aListOfObjects;
|
||||
ListBuilder<BuiltSimpleObject>? _aListOfObjects;
|
||||
ListBuilder<BuiltSimpleObject> get aListOfObjects =>
|
||||
_$this._aListOfObjects ??= new ListBuilder<BuiltSimpleObject>();
|
||||
set aListOfObjects(ListBuilder<BuiltSimpleObject> aListOfObjects) =>
|
||||
set aListOfObjects(ListBuilder<BuiltSimpleObject>? aListOfObjects) =>
|
||||
_$this._aListOfObjects = aListOfObjects;
|
||||
|
||||
BuiltComplexObjectBuilder();
|
||||
|
||||
BuiltComplexObjectBuilder get _$this {
|
||||
if (_$v != null) {
|
||||
_aString = _$v.aString;
|
||||
_anInt = _$v.anInt;
|
||||
_aDouble = _$v.aDouble;
|
||||
_anObject = _$v.anObject?.toBuilder();
|
||||
_aListOfStrings = _$v.aListOfStrings?.toBuilder();
|
||||
_aListOfInts = _$v.aListOfInts?.toBuilder();
|
||||
_aListOfDoubles = _$v.aListOfDoubles?.toBuilder();
|
||||
_aListOfObjects = _$v.aListOfObjects?.toBuilder();
|
||||
final $v = _$v;
|
||||
if ($v != null) {
|
||||
_aString = $v.aString;
|
||||
_anInt = $v.anInt;
|
||||
_aDouble = $v.aDouble;
|
||||
_anObject = $v.anObject?.toBuilder();
|
||||
_aListOfStrings = $v.aListOfStrings?.toBuilder();
|
||||
_aListOfInts = $v.aListOfInts?.toBuilder();
|
||||
_aListOfDoubles = $v.aListOfDoubles?.toBuilder();
|
||||
_aListOfObjects = $v.aListOfObjects?.toBuilder();
|
||||
_$v = null;
|
||||
}
|
||||
return this;
|
||||
@@ -287,14 +296,12 @@ class BuiltComplexObjectBuilder
|
||||
|
||||
@override
|
||||
void replace(BuiltComplexObject other) {
|
||||
if (other == null) {
|
||||
throw new ArgumentError.notNull('other');
|
||||
}
|
||||
ArgumentError.checkNotNull(other, 'other');
|
||||
_$v = other as _$BuiltComplexObject;
|
||||
}
|
||||
|
||||
@override
|
||||
void update(void Function(BuiltComplexObjectBuilder) updates) {
|
||||
void update(void Function(BuiltComplexObjectBuilder)? updates) {
|
||||
if (updates != null) updates(this);
|
||||
}
|
||||
|
||||
@@ -313,7 +320,7 @@ class BuiltComplexObjectBuilder
|
||||
aListOfDoubles: _aListOfDoubles?.build(),
|
||||
aListOfObjects: _aListOfObjects?.build());
|
||||
} catch (_) {
|
||||
String _$failedField;
|
||||
late String _$failedField;
|
||||
try {
|
||||
_$failedField = 'anObject';
|
||||
_anObject?.build();
|
||||
|
||||
@@ -13,23 +13,17 @@ abstract class BuiltSimpleObject
|
||||
static Serializer<BuiltSimpleObject> get serializer =>
|
||||
_$builtSimpleObjectSerializer;
|
||||
|
||||
@nullable
|
||||
String get aString;
|
||||
String? get aString;
|
||||
|
||||
@nullable
|
||||
int get anInt;
|
||||
int? get anInt;
|
||||
|
||||
@nullable
|
||||
double get aDouble;
|
||||
double? get aDouble;
|
||||
|
||||
@nullable
|
||||
BuiltList<String> get aListOfStrings;
|
||||
BuiltList<String>? get aListOfStrings;
|
||||
|
||||
@nullable
|
||||
BuiltList<int> get aListOfInts;
|
||||
BuiltList<int>? get aListOfInts;
|
||||
|
||||
@nullable
|
||||
BuiltList<double> get aListOfDoubles;
|
||||
BuiltList<double>? get aListOfDoubles;
|
||||
|
||||
BuiltSimpleObject._();
|
||||
|
||||
|
||||
@@ -20,42 +20,48 @@ class _$BuiltSimpleObjectSerializer
|
||||
Iterable<Object> serialize(Serializers serializers, BuiltSimpleObject object,
|
||||
{FullType specifiedType = FullType.unspecified}) {
|
||||
final result = <Object>[];
|
||||
if (object.aString != null) {
|
||||
Object? value;
|
||||
value = object.aString;
|
||||
if (value != null) {
|
||||
result
|
||||
..add('aString')
|
||||
..add(serializers.serialize(object.aString,
|
||||
..add(serializers.serialize(value,
|
||||
specifiedType: const FullType(String)));
|
||||
}
|
||||
if (object.anInt != null) {
|
||||
value = object.anInt;
|
||||
if (value != null) {
|
||||
result
|
||||
..add('anInt')
|
||||
..add(serializers.serialize(object.anInt,
|
||||
specifiedType: const FullType(int)));
|
||||
..add(serializers.serialize(value, specifiedType: const FullType(int)));
|
||||
}
|
||||
if (object.aDouble != null) {
|
||||
value = object.aDouble;
|
||||
if (value != null) {
|
||||
result
|
||||
..add('aDouble')
|
||||
..add(serializers.serialize(object.aDouble,
|
||||
..add(serializers.serialize(value,
|
||||
specifiedType: const FullType(double)));
|
||||
}
|
||||
if (object.aListOfStrings != null) {
|
||||
value = object.aListOfStrings;
|
||||
if (value != null) {
|
||||
result
|
||||
..add('aListOfStrings')
|
||||
..add(serializers.serialize(object.aListOfStrings,
|
||||
..add(serializers.serialize(value,
|
||||
specifiedType:
|
||||
const FullType(BuiltList, const [const FullType(String)])));
|
||||
}
|
||||
if (object.aListOfInts != null) {
|
||||
value = object.aListOfInts;
|
||||
if (value != null) {
|
||||
result
|
||||
..add('aListOfInts')
|
||||
..add(serializers.serialize(object.aListOfInts,
|
||||
..add(serializers.serialize(value,
|
||||
specifiedType:
|
||||
const FullType(BuiltList, const [const FullType(int)])));
|
||||
}
|
||||
if (object.aListOfDoubles != null) {
|
||||
value = object.aListOfDoubles;
|
||||
if (value != null) {
|
||||
result
|
||||
..add('aListOfDoubles')
|
||||
..add(serializers.serialize(object.aListOfDoubles,
|
||||
..add(serializers.serialize(value,
|
||||
specifiedType:
|
||||
const FullType(BuiltList, const [const FullType(double)])));
|
||||
}
|
||||
@@ -72,7 +78,7 @@ class _$BuiltSimpleObjectSerializer
|
||||
while (iterator.moveNext()) {
|
||||
final key = iterator.current as String;
|
||||
iterator.moveNext();
|
||||
final dynamic value = iterator.current;
|
||||
final Object value = iterator.current;
|
||||
switch (key) {
|
||||
case 'aString':
|
||||
result.aString = serializers.deserialize(value,
|
||||
@@ -113,20 +119,20 @@ class _$BuiltSimpleObjectSerializer
|
||||
|
||||
class _$BuiltSimpleObject extends BuiltSimpleObject {
|
||||
@override
|
||||
final String aString;
|
||||
final String? aString;
|
||||
@override
|
||||
final int anInt;
|
||||
final int? anInt;
|
||||
@override
|
||||
final double aDouble;
|
||||
final double? aDouble;
|
||||
@override
|
||||
final BuiltList<String> aListOfStrings;
|
||||
final BuiltList<String>? aListOfStrings;
|
||||
@override
|
||||
final BuiltList<int> aListOfInts;
|
||||
final BuiltList<int>? aListOfInts;
|
||||
@override
|
||||
final BuiltList<double> aListOfDoubles;
|
||||
final BuiltList<double>? aListOfDoubles;
|
||||
|
||||
factory _$BuiltSimpleObject(
|
||||
[void Function(BuiltSimpleObjectBuilder) updates]) =>
|
||||
[void Function(BuiltSimpleObjectBuilder)? updates]) =>
|
||||
(new BuiltSimpleObjectBuilder()..update(updates)).build();
|
||||
|
||||
_$BuiltSimpleObject._(
|
||||
@@ -185,48 +191,49 @@ class _$BuiltSimpleObject extends BuiltSimpleObject {
|
||||
|
||||
class BuiltSimpleObjectBuilder
|
||||
implements Builder<BuiltSimpleObject, BuiltSimpleObjectBuilder> {
|
||||
_$BuiltSimpleObject _$v;
|
||||
_$BuiltSimpleObject? _$v;
|
||||
|
||||
String _aString;
|
||||
String get aString => _$this._aString;
|
||||
set aString(String aString) => _$this._aString = aString;
|
||||
String? _aString;
|
||||
String? get aString => _$this._aString;
|
||||
set aString(String? aString) => _$this._aString = aString;
|
||||
|
||||
int _anInt;
|
||||
int get anInt => _$this._anInt;
|
||||
set anInt(int anInt) => _$this._anInt = anInt;
|
||||
int? _anInt;
|
||||
int? get anInt => _$this._anInt;
|
||||
set anInt(int? anInt) => _$this._anInt = anInt;
|
||||
|
||||
double _aDouble;
|
||||
double get aDouble => _$this._aDouble;
|
||||
set aDouble(double aDouble) => _$this._aDouble = aDouble;
|
||||
double? _aDouble;
|
||||
double? get aDouble => _$this._aDouble;
|
||||
set aDouble(double? aDouble) => _$this._aDouble = aDouble;
|
||||
|
||||
ListBuilder<String> _aListOfStrings;
|
||||
ListBuilder<String>? _aListOfStrings;
|
||||
ListBuilder<String> get aListOfStrings =>
|
||||
_$this._aListOfStrings ??= new ListBuilder<String>();
|
||||
set aListOfStrings(ListBuilder<String> aListOfStrings) =>
|
||||
set aListOfStrings(ListBuilder<String>? aListOfStrings) =>
|
||||
_$this._aListOfStrings = aListOfStrings;
|
||||
|
||||
ListBuilder<int> _aListOfInts;
|
||||
ListBuilder<int>? _aListOfInts;
|
||||
ListBuilder<int> get aListOfInts =>
|
||||
_$this._aListOfInts ??= new ListBuilder<int>();
|
||||
set aListOfInts(ListBuilder<int> aListOfInts) =>
|
||||
set aListOfInts(ListBuilder<int>? aListOfInts) =>
|
||||
_$this._aListOfInts = aListOfInts;
|
||||
|
||||
ListBuilder<double> _aListOfDoubles;
|
||||
ListBuilder<double>? _aListOfDoubles;
|
||||
ListBuilder<double> get aListOfDoubles =>
|
||||
_$this._aListOfDoubles ??= new ListBuilder<double>();
|
||||
set aListOfDoubles(ListBuilder<double> aListOfDoubles) =>
|
||||
set aListOfDoubles(ListBuilder<double>? aListOfDoubles) =>
|
||||
_$this._aListOfDoubles = aListOfDoubles;
|
||||
|
||||
BuiltSimpleObjectBuilder();
|
||||
|
||||
BuiltSimpleObjectBuilder get _$this {
|
||||
if (_$v != null) {
|
||||
_aString = _$v.aString;
|
||||
_anInt = _$v.anInt;
|
||||
_aDouble = _$v.aDouble;
|
||||
_aListOfStrings = _$v.aListOfStrings?.toBuilder();
|
||||
_aListOfInts = _$v.aListOfInts?.toBuilder();
|
||||
_aListOfDoubles = _$v.aListOfDoubles?.toBuilder();
|
||||
final $v = _$v;
|
||||
if ($v != null) {
|
||||
_aString = $v.aString;
|
||||
_anInt = $v.anInt;
|
||||
_aDouble = $v.aDouble;
|
||||
_aListOfStrings = $v.aListOfStrings?.toBuilder();
|
||||
_aListOfInts = $v.aListOfInts?.toBuilder();
|
||||
_aListOfDoubles = $v.aListOfDoubles?.toBuilder();
|
||||
_$v = null;
|
||||
}
|
||||
return this;
|
||||
@@ -234,14 +241,12 @@ class BuiltSimpleObjectBuilder
|
||||
|
||||
@override
|
||||
void replace(BuiltSimpleObject other) {
|
||||
if (other == null) {
|
||||
throw new ArgumentError.notNull('other');
|
||||
}
|
||||
ArgumentError.checkNotNull(other, 'other');
|
||||
_$v = other as _$BuiltSimpleObject;
|
||||
}
|
||||
|
||||
@override
|
||||
void update(void Function(BuiltSimpleObjectBuilder) updates) {
|
||||
void update(void Function(BuiltSimpleObjectBuilder)? updates) {
|
||||
if (updates != null) updates(this);
|
||||
}
|
||||
|
||||
@@ -258,7 +263,7 @@ class BuiltSimpleObjectBuilder
|
||||
aListOfInts: _aListOfInts?.build(),
|
||||
aListOfDoubles: _aListOfDoubles?.build());
|
||||
} catch (_) {
|
||||
String _$failedField;
|
||||
late String _$failedField;
|
||||
try {
|
||||
_$failedField = 'aListOfStrings';
|
||||
_aListOfStrings?.build();
|
||||
|
||||
@@ -16,22 +16,20 @@ class ConvertedComplexObject {
|
||||
this.aListOfObjects,
|
||||
});
|
||||
|
||||
final String aString;
|
||||
final int anInt;
|
||||
final double aDouble;
|
||||
final ConvertedSimpleObject anObject;
|
||||
final List<String> aListOfStrings;
|
||||
final List<int> aListOfInts;
|
||||
final List<double> aListOfDoubles;
|
||||
final List<ConvertedSimpleObject> aListOfObjects;
|
||||
final String? aString;
|
||||
final int? anInt;
|
||||
final double? aDouble;
|
||||
final ConvertedSimpleObject? anObject;
|
||||
final List<String>? aListOfStrings;
|
||||
final List<int>? aListOfInts;
|
||||
final List<double>? aListOfDoubles;
|
||||
final List<ConvertedSimpleObject>? aListOfObjects;
|
||||
|
||||
factory ConvertedComplexObject.fromJson(Map<String, dynamic> json) {
|
||||
if (json == null) return null;
|
||||
|
||||
return ConvertedComplexObject(
|
||||
aString: json['aString'] as String,
|
||||
anInt: json['anInt'] as int,
|
||||
aDouble: json['aDouble'] as double,
|
||||
aString: json['aString'] as String?,
|
||||
anInt: json['anInt'] as int?,
|
||||
aDouble: json['aDouble'] as double?,
|
||||
anObject: json['anObject'] != null
|
||||
? ConvertedSimpleObject.fromJson(
|
||||
json['anObject'] as Map<String, dynamic>)
|
||||
|
||||
@@ -12,20 +12,18 @@ class ConvertedSimpleObject {
|
||||
this.aListOfDoubles,
|
||||
});
|
||||
|
||||
final String aString;
|
||||
final int anInt;
|
||||
final double aDouble;
|
||||
final List<String> aListOfStrings;
|
||||
final List<int> aListOfInts;
|
||||
final List<double> aListOfDoubles;
|
||||
final String? aString;
|
||||
final int? anInt;
|
||||
final double? aDouble;
|
||||
final List<String>? aListOfStrings;
|
||||
final List<int>? aListOfInts;
|
||||
final List<double>? aListOfDoubles;
|
||||
|
||||
factory ConvertedSimpleObject.fromJson(Map<String, dynamic> json) {
|
||||
if (json == null) return null;
|
||||
|
||||
return ConvertedSimpleObject(
|
||||
aString: json['aString'] as String,
|
||||
anInt: json['anInt'] as int,
|
||||
aDouble: json['aDouble'] as double,
|
||||
aString: json['aString'] as String?,
|
||||
anInt: json['anInt'] as int?,
|
||||
aDouble: json['aDouble'] as double?,
|
||||
aListOfStrings: json['aListOfStrings'] != null
|
||||
? List<String>.from(json['aListOfStrings'] as Iterable<dynamic>)
|
||||
: null,
|
||||
|
||||
@@ -20,14 +20,14 @@ class SerializableComplexObject {
|
||||
this.aListOfObjects,
|
||||
});
|
||||
|
||||
final String aString;
|
||||
final int anInt;
|
||||
final double aDouble;
|
||||
final SerializableSimpleObject anObject;
|
||||
final List<String> aListOfStrings;
|
||||
final List<int> aListOfInts;
|
||||
final List<double> aListOfDoubles;
|
||||
final List<SerializableSimpleObject> aListOfObjects;
|
||||
final String? aString;
|
||||
final int? anInt;
|
||||
final double? aDouble;
|
||||
final SerializableSimpleObject? anObject;
|
||||
final List<String>? aListOfStrings;
|
||||
final List<int>? aListOfInts;
|
||||
final List<double>? aListOfDoubles;
|
||||
final List<SerializableSimpleObject>? aListOfObjects;
|
||||
|
||||
factory SerializableComplexObject.fromJson(Map<String, dynamic> json) =>
|
||||
_$SerializableComplexObjectFromJson(json);
|
||||
|
||||
@@ -9,24 +9,25 @@ part of 'serializable_complex_object.dart';
|
||||
SerializableComplexObject _$SerializableComplexObjectFromJson(
|
||||
Map<String, dynamic> json) {
|
||||
return SerializableComplexObject(
|
||||
aString: json['aString'] as String,
|
||||
anInt: json['anInt'] as int,
|
||||
aDouble: (json['aDouble'] as num)?.toDouble(),
|
||||
aString: json['aString'] as String?,
|
||||
anInt: json['anInt'] as int?,
|
||||
aDouble: (json['aDouble'] as num?)?.toDouble(),
|
||||
anObject: json['anObject'] == null
|
||||
? null
|
||||
: SerializableSimpleObject.fromJson(
|
||||
json['anObject'] as Map<String, dynamic>),
|
||||
aListOfStrings:
|
||||
(json['aListOfStrings'] as List)?.map((e) => e as String)?.toList(),
|
||||
aListOfInts: (json['aListOfInts'] as List)?.map((e) => e as int)?.toList(),
|
||||
aListOfDoubles: (json['aListOfDoubles'] as List)
|
||||
?.map((e) => (e as num)?.toDouble())
|
||||
?.toList(),
|
||||
aListOfObjects: (json['aListOfObjects'] as List)
|
||||
?.map((e) => e == null
|
||||
? null
|
||||
: SerializableSimpleObject.fromJson(e as Map<String, dynamic>))
|
||||
?.toList(),
|
||||
aListOfStrings: (json['aListOfStrings'] as List<dynamic>?)
|
||||
?.map((e) => e as String)
|
||||
.toList(),
|
||||
aListOfInts:
|
||||
(json['aListOfInts'] as List<dynamic>?)?.map((e) => e as int).toList(),
|
||||
aListOfDoubles: (json['aListOfDoubles'] as List<dynamic>?)
|
||||
?.map((e) => (e as num).toDouble())
|
||||
.toList(),
|
||||
aListOfObjects: (json['aListOfObjects'] as List<dynamic>?)
|
||||
?.map(
|
||||
(e) => SerializableSimpleObject.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -19,12 +19,12 @@ class SerializableSimpleObject {
|
||||
this.aListOfDoubles,
|
||||
});
|
||||
|
||||
final String aString;
|
||||
final int anInt;
|
||||
final double aDouble;
|
||||
final List<String> aListOfStrings;
|
||||
final List<int> aListOfInts;
|
||||
final List<double> aListOfDoubles;
|
||||
final String? aString;
|
||||
final int? anInt;
|
||||
final double? aDouble;
|
||||
final List<String>? aListOfStrings;
|
||||
final List<int>? aListOfInts;
|
||||
final List<double>? aListOfDoubles;
|
||||
|
||||
factory SerializableSimpleObject.fromJson(Map<String, dynamic> json) =>
|
||||
_$SerializableSimpleObjectFromJson(json);
|
||||
|
||||
@@ -9,15 +9,17 @@ part of 'serializable_simple_object.dart';
|
||||
SerializableSimpleObject _$SerializableSimpleObjectFromJson(
|
||||
Map<String, dynamic> json) {
|
||||
return SerializableSimpleObject(
|
||||
aString: json['aString'] as String,
|
||||
anInt: json['anInt'] as int,
|
||||
aDouble: (json['aDouble'] as num)?.toDouble(),
|
||||
aListOfStrings:
|
||||
(json['aListOfStrings'] as List)?.map((e) => e as String)?.toList(),
|
||||
aListOfInts: (json['aListOfInts'] as List)?.map((e) => e as int)?.toList(),
|
||||
aListOfDoubles: (json['aListOfDoubles'] as List)
|
||||
?.map((e) => (e as num)?.toDouble())
|
||||
?.toList(),
|
||||
aString: json['aString'] as String?,
|
||||
anInt: json['anInt'] as int?,
|
||||
aDouble: (json['aDouble'] as num?)?.toDouble(),
|
||||
aListOfStrings: (json['aListOfStrings'] as List<dynamic>?)
|
||||
?.map((e) => e as String)
|
||||
.toList(),
|
||||
aListOfInts:
|
||||
(json['aListOfInts'] as List<dynamic>?)?.map((e) => e as int).toList(),
|
||||
aListOfDoubles: (json['aListOfDoubles'] as List<dynamic>?)
|
||||
?.map((e) => (e as num).toDouble())
|
||||
.toList(),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ class MyApp extends StatelessWidget {
|
||||
}
|
||||
|
||||
class MyHomePage extends StatelessWidget {
|
||||
MyHomePage({Key key}) : super(key: key);
|
||||
MyHomePage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
@@ -39,7 +39,7 @@ class BasicsPage extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
final localTheme = Theme.of(context).textTheme;
|
||||
final boldStyle =
|
||||
localTheme.bodyText2.copyWith(fontWeight: FontWeight.w600);
|
||||
localTheme.bodyText2!.copyWith(fontWeight: FontWeight.w600);
|
||||
|
||||
final dynamicListOfInts = json.decode(JsonStrings.listOfInts) as List;
|
||||
final strongListOfInts = List<int>.from(dynamicListOfInts);
|
||||
@@ -134,7 +134,7 @@ class BasicsPage extends StatelessWidget {
|
||||
},
|
||||
children: createMapRows(
|
||||
strongMapOfDynamics,
|
||||
localTheme.bodyText2,
|
||||
localTheme.bodyText2!,
|
||||
boldStyle,
|
||||
),
|
||||
),
|
||||
@@ -275,7 +275,7 @@ class BuiltSimplePage extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
var objects = JsonStrings.simpleObjects.map(
|
||||
(jsonString) {
|
||||
final dynamic parsedJson = json.decode(jsonString);
|
||||
final parsedJson = json.decode(jsonString) as Object;
|
||||
return serializers.deserializeWith(
|
||||
BuiltSimpleObject.serializer, parsedJson);
|
||||
},
|
||||
@@ -297,7 +297,7 @@ class BuiltComplexPage extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
var objects = JsonStrings.complexObjects.map(
|
||||
(jsonString) {
|
||||
final dynamic parsedJson = json.decode(jsonString);
|
||||
final parsedJson = json.decode(jsonString) as Object;
|
||||
return serializers.deserializeWith(
|
||||
BuiltComplexObject.serializer, parsedJson);
|
||||
},
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
String prettyPrintList(Iterable iter) {
|
||||
String prettyPrintList(Iterable? iter) {
|
||||
if (iter == null) return 'NULL';
|
||||
|
||||
final buff = StringBuffer();
|
||||
|
||||
@@ -14,7 +14,7 @@ class SimpleObjectView extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
final localTheme = Theme.of(context).textTheme;
|
||||
final boldStyle =
|
||||
localTheme.bodyText2.copyWith(fontWeight: FontWeight.w600);
|
||||
localTheme.bodyText2!.copyWith(fontWeight: FontWeight.w600);
|
||||
|
||||
if (simpleObject == null) return Text('NULL', style: localTheme.bodyText2);
|
||||
|
||||
@@ -59,7 +59,7 @@ class SimpleObjectView extends StatelessWidget {
|
||||
Text('aListOfStrings:', style: boldStyle),
|
||||
Text(
|
||||
prettyPrintList(
|
||||
simpleObject.aListOfStrings as Iterable<dynamic>,
|
||||
simpleObject.aListOfStrings as Iterable<dynamic>?,
|
||||
),
|
||||
style: localTheme.bodyText2,
|
||||
),
|
||||
@@ -69,7 +69,7 @@ class SimpleObjectView extends StatelessWidget {
|
||||
children: [
|
||||
Text('aListOfInts:', style: boldStyle),
|
||||
Text(
|
||||
prettyPrintList(simpleObject.aListOfInts as Iterable<dynamic>),
|
||||
prettyPrintList(simpleObject.aListOfInts as Iterable<dynamic>?),
|
||||
style: localTheme.bodyText2,
|
||||
),
|
||||
],
|
||||
@@ -81,7 +81,8 @@ class SimpleObjectView extends StatelessWidget {
|
||||
child: Text('aListOfDoubles:', style: boldStyle),
|
||||
),
|
||||
Text(
|
||||
prettyPrintList(simpleObject.aListOfDoubles as Iterable<dynamic>),
|
||||
prettyPrintList(
|
||||
simpleObject.aListOfDoubles as Iterable<dynamic>?),
|
||||
style: localTheme.bodyText2,
|
||||
),
|
||||
],
|
||||
@@ -126,7 +127,7 @@ class ComplexObjectView extends StatelessWidget {
|
||||
|
||||
ComplexObjectView(dynamic obj) : complexObject = obj;
|
||||
|
||||
List<Widget> _generateSimpleObjectWidgets(Iterable<dynamic> simpleObjects) {
|
||||
List<Widget> _generateSimpleObjectWidgets(Iterable<dynamic>? simpleObjects) {
|
||||
if (simpleObjects == null) {
|
||||
return [
|
||||
const Padding(
|
||||
@@ -158,7 +159,7 @@ class ComplexObjectView extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
final localTheme = Theme.of(context).textTheme;
|
||||
final boldStyle =
|
||||
localTheme.bodyText2.copyWith(fontWeight: FontWeight.w600);
|
||||
localTheme.bodyText2!.copyWith(fontWeight: FontWeight.w600);
|
||||
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
@@ -216,7 +217,7 @@ class ComplexObjectView extends StatelessWidget {
|
||||
Text('aListOfStrings:', style: boldStyle),
|
||||
Text(
|
||||
prettyPrintList(
|
||||
complexObject.aListOfStrings as Iterable<dynamic>),
|
||||
complexObject.aListOfStrings as Iterable<dynamic>?),
|
||||
style: localTheme.bodyText2,
|
||||
),
|
||||
],
|
||||
@@ -226,7 +227,7 @@ class ComplexObjectView extends StatelessWidget {
|
||||
Text('aListOfInts:', style: boldStyle),
|
||||
Text(
|
||||
prettyPrintList(
|
||||
complexObject.aListOfInts as Iterable<dynamic>),
|
||||
complexObject.aListOfInts as Iterable<dynamic>?),
|
||||
style: localTheme.bodyText2,
|
||||
),
|
||||
],
|
||||
@@ -239,7 +240,7 @@ class ComplexObjectView extends StatelessWidget {
|
||||
),
|
||||
Text(
|
||||
prettyPrintList(
|
||||
complexObject.aListOfDoubles as Iterable<dynamic>),
|
||||
complexObject.aListOfDoubles as Iterable<dynamic>?),
|
||||
style: localTheme.bodyText2,
|
||||
),
|
||||
],
|
||||
@@ -257,7 +258,7 @@ class ComplexObjectView extends StatelessWidget {
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: _generateSimpleObjectWidgets(
|
||||
complexObject.aListOfObjects as Iterable<dynamic>),
|
||||
complexObject.aListOfObjects as Iterable<dynamic>?),
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user