Skip to content

Instantly share code, notes, and snippets.

View bobjackman's full-sized avatar

Bob Jackman bobjackman

View GitHub Profile
@bobjackman
bobjackman / SomeClass.dart
Created February 4, 2020 20:10
Making fromMap Constructors Require Certain Fields
class SomeClass {
String id;
String foo;
String bar; // required
String zap; // required
SomeClass.fromMap(Map<String, dynamic> inputMap) {
this.id = inputMap['ID'];
this.foo = inputMap['Foo'];
this.bar = inputMap['Bar'];
@bobjackman
bobjackman / SomeClass.dart
Created February 4, 2020 20:15
Set value only if we don't already have one
class SomeClass {
String foobar;
void someMethod(String newValue) {
if (foobar == null) {
foobar = newValue;
}
}
// OR //