WorldStorm.fromJson constructor
WorldStorm.fromJson(
- Map<String, dynamic> json
)
Implementation
factory WorldStorm.fromJson(Map<String, dynamic> json) {
final name = json['name'] as String? ?? '';
final kind = json['kind'] as String? ?? '';
final touchpoint = json['touchpoint'] as String? ?? '';
if (name.isEmpty || touchpoint.isEmpty) {
throw const WorldManifestError(
'storm without a name/touchpoint --> fix: every storms[] entry '
'needs "name", "kind", and "touchpoint".',
);
}
final fromCall = (json['fromCall'] as num?)?.toInt() ?? 1;
var toCall = (json['toCall'] as num?)?.toInt() ?? fromCall;
if (toCall < fromCall) toCall = fromCall;
return WorldStorm(
name: name,
kind: kind,
touchpoint: touchpoint,
method: json['method'] as String?,
fromCall: fromCall,
toCall: toCall,
failure: Map<String, dynamic>.from(
json['failure'] as Map? ?? const <String, dynamic>{},
),
description: json['description'] as String? ?? '',
);
}