From ab19027b3ea49fa6a8b3d704aa50a8a3ca4a689a Mon Sep 17 00:00:00 2001 From: Kevin Worth Date: Fri, 8 May 2020 08:58:03 -0400 Subject: [PATCH] Display total number of players Setting up a new widget to display the list of players, but for the time being (for simplicity's sake) it's just displaying the size of the returned list of players. --- flutterempires/lib/main.dart | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/flutterempires/lib/main.dart b/flutterempires/lib/main.dart index e313be1..0d57404 100644 --- a/flutterempires/lib/main.dart +++ b/flutterempires/lib/main.dart @@ -54,11 +54,13 @@ class _MyHomePageState extends State { int _counter = 0; Future futurePlayer; + Future> allPlayers; @override void initState() { super.initState(); futurePlayer = Player.fetchFirstPlayer(); + allPlayers = Player.fetchAllPlayers(); } void _incrementCounter() { @@ -122,6 +124,18 @@ class _MyHomePageState extends State { } else if (snapshot.hasError) { return Text("${snapshot.error}"); } + return CircularProgressIndicator(); + }, + ), + Spacer(flex: 1), + FutureBuilder>( + future: allPlayers, + builder: (context, snapshot) { + if (snapshot.hasData) { + return Text(snapshot.data.length.toString()); + } else if (snapshot.hasError) { + return Text("${snapshot.error}"); + } // By default, show a loading spinner. return CircularProgressIndicator(); }, -- 2.43.0