setFromJson method
Convert and set any json to T
It doesn't crash if passed incorrect data type value
If it fails to put value it returns false
Implementation
@override
bool setFromJson(json) {
_loaded = false;
int? ms;
if (json is DateTime) set(json);
if (json is int) ms = json;
if (json is double) ms = json.toInt();
if (ms != null) {
final datetime = DateTime.fromMillisecondsSinceEpoch(ms);
set(datetime);
} else if (json is String) {
final datetime = DateTime.tryParse(json);
if (datetime != null) set(datetime);
}
return isLoaded;
}