Added comments and refactored code
This commit is contained in:
@@ -15,6 +15,7 @@ class LandingPage extends StatefulWidget {
|
|||||||
State<LandingPage> createState() => _LandingPageState();
|
State<LandingPage> createState() => _LandingPageState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// uses mixin OverlayService to show loading overlay
|
||||||
class _LandingPageState extends State<LandingPage> with OverlayService {
|
class _LandingPageState extends State<LandingPage> with OverlayService {
|
||||||
late FloodStationProvider floodStationProvider;
|
late FloodStationProvider floodStationProvider;
|
||||||
|
|
||||||
@@ -37,8 +38,10 @@ class _LandingPageState extends State<LandingPage> with OverlayService {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if the list of all Stations is empty the method returns a button to load them
|
||||||
|
// else returns a list of FloodStations
|
||||||
Widget _buildStationList() {
|
Widget _buildStationList() {
|
||||||
if (!_shouldShowList()) {
|
if (!_shouldShowList) {
|
||||||
return Expanded(
|
return Expanded(
|
||||||
child: Center(
|
child: Center(
|
||||||
child: ElevatedButton(
|
child: ElevatedButton(
|
||||||
@@ -99,7 +102,9 @@ class _LandingPageState extends State<LandingPage> with OverlayService {
|
|||||||
Navigator.of(context).pushNamed(FloodStationPage.routeName);
|
Navigator.of(context).pushNamed(FloodStationPage.routeName);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool _shouldShowList() {
|
// returns boolean to decide whether the list of stations should be shown
|
||||||
|
// if the list of stations is empty and is not filtered either, the function returns false
|
||||||
|
bool get _shouldShowList {
|
||||||
if (!floodStationProvider.filtered &&
|
if (!floodStationProvider.filtered &&
|
||||||
floodStationProvider.allStations.isNotEmpty) {
|
floodStationProvider.allStations.isNotEmpty) {
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Reference in New Issue
Block a user