27 lines
817 B
Dart
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();
|
|
}
|
|
}
|
|
);
|
|
} |