Skip to content

Commit a553164

Browse files
committed
Fix package info in settings
1 parent 1f0d3f5 commit a553164

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

lib/screens/settings.dart

+16-8
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ class SettingsPage extends StatefulWidget {
1717
class _SettingsPageState extends State<SettingsPage> {
1818
Storage storage = Storage.instance;
1919

20-
static String _appVersion = '?';
21-
static String _build = '?';
2220
static const String _apiVersion = '2.0.2';
2321
static const String _repoUrl = 'https://github.com/davquar/halfdot';
2422
static const String _license = 'MIT';
@@ -29,11 +27,6 @@ class _SettingsPageState extends State<SettingsPage> {
2927

3028
@override
3129
Widget build(BuildContext context) {
32-
PackageInfo.fromPlatform().then((PackageInfo info) {
33-
_appVersion = info.version;
34-
_build = info.buildNumber;
35-
});
36-
3730
return Scaffold(
3831
appBar: AppBar(
3932
title: Text(AppLocalizations.of(context)!.settingsTitle),
@@ -70,7 +63,22 @@ class _SettingsPageState extends State<SettingsPage> {
7063
),
7164
ListTile(
7265
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+
),
7482
),
7583
ListTile(
7684
title: Text(AppLocalizations.of(context)!.apiVersion),

0 commit comments

Comments
 (0)