@@ -17,8 +17,6 @@ class SettingsPage extends StatefulWidget {
17
17
class _SettingsPageState extends State <SettingsPage > {
18
18
Storage storage = Storage .instance;
19
19
20
- static String _appVersion = '?' ;
21
- static String _build = '?' ;
22
20
static const String _apiVersion = '2.0.2' ;
23
21
static const String _repoUrl = 'https://github.com/davquar/halfdot' ;
24
22
static const String _license = 'MIT' ;
@@ -29,11 +27,6 @@ class _SettingsPageState extends State<SettingsPage> {
29
27
30
28
@override
31
29
Widget build (BuildContext context) {
32
- PackageInfo .fromPlatform ().then ((PackageInfo info) {
33
- _appVersion = info.version;
34
- _build = info.buildNumber;
35
- });
36
-
37
30
return Scaffold (
38
31
appBar: AppBar (
39
32
title: Text (AppLocalizations .of (context)! .settingsTitle),
@@ -70,7 +63,22 @@ class _SettingsPageState extends State<SettingsPage> {
70
63
),
71
64
ListTile (
72
65
title: Text (AppLocalizations .of (context)! .appVersion),
73
- subtitle: Text ('$_appVersion (build $_build )' ),
66
+ subtitle: FutureBuilder <PackageInfo >(
67
+ future: PackageInfo .fromPlatform (),
68
+ builder: (
69
+ BuildContext context,
70
+ AsyncSnapshot <PackageInfo > snapshot,
71
+ ) {
72
+ if (snapshot.hasError) {
73
+ return Text ('Unknown: ${snapshot .error }' );
74
+ } else if (snapshot.hasData) {
75
+ return Text (
76
+ '${snapshot .data !.version } (build ${snapshot .data !.buildNumber })' ,
77
+ );
78
+ }
79
+ return const Text ('Unknown' );
80
+ },
81
+ ),
74
82
),
75
83
ListTile (
76
84
title: Text (AppLocalizations .of (context)! .apiVersion),
0 commit comments