Fetching but Type Conversion Err

This commit is contained in:
2023-12-26 19:23:43 +02:00
parent 3dcb8215f2
commit 70895a74c5
3 changed files with 80 additions and 1 deletions

View File

@@ -1,8 +1,22 @@
import 'package:flutter/material.dart';
import 'package:witl/album_fetch.dart';
class FetchAPI extends StatelessWidget {
class FetchAPI extends StatefulWidget {
const FetchAPI({super.key});
@override
State<FetchAPI> createState() => _FetchAPIState();
}
class _FetchAPIState extends State<FetchAPI> {
late Future<FetchAlbum> fetchedAlbum;
@override
void initState() {
super.initState();
fetchedAlbum = fetchArrivals();
}
@override
Widget build(BuildContext context) {
return Scaffold(
@@ -11,6 +25,18 @@ class FetchAPI extends StatelessWidget {
),
body: ListView(
children: [
FutureBuilder<FetchAlbum> (
future: fetchedAlbum,
builder: (context, snapshot) {
if (snapshot.hasData) {
return Text(snapshot.data!.timeOfDay);
} else if (snapshot.hasError) {
return Text('${snapshot.error}');
}
return const CircularProgressIndicator();
},
),
InkWell(
onTap: () {
Navigator.pushNamedAndRemoveUntil(