-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(model): extract shorter JSON field names
- Loading branch information
1 parent
6cb11f7
commit ae0689d
Showing
9 changed files
with
146 additions
and
79 deletions.
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
abstract class _JsonFields { | ||
static const brand = 'b'; | ||
static const model = 'm'; | ||
static const isElectronic = 'ie'; | ||
} | ||
|
||
class Piano { | ||
String? brand; | ||
String? model; | ||
bool isElectronic; | ||
|
||
Piano({ | ||
this.brand, | ||
this.model, | ||
this.isElectronic = false, | ||
}); | ||
|
||
Piano.from(Map<String, dynamic> other) | ||
: brand = other[_JsonFields.brand] as String?, | ||
model = other[_JsonFields.model] as String?, | ||
isElectronic = other[_JsonFields.isElectronic] as bool; | ||
|
||
Map<String, dynamic> toJson() => { | ||
_JsonFields.brand: brand, | ||
_JsonFields.model: model, | ||
_JsonFields.isElectronic: isElectronic, | ||
}; | ||
} |
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
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
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
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
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