import 'dart:convert'; import 'dart:async'; import 'package:http/http.dart' as http; import 'package:witl/arrival.dart'; Future> fetchArrivals() async { try { final response = await http.get(Uri.parse('http://141.144.238.26:48502/arrivals/all')); if (response.statusCode == 200) { // List data = jsonDecode(response.body); // List arrivals = List.from(data.map((dynamic arrivalJson) { // return Arrival.fromJson(arrivalJson); // })); Iterable I = json.decode(response.body); List arrivals = List.from(I.map((model)=>Arrival.fromJson(model))); return arrivals; } else { throw Exception('Failed to load Arrival'); } } catch (error) { throw Exception('Failed to fetch data: $error'); } }