diff --git a/lib/fetcher.dart b/lib/fetcher.dart index 638b017..3f447f8 100644 --- a/lib/fetcher.dart +++ b/lib/fetcher.dart @@ -23,31 +23,34 @@ class _FetchAPIState extends State { appBar: AppBar( title: const Text("Fetching API"), ), - body: ListView( - children: [ - FutureBuilder>( - future: fetchedArrivals, - builder: (context, snapshot) { - if (snapshot.connectionState == ConnectionState.waiting) { - return const CircularProgressIndicator(); - } else if (snapshot.hasError) { - return Text('Failed to fetch data.\nError: ${snapshot.error}'); - } else { - return ListView.builder( - itemCount: snapshot.data!.length, - itemBuilder: (context, index) { - return ListTile( - title: Text(snapshot.data![index].timeOfDay), + body: Row( + children: [ + Expanded( + child: SizedBox( + child: FutureBuilder>( + future: fetchedArrivals, + builder: (context, snapshot) { + if (snapshot.connectionState == ConnectionState.waiting) { + return const CircularProgressIndicator(); + } else if (snapshot.hasError) { + return Text('Failed to fetch data.\nError: ${snapshot.error}'); + } else { + return ListView.builder( + itemCount: snapshot.data!.length, + itemBuilder: (context, index) { + return ListTile( + title: Text(snapshot.data![index].timeOfDay), + ); + }, ); - }, - ); - } - }, + } + }, + ), + ), ), InkWell( onTap: () { - Navigator.pushNamedAndRemoveUntil( - context, '/', (route) => false); + Navigator.pushNamedAndRemoveUntil(context, '/', (route) => false); }, child: Container( padding: const EdgeInsets.all(20.0), @@ -58,4 +61,10 @@ class _FetchAPIState extends State { ), ); } + + @override + void initState() { + super.initState(); + fetchedArrivals = fetchArrivals(); + } }