From 219acc99a78b66921b6dd6aac62d619b03f39e21 Mon Sep 17 00:00:00 2001 From: ospab Date: Mon, 24 Aug 2026 14:42:47 +0300 Subject: [PATCH] feat(flutter): show app version at the bottom of the home screen MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds a muted "OSTP · v ()" line pinned below the metrics bar on the mobile home screen. The version is read from the build via package_info (already a dependency) rather than hardcoded, so it tracks the release automatically. Blank-safe if package info can't be read. --- ostp-flutter/lib/ui/home_screen.dart | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/ostp-flutter/lib/ui/home_screen.dart b/ostp-flutter/lib/ui/home_screen.dart index 8d85875..87457ab 100644 --- a/ostp-flutter/lib/ui/home_screen.dart +++ b/ostp-flutter/lib/ui/home_screen.dart @@ -4,6 +4,7 @@ import 'dart:ui'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:shared_preferences/shared_preferences.dart'; +import 'package:package_info_plus/package_info_plus.dart'; import '../models/connection_state_enum.dart'; import '../models/ostp_profile.dart'; import 'settings_screen.dart'; @@ -55,10 +56,15 @@ class _HomeScreenState extends State with TickerProviderStateMixin { String _pingText = '-- ms'; Color _pingColor = Colors.white54; + // App version, shown at the bottom of the home screen. Read from the build + // (pubspec) via package_info rather than hardcoded, so it never drifts. + String _version = ''; + @override void initState() { super.initState(); _loadSettings(); + _loadVersion(); _pulseController = AnimationController( vsync: this, duration: const Duration(seconds: 2), @@ -71,6 +77,17 @@ class _HomeScreenState extends State with TickerProviderStateMixin { _startPolling(); } + Future _loadVersion() async { + try { + final info = await PackageInfo.fromPlatform(); + if (mounted) { + setState(() => _version = 'v${info.version} (${info.buildNumber})'); + } + } catch (_) { + // Non-fatal: just leave the version line blank if it can't be read. + } + } + Future _checkInitialState() async { try { final isRunning = await platform.invokeMethod('isRunning'); @@ -517,6 +534,17 @@ class _HomeScreenState extends State with TickerProviderStateMixin { _buildTopBar(theme), Expanded(child: _buildStage(theme)), _buildMetricsBar(theme), + Padding( + padding: const EdgeInsets.only(top: 8, bottom: 10), + child: Text( + _version.isEmpty ? 'OSTP' : 'OSTP · $_version', + style: TextStyle( + fontSize: 11, + letterSpacing: 0.5, + color: Colors.white.withOpacity(0.28), + ), + ), + ), ], ), ),