mobile_nebula/lib/models/StaticHosts.dart

24 lines
586 B
Dart
Raw Normal View History

2020-07-27 20:43:58 +00:00
import 'IPAndPort.dart';
class StaticHost {
bool lighthouse;
List<IPAndPort> destinations;
StaticHost({required this.lighthouse, required this.destinations});
2020-07-27 20:43:58 +00:00
factory StaticHost.fromJson(Map<String, dynamic> json) {
2020-07-27 20:43:58 +00:00
var list = json['destinations'] as List<dynamic>;
2021-04-23 17:33:28 +00:00
var result = <IPAndPort>[];
2020-07-27 20:43:58 +00:00
list.forEach((item) {
result.add(IPAndPort.fromString(item));
});
return StaticHost(lighthouse: json['lighthouse'], destinations: result);
2020-07-27 20:43:58 +00:00
}
Map<String, dynamic> toJson() {
return {'lighthouse': lighthouse, 'destinations': destinations};
2020-07-27 20:43:58 +00:00
}
}