Implemented loading indicator for mapview
This commit is contained in:
@@ -22,14 +22,28 @@ class MapPage extends StatefulWidget {
|
||||
class _MapPageState extends State<MapPage> {
|
||||
final _mapController = MapController();
|
||||
late FloodStationProvider _floodStationProvider;
|
||||
bool _loading = false;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
_floodStationProvider = context.watch<FloodStationProvider>();
|
||||
if (_floodStationProvider.allStations.isEmpty) {
|
||||
if (_loading == true) {
|
||||
return Center(
|
||||
child: CircularProgressIndicator(),
|
||||
);
|
||||
} else if (_floodStationProvider.allStations.isEmpty) {
|
||||
return Center(
|
||||
child: ElevatedButton(
|
||||
onPressed: _floodStationProvider.loadAllStations,
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
_loading = true;
|
||||
});
|
||||
_floodStationProvider
|
||||
.loadAllStations()
|
||||
.whenComplete(() => setState(() {
|
||||
_loading = false;
|
||||
}));
|
||||
},
|
||||
child: Text('Load Map'),
|
||||
),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user