simple detail view of flood station and readings

This commit is contained in:
2025-01-24 23:47:46 +01:00
parent 08c266bc95
commit dfb9b59560
4 changed files with 68 additions and 0 deletions

View 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();
}
}),
);
}
}