diff --git a/example/lib/player_info.dart b/example/lib/player_info.dart index c078eb17..edcb8b0c 100644 --- a/example/lib/player_info.dart +++ b/example/lib/player_info.dart @@ -12,7 +12,7 @@ class PlayerInfo extends StatefulWidget { } class PlayerInfoState extends State { - final Map _data = {}; + final Map _data = {}; Future updatePlayerInfo(Player player, Event event) async { if (event is ReadyEvent) { @@ -67,8 +67,13 @@ class PlayerInfoState extends State { void _updatePlayerInfoForField(String field, Future value) { value.then((dynamic value) { + var valueString = value.toString(); + if (value is double) { + valueString = value.toStringAsFixed(2); + } + setState(() { - _data[field] = value.toString(); + _data[field] = valueString; }); }); } @@ -79,7 +84,7 @@ class PlayerInfoState extends State { itemCount: _data.length, itemBuilder: (context, index) { final key = _data.keys.elementAt(index); - final value = _data[key]; + final value = _data[key]!; return Padding( padding: const EdgeInsets.symmetric(vertical: 1, horizontal: 1), @@ -91,7 +96,7 @@ class PlayerInfoState extends State { ), Expanded( flex: 3, - child: Text(value.toString()), + child: Text(value), ), ], ),