Get rid of extra FutureBuilder widgets
authorKevin Worth <kworth082@gmail.com>
Tue, 12 May 2020 03:16:20 +0000 (23:16 -0400)
committerCarl Worth <cworth@cworth.org>
Sat, 23 May 2020 13:49:00 +0000 (06:49 -0700)
Now that the ListView is working correctly, we can get rid of these two
FutureBuilders which were essentially intermediate steps to get to this
point.

flutterempires/lib/main.dart

index 89867ec99bb629883d56040ca5defdd9d28a1d33..64d8bf057591cad6e02f85b9c21844bef19e0eb3 100644 (file)
@@ -110,32 +110,8 @@ class _MyHomePageState extends State<MyHomePage> {
                 ),
               ),
               Spacer(flex: 1),
-              FutureBuilder<Player>(
-                future: futurePlayer,
-                builder: (context, snapshot) {
-                  if (snapshot.hasData) {
-                    return Text(snapshot.data.name);
-                  } else if (snapshot.hasError) {
-                    return Text("${snapshot.error}");
-                  }
-                  return CircularProgressIndicator();
-                },
-              ),
-              Spacer(flex: 1),
-              FutureBuilder<List<Player>>(
-                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();
-                },
-              ),
               Expanded(
-                flex: 10,
+                flex: 20,
                 child: FutureBuilder<List<Player>>(
                     future: allPlayers,
                     builder: (context, snapshot) {