mobile_nebula/lib/models/CIDR.dart
Nate Brown dbe67c2f81
Upgrade to flutter 3 (#70)
Co-authored-by: John Maguire <contact@johnmaguire.me>
2022-09-21 15:27:35 -05:00

27 lines
418 B
Dart

class CIDR {
CIDR({this.ip = '', this.bits = 0});
String ip;
int bits;
@override
String toString() {
return '$ip/$bits';
}
String toJson() {
return toString();
}
factory CIDR.fromString(String val) {
final parts = val.split('/');
if (parts.length != 2) {
throw 'Invalid CIDR string';
}
return CIDR(
ip: parts[0],
bits: int.parse(parts[1]),
);
}
}