Created
August 1, 2018 17:31
-
-
Save RedBrogdon/19f1ca02d310586499b9ef85744ea406 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SimpleObject { | |
const SimpleObject({ | |
this.aString, | |
this.anInt, | |
this.aDouble, | |
this.aListOfStrings, | |
this.aListOfInts, | |
this.aListOfDoubles, | |
}); | |
final String aString; | |
final int anInt; | |
final double aDouble; | |
final List<String> aListOfStrings; | |
final List<int> aListOfInts; | |
final List<double> aListOfDoubles; | |
factory SimpleObject.fromJson(Map<String, dynamic> json) { | |
if (json == null) { | |
throw FormatException("Null JSON provided to SimpleObject"); | |
} | |
return SimpleObject( | |
aString: json['aString'], | |
anInt: json['anInt'], | |
aDouble: json['aDouble'], | |
aListOfStrings: json['aListOfStrings'] != null | |
? List<String>.from(json['aListOfStrings']) | |
: null, | |
aListOfInts: json['aListOfInts'] != null | |
? List<int>.from(json['aListOfInts']) | |
: null, | |
aListOfDoubles: json['aListOfDoubles'] != null | |
? List<double>.from(json['aListOfDoubles']) | |
: null, | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment