Ajout parsing route

This commit is contained in:
Gabriel
2023-06-05 11:24:15 +02:00
parent 77451787f5
commit 314874a142
2 changed files with 42 additions and 3 deletions

View File

@@ -17,19 +17,58 @@ class Registration {
}
}
class Coordinates {
String? symbol;
String? type;
String? systemSymbol;
int? x;
int? y;
Coordinates({this.symbol, this.type, this.systemSymbol, this.x, this.y });
factory Coordinates.fromJson(Map<String, dynamic> json) {
return Coordinates(
symbol: json['symbol'],
type: json['type'],
systemSymbol: json['systemSymbol'],
x: json['x'],
y: json['y'],
);
}
}
class Route {
Coordinates? departure;
Coordinates? destination;
String? arrival;
String? departureTime;
Route({this.departure, this.destination, this.arrival, this.departureTime});
factory Route.fromJson(Map<String, dynamic> json) {
return Route(
departure: Coordinates.fromJson(json['departure']),
destination: Coordinates.fromJson(json['destination']),
arrival: json['arrival'],
departureTime: json['departureTime'],
);
}
}
class Nav {
String? systemSymbol;
String? waypointSymbol;
//TODO Route
Route? route;
String? status;
String? flightMode;
Nav({this.systemSymbol, this.waypointSymbol, this.status, this.flightMode});
Nav({this.systemSymbol, this.waypointSymbol, this.route, this.status, this.flightMode});
factory Nav.fromJson(Map<String, dynamic> json) {
return Nav(
systemSymbol: json['systemSymbol'],
waypointSymbol: json['waypointSymbol'],
route: Route.fromJson(json['route']),
status: json['status'],
flightMode: json['flightMode'],
);

View File

@@ -90,7 +90,7 @@ class ShipPage extends StatelessWidget {
Column(
children:[
Text('${ship.nav?.waypointSymbol ?? 'N/A'}'),
Text('Asteroid Field'),
Text('${ship.nav?.route?.destination?.type ?? 'N/A'}'),
],
),
SizedBox(height: 32),