X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=flutterempires%2Flib%2Fmain.dart;h=e313be10cb04ba71750ab650ab2a589a0cd48b8f;hb=893153993716d14aa37813af19fd7dff83f70af3;hp=7bb1c7deb4d75311e97d82f1a959cde946f122f2;hpb=584dc2906ede9ec4b39a7870b5875154b0968ed3;p=lmno.games diff --git a/flutterempires/lib/main.dart b/flutterempires/lib/main.dart index 7bb1c7d..e313be1 100644 --- a/flutterempires/lib/main.dart +++ b/flutterempires/lib/main.dart @@ -53,6 +53,14 @@ class MyHomePage extends StatefulWidget { class _MyHomePageState extends State { int _counter = 0; + Future futurePlayer; + + @override + void initState() { + super.initState(); + futurePlayer = Player.fetchFirstPlayer(); + } + void _incrementCounter() { setState(() { // This call to setState tells the Flutter framework that something has @@ -107,7 +115,13 @@ 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}"); + } // By default, show a loading spinner. return CircularProgressIndicator(); },