40 lines
1.2 KiB
Dart
40 lines
1.2 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
import '../Widgets/reading_graph.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) {
|
|
if (snapshot.data!.isEmpty) {
|
|
return Text('No readings on record.');
|
|
}
|
|
return Center(
|
|
child: Padding(
|
|
padding: const EdgeInsets.fromLTRB(20, 0, 20, 20),
|
|
child: ReadingGraph(
|
|
readings: snapshot.data!,
|
|
),
|
|
),
|
|
);
|
|
} else {
|
|
return Placeholder();
|
|
}
|
|
}),
|
|
);
|
|
}
|
|
}
|