37 lines
1.1 KiB
Dart
37 lines
1.1 KiB
Dart
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();
|
|
}
|
|
}),
|
|
);
|
|
}
|
|
}
|