Fetch fetches, layout bettered
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
import 'package:http/http.dart' as http;
|
import 'package:http/http.dart' as http;
|
||||||
|
|
||||||
Future<Album> createAlbum(String title) async {
|
Future<Album> createAlbum(String title) async {
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:witl/album_fetch.dart';
|
import 'package:witl/arrival_fetch.dart';
|
||||||
|
|
||||||
class FetchAPI extends StatefulWidget {
|
class FetchAPI extends StatefulWidget {
|
||||||
const FetchAPI({super.key});
|
const FetchAPI({super.key});
|
||||||
@@ -17,8 +17,9 @@ class _FetchAPIState extends State<FetchAPI> {
|
|||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: const Text("Fetching API"),
|
title: const Text("Fetching API"),
|
||||||
),
|
),
|
||||||
body: Row(
|
body: Column(
|
||||||
children: <Widget>[
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
|
children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
child: FutureBuilder<List<Arrival>>(
|
child: FutureBuilder<List<Arrival>>(
|
||||||
@@ -33,7 +34,9 @@ class _FetchAPIState extends State<FetchAPI> {
|
|||||||
itemCount: snapshot.data!.length,
|
itemCount: snapshot.data!.length,
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
return ListTile(
|
return ListTile(
|
||||||
title: Text(snapshot.data![index].timeOfDay),
|
title: Text("Arrival Time: ${snapshot.data![index].timeOfDay}"),
|
||||||
|
titleAlignment: ListTileTitleAlignment.center,
|
||||||
|
subtitle: Text("Week Day: ${weekNumToString(snapshot.data![index].weekDay)}"),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@@ -42,6 +45,7 @@ class _FetchAPIState extends State<FetchAPI> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
const SizedBox(height: 30,),
|
||||||
InkWell(
|
InkWell(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
Navigator.pushNamedAndRemoveUntil(context, '/', (route) => false);
|
Navigator.pushNamedAndRemoveUntil(context, '/', (route) => false);
|
||||||
@@ -51,6 +55,7 @@ class _FetchAPIState extends State<FetchAPI> {
|
|||||||
child: const Text("Homescreen"),
|
child: const Text("Homescreen"),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
const SizedBox(height: 35,),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@@ -62,3 +67,24 @@ class _FetchAPIState extends State<FetchAPI> {
|
|||||||
fetchedArrivals = fetchArrivals();
|
fetchedArrivals = fetchArrivals();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String weekNumToString(int weekday) {
|
||||||
|
switch (weekday) {
|
||||||
|
case 1:
|
||||||
|
return "Monday";
|
||||||
|
case 2:
|
||||||
|
return "Tuesday";
|
||||||
|
case 3:
|
||||||
|
return "Wednesday";
|
||||||
|
case 4:
|
||||||
|
return "Thursday";
|
||||||
|
case 5:
|
||||||
|
return "Friday";
|
||||||
|
case 6:
|
||||||
|
return "Saturday";
|
||||||
|
case 7:
|
||||||
|
return "Sunday";
|
||||||
|
}
|
||||||
|
|
||||||
|
throw "AAAAAAAAA";
|
||||||
|
}
|
||||||
@@ -5,7 +5,7 @@ class InputData extends StatefulWidget {
|
|||||||
const InputData({super.key});
|
const InputData({super.key});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_InputDataState createState() => _InputDataState();
|
State<InputData> createState() => _InputDataState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _InputDataState extends State<InputData> {
|
class _InputDataState extends State<InputData> {
|
||||||
|
|||||||
Reference in New Issue
Block a user