simple view of town names
This commit is contained in:
38
lib/pages/landing_page.dart
Normal file
38
lib/pages/landing_page.dart
Normal file
@@ -0,0 +1,38 @@
|
||||
import 'package:flutter/material.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 ListView.builder(
|
||||
itemBuilder: (context, index) {
|
||||
return ListTile(
|
||||
title: Text(snapshot.data!.elementAt(index).town),
|
||||
);
|
||||
},
|
||||
itemCount: snapshot.data!.length,
|
||||
);
|
||||
} else {
|
||||
return Placeholder();
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
body: FutureBuilder<List<FloodStation>>(
|
||||
future: Api.fetchStations(),
|
||||
builder: builder,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user