Skip to content

Commit

Permalink
Fix package info in settings
Browse files Browse the repository at this point in the history
  • Loading branch information
davquar committed Apr 29, 2023
1 parent 1f0d3f5 commit a553164
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions lib/screens/settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ class SettingsPage extends StatefulWidget {
class _SettingsPageState extends State<SettingsPage> {
Storage storage = Storage.instance;

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

@override
Widget build(BuildContext context) {
PackageInfo.fromPlatform().then((PackageInfo info) {
_appVersion = info.version;
_build = info.buildNumber;
});

return Scaffold(
appBar: AppBar(
title: Text(AppLocalizations.of(context)!.settingsTitle),
Expand Down Expand Up @@ -70,7 +63,22 @@ class _SettingsPageState extends State<SettingsPage> {
),
ListTile(
title: Text(AppLocalizations.of(context)!.appVersion),
subtitle: Text('$_appVersion (build $_build)'),
subtitle: FutureBuilder<PackageInfo>(
future: PackageInfo.fromPlatform(),
builder: (
BuildContext context,
AsyncSnapshot<PackageInfo> snapshot,
) {
if (snapshot.hasError) {
return Text('Unknown: ${snapshot.error}');
} else if (snapshot.hasData) {
return Text(
'${snapshot.data!.version} (build ${snapshot.data!.buildNumber})',
);
}
return const Text('Unknown');
},
),
),
ListTile(
title: Text(AppLocalizations.of(context)!.apiVersion),
Expand Down

0 comments on commit a553164

Please sign in to comment.