Skip to content

Commit 9972a6c

Browse files
committed
feat: display app version in Server Configuration dialog
- Add package_info_plus import - Load app version in initState - Display version badge in dialog title - Fallback to v0.1.6 if PackageInfo fails
1 parent 06a08f7 commit 9972a6c

File tree

1 file changed

+44
-6
lines changed

1 file changed

+44
-6
lines changed

frontend/lib/features/startup/startup_dialog.dart

Lines changed: 44 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import 'package:flutter/material.dart';
22
import 'package:flutter/services.dart';
3+
import 'package:package_info_plus/package_info_plus.dart';
34
import 'port_checker.dart';
45

56
class StartupConfig {
@@ -47,6 +48,7 @@ class _StartupDialogState extends State<_StartupDialog> {
4748
late TextEditingController _proxyPortCtrl;
4849
PortStatus? _portStatus;
4950
bool _checking = true;
51+
String _appVersion = '';
5052

5153
@override
5254
void initState() {
@@ -57,9 +59,28 @@ class _StartupDialogState extends State<_StartupDialog> {
5759
_proxyPortCtrl = TextEditingController(
5860
text: widget.initialConfig.forwardProxyPort.toString(),
5961
);
62+
_loadAppVersion();
6063
_checkPorts();
6164
}
6265

66+
Future<void> _loadAppVersion() async {
67+
try {
68+
final packageInfo = await PackageInfo.fromPlatform();
69+
if (mounted) {
70+
setState(() {
71+
_appVersion = 'v${packageInfo.version}';
72+
});
73+
}
74+
} catch (e) {
75+
// Fallback version
76+
if (mounted) {
77+
setState(() {
78+
_appVersion = 'v0.1.6';
79+
});
80+
}
81+
}
82+
}
83+
6384
@override
6485
void dispose() {
6586
_apiPortCtrl.dispose();
@@ -158,13 +179,30 @@ class _StartupDialogState extends State<_StartupDialog> {
158179
size: 24,
159180
),
160181
const SizedBox(width: 12),
161-
Text(
162-
_checking
163-
? 'Checking Server Status'
164-
: (_portStatus?.bothStopped ?? true
165-
? 'Server Configuration'
166-
: 'Server Status'),
182+
Expanded(
183+
child: Text(
184+
_checking
185+
? 'Checking Server Status'
186+
: (_portStatus?.bothStopped ?? true
187+
? 'Server Configuration'
188+
: 'Server Status'),
189+
),
167190
),
191+
if (_appVersion.isNotEmpty)
192+
Container(
193+
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
194+
decoration: BoxDecoration(
195+
color: Colors.grey.withValues(alpha: 0.2),
196+
borderRadius: BorderRadius.circular(4),
197+
),
198+
child: Text(
199+
_appVersion,
200+
style: const TextStyle(
201+
fontSize: 12,
202+
fontWeight: FontWeight.w500,
203+
),
204+
),
205+
),
168206
],
169207
),
170208
content: SizedBox(

0 commit comments

Comments
 (0)