import 'package:flutter/material.dart'; import '../Widgets/flood_station_list_view.dart'; import '../model/flood_station.dart'; import '../services/api.dart'; class LandingPage extends StatelessWidget { const LandingPage({super.key}); static const routeName = '/'; Widget builder( BuildContext context, AsyncSnapshot> snapshot) { if (!snapshot.hasData) { return CircularProgressIndicator(); } else if (snapshot.hasData) { return FloodStationListView(stations: snapshot.data!); } else if (snapshot.hasError) { return Text(snapshot.error.toString()); } else { return Text('An unknown error occured.'); } } @override Widget build(BuildContext context) { return Scaffold( body: FutureBuilder>( future: Api.fetchStations(), builder: builder, ), ); } }