Beginning to use different contexts
This commit is contained in:
@@ -38,6 +38,17 @@ class Landmark {
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'name': name,
|
||||
'location': location,
|
||||
'type': type.name,
|
||||
// 'description': description,
|
||||
// 'duration': duration.inMinutes,
|
||||
// 'visited': visited
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
25
frontend/lib/structs/trip.dart
Normal file
25
frontend/lib/structs/trip.dart
Normal file
@@ -0,0 +1,25 @@
|
||||
// Represents a collection of landmarks that represent a journey
|
||||
// Different instances of a Trip can be saved and loaded by the user
|
||||
|
||||
import 'package:fast_network_navigation/structs/landmark.dart';
|
||||
|
||||
class Trip {
|
||||
final String uuid;
|
||||
final String cityName;
|
||||
final List<Landmark> landmarks;
|
||||
|
||||
|
||||
Trip({required this.uuid, required this.cityName, required this.landmarks});
|
||||
|
||||
factory Trip.fromJson(Map<String, dynamic> json) {
|
||||
List<Landmark> landmarks = [];
|
||||
for (var landmark in json['landmarks']) {
|
||||
landmarks.add(Landmark.fromJson(landmark));
|
||||
}
|
||||
return Trip(
|
||||
uuid: json['uuid'],
|
||||
cityName: json['cityName'],
|
||||
landmarks: landmarks,
|
||||
);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user