HomeView Mock-Daten entfernen #51
@@ -138,29 +138,40 @@ class _HomeViewState extends State<HomeView> {
|
||||
padding: const EdgeInsets.symmetric(horizontal: 40.0),
|
||||
child: FutureBuilder(
|
||||
future: _recentGamesFuture,
|
||||
builder: (context, snapshot) {
|
||||
builder:
|
||||
(
|
||||
BuildContext context,
|
||||
AsyncSnapshot<List<Game>> snapshot,
|
||||
) {
|
||||
if (snapshot.hasError) {
|
||||
return const Center(
|
||||
heightFactor: 4,
|
||||
child: Text('Error while loading recent games.'),
|
||||
child: Text(
|
||||
'Error while loading recent games.',
|
||||
),
|
||||
);
|
||||
}
|
||||
if (snapshot.connectionState ==
|
||||
ConnectionState.done &&
|
||||
(!snapshot.hasData || snapshot.data!.isEmpty)) {
|
||||
(!snapshot.hasData ||
|
||||
|
sneeex marked this conversation as resolved
Outdated
|
||||
snapshot.data!.isEmpty)) {
|
||||
return const Center(
|
||||
heightFactor: 4,
|
||||
child: Text('No recent games available.'),
|
||||
);
|
||||
}
|
||||
final List<Game> games =
|
||||
(isLoading ? skeletonData : (snapshot.data ?? [])
|
||||
(isLoading
|
||||
? skeletonData
|
||||
: (snapshot.data ?? [])
|
||||
..sort(
|
||||
(a, b) =>
|
||||
b.createdAt.compareTo(a.createdAt),
|
||||
(a, b) => b.createdAt.compareTo(
|
||||
a.createdAt,
|
||||
),
|
||||
))
|
||||
.take(2)
|
||||
.toList();
|
||||
if (games.length > 0)
|
||||
return Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
@@ -175,10 +186,12 @@ class _HomeViewState extends State<HomeView> {
|
||||
: games[0].winner!.name,
|
||||
),
|
||||
const Padding(
|
||||
|
sneeex marked this conversation as resolved
Outdated
flixcoo
commented
Lieber sowas wie Lieber sowas wie `Game in Progress` oder so
|
||||
padding: EdgeInsets.symmetric(vertical: 8.0),
|
||||
padding: EdgeInsets.symmetric(
|
||||
vertical: 8.0,
|
||||
),
|
||||
child: Divider(),
|
||||
),
|
||||
if (games.length >= 2) ...[
|
||||
if (games.length > 1) ...[
|
||||
GameTile(
|
||||
gameTitle: games[1].name,
|
||||
gameType: 'Winner',
|
||||
@@ -192,11 +205,18 @@ class _HomeViewState extends State<HomeView> {
|
||||
] else ...[
|
||||
const Center(
|
||||
heightFactor: 4,
|
||||
child: Text('No second game available.'),
|
||||
child: Text(
|
||||
'No second game available.',
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
);
|
||||
else
|
||||
return const Center(
|
||||
heightFactor: 4,
|
||||
child: Text('No recent games available.'),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user
Fehler taucht auf, wenn man die App startet. Könnte an dieser Zeile liegen. Ggf. die Skeleton Daten in der gleichen Variable wie die reelen Daten speichern und dann überhscreiben, wenn diese geladen sind