From 521c8f8c4e9cd430162d553c7bc8c04782f92a0e Mon Sep 17 00:00:00 2001 From: Bram Verhulst Date: Wed, 29 Jul 2026 01:40:37 +0200 Subject: [PATCH] feat: add version label in settings --- lib/views/settings_view.dart | 49 ++++++++++++++++++++++++++++++++++++ pubspec.yaml | 2 +- 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/lib/views/settings_view.dart b/lib/views/settings_view.dart index ba8d790..42eb7ee 100644 --- a/lib/views/settings_view.dart +++ b/lib/views/settings_view.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:go_router/go_router.dart'; +import 'package:package_info_plus/package_info_plus.dart'; import 'package:provider/provider.dart'; import '../models/settings.dart'; @@ -15,6 +16,9 @@ class SettingsScreenView extends StatefulWidget { } class _SettingsScreenViewState extends State { + String _appVersion = ''; + int _versionTaps = 0; + @override void initState() { super.initState(); @@ -22,6 +26,32 @@ class _SettingsScreenViewState extends State { WidgetsBinding.instance.addPostFrameCallback((_) { context.read().ensureLoaded(); context.read().ensureLoaded(); + _loadVersion(); + }); + } + + Future currentVersion() async { + final info = await PackageInfo.fromPlatform(); + debugPrint("Current app version: ${info.version}"); + return info.version; + } + + void _onVersionTap() { + _versionTaps++; + + if (_versionTaps >= 7) { + _versionTaps = 0; + context.push('/dev'); + } + } + + Future _loadVersion() async { + final version = await currentVersion(); + + if (!mounted) return; + + setState(() { + _appVersion = version; }); } @@ -229,6 +259,25 @@ class _SettingsScreenViewState extends State { ), ], ), + const SizedBox(height: 40), + GestureDetector( + onTap: _onVersionTap, + child: Center( + child: Text( + 'Version $_appVersion', + style: Theme.of(context) + .textTheme + .bodySmall + ?.copyWith( + color: Theme.of(context) + .colorScheme + .onSurface + .withValues(alpha: 0.5), + ), + ), + ), + ), + const SizedBox(height: 20), ], ); }, diff --git a/pubspec.yaml b/pubspec.yaml index 3e5747d..4e358cf 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html # In Windows, build-name is used as the major, minor, and patch parts # of the product and file versions while build-number is used as the build suffix. -version: 1.0.0+1 +version: 2.0.0+1 environment: sdk: ^3.12.2