anyway/frontend/lib/utils/get_first_page.dart
Remy Moll 3f1fe463bf
All checks were successful
Build and deploy the backend to staging / Build and push image (pull_request) Successful in 1m40s
Build and release debug APK / Build APK (pull_request) Successful in 7m23s
Build and deploy the backend to staging / Deploy to staging (pull_request) Successful in 14s
better help and onboarding
2024-11-18 17:42:52 +01:00

27 lines
817 B
Dart

import 'package:anyway/pages/current_trip.dart';
import 'package:anyway/pages/onboarding.dart';
import 'package:anyway/structs/trip.dart';
import 'package:anyway/utils/load_trips.dart';
import 'package:flutter/material.dart';
Widget getFirstPage() {
Future<List<Trip>> trips = loadTrips();
// test if there are any active trips
// if there are, return the trip list
// if there are not, return the onboarding page
return FutureBuilder(
future: trips,
builder: (context, snapshot) {
if (snapshot.hasData) {
List<Trip> availableTrips = snapshot.data!;
if (availableTrips.isNotEmpty) {
return TripPage(trip: availableTrips[0]);
} else {
return OnboardingPage();
}
} else {
return CircularProgressIndicator();
}
}
);
}