Files
floodwatch/lib/pages/landing_page.dart

35 lines
890 B
Dart

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<List<FloodStation>> 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<List<FloodStation>>(
future: Api.fetchStations(),
builder: builder,
),
);
}
}