XrayInt32Range.fromJson constructor
XrayInt32Range.fromJson(
- Object? json
Implementation
factory XrayInt32Range.fromJson(Object? json) {
if (json is int) {
return XrayInt32Range.single(json);
}
if (json is String) {
if (json.isEmpty) {
return XrayInt32Range.single(0);
}
final dash = json.indexOf('-', json.startsWith('-') ? 1 : 0);
if (dash < 0) {
return XrayInt32Range.single(int.parse(json));
}
return XrayInt32Range(
left: int.parse(json.substring(0, dash)),
right: int.parse(json.substring(dash + 1)),
);
}
throw FormatException('invalid integer range: $json');
}