simple detail view of flood station and readings
This commit is contained in:
36
lib/pages/flood_station_page.dart
Normal file
36
lib/pages/flood_station_page.dart
Normal file
@@ -0,0 +1,36 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../model/flood_station.dart';
|
||||
import '../model/reading.dart';
|
||||
import '../services/api.dart';
|
||||
|
||||
class FloodStationPage extends StatelessWidget {
|
||||
const FloodStationPage({super.key, required FloodStation floodStation})
|
||||
: _floodStation = floodStation;
|
||||
final FloodStation _floodStation;
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(_floodStation.label),
|
||||
),
|
||||
body: FutureBuilder<List<Reading>>(
|
||||
future: Api.fetchReadingsFromStation(_floodStation.id),
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.hasData) {
|
||||
return ListView.builder(
|
||||
itemBuilder: (context, index) {
|
||||
return ListTile(
|
||||
title:
|
||||
Text(snapshot.data!.elementAt(index).value.toString()),
|
||||
);
|
||||
},
|
||||
itemCount: snapshot.data!.length,
|
||||
);
|
||||
} else {
|
||||
return Placeholder();
|
||||
}
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user