working save and load functionality with custom datastructures
This commit is contained in:
@@ -12,7 +12,7 @@ import 'package:fast_network_navigation/pages/profile.dart';
|
||||
// A side drawer is used to switch between pages
|
||||
class BasePage extends StatefulWidget {
|
||||
final String mainScreen;
|
||||
final Trip? trip;
|
||||
final Future<Trip>? trip;
|
||||
|
||||
const BasePage({
|
||||
super.key,
|
||||
@@ -30,11 +30,10 @@ class _BasePageState extends State<BasePage> {
|
||||
Widget build(BuildContext context) {
|
||||
Widget currentView = const Text("loading...");
|
||||
Future<List<Trip>> trips = loadTrips();
|
||||
Future<Trip> firstTrip = getFirstTrip(trips);
|
||||
// Future<Trip> trip = Future(trips[0]);
|
||||
|
||||
|
||||
if (widget.mainScreen == "map") {
|
||||
currentView = NavigationOverview(trip: firstTrip);
|
||||
currentView = NavigationOverview(trip: widget.trip ?? getFirstTrip(trips));
|
||||
} else if (widget.mainScreen == "tutorial") {
|
||||
currentView = TutorialPage();
|
||||
} else if (widget.mainScreen == "profile") {
|
||||
@@ -88,12 +87,8 @@ class _BasePageState extends State<BasePage> {
|
||||
child: TripsOverview(trips: trips),
|
||||
),
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
Navigator.of(context).push(
|
||||
MaterialPageRoute(
|
||||
builder: (context) => const NewTripPage()
|
||||
)
|
||||
);
|
||||
onPressed: () async {
|
||||
removeAllTripsFromPrefs();
|
||||
},
|
||||
child: const Text('Clear trips'),
|
||||
),
|
||||
|
Reference in New Issue
Block a user