X-Git-Url: https://git.cworth.org/git?p=lmno.games;a=blobdiff_plain;f=flutterempires%2Flib%2Fmain.dart;h=64d8bf057591cad6e02f85b9c21844bef19e0eb3;hp=7bb337c1b7b2b35cf158e276443e3d73a07c670f;hb=b9c184f2a7fd491e736c32b02baa38b18f906eb9;hpb=581baa23cbbf8b13223a28491775746f2b3992ad diff --git a/flutterempires/lib/main.dart b/flutterempires/lib/main.dart index 7bb337c..64d8bf0 100644 --- a/flutterempires/lib/main.dart +++ b/flutterempires/lib/main.dart @@ -110,49 +110,29 @@ class _MyHomePageState extends State { ), ), Spacer(flex: 1), - FutureBuilder( - 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>( - 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, - child: FutureBuilder>( - future: allPlayers, - builder: (context, snapshot) { - if (snapshot.hasData) { - return ListView.builder( - itemCount: snapshot.data.length, - itemBuilder: (context, index) { - return ListTile( - title: Text( - snapshot.data[index].name.toString())); - }); - } else if (snapshot.hasError) { - return Text("${snapshot.error}"); - } - return CircularProgressIndicator(); - }), - ), + flex: 20, + child: FutureBuilder>( + future: allPlayers, + builder: (context, snapshot) { + if (snapshot.hasData) { + if (snapshot.data.length == 0) { + return Text('No players yet'); + } else { + return ListView.builder( + itemCount: snapshot.data.length, + itemBuilder: (context, index) { + return ListTile( + title: Text( + snapshot.data[index].name.toString())); + }); + } + } else if (snapshot.hasError) { + return Text("${snapshot.error}"); + } + return CircularProgressIndicator(); + }), + ) ], ), ),