Fixed bug - Loading Indicator now functions correctly

This commit is contained in:
2025-01-27 21:08:41 +01:00
parent 13bd344807
commit 36dec2d0de
5 changed files with 106 additions and 29 deletions

View File

@@ -21,6 +21,20 @@ class Api {
return stations;
}
/// Fetches all stations whose label contain [label]
static Future<List<FloodStation>> fetchFilteredStations(String label) async {
List<FloodStation> stations = [];
final response =
await http.get(Uri.parse('$_rootUrl/id/stations?search=$label'));
if (response.statusCode == 200) {
final Map<String, dynamic> jsonStr = jsonDecode(response.body);
for (final str in jsonStr['items']) {
stations.add(FloodStation.fromMap(str));
}
}
return stations;
}
/// [limit] limits the number of entries that are requested from the API and [offset] returns the
/// list starting from the specified number