From 0f20ebdb1a0cc103a6f9806b1e94fee343767e70 Mon Sep 17 00:00:00 2001 From: Gerrit Balindt Date: Tue, 17 Sep 2024 18:19:51 +0200 Subject: [PATCH] add version+buildNumber --- lib/screens/verticalbar.dart | 31 +++++++++++++++++-- macos/Flutter/GeneratedPluginRegistrant.swift | 2 ++ pubspec.lock | 24 ++++++++++++++ pubspec.yaml | 1 + 4 files changed, 56 insertions(+), 2 deletions(-) diff --git a/lib/screens/verticalbar.dart b/lib/screens/verticalbar.dart index cdb66b1..00c623d 100644 --- a/lib/screens/verticalbar.dart +++ b/lib/screens/verticalbar.dart @@ -2,10 +2,34 @@ import 'package:flutter/material.dart'; import 'package:terrestrial_forest_monitor/providers/map-state.dart'; import 'package:provider/provider.dart'; import 'package:terrestrial_forest_monitor/widgets/map-navigation.dart'; +import 'package:package_info_plus/package_info_plus.dart'; -class VertialBar extends StatelessWidget { +class VertialBar extends StatefulWidget { const VertialBar({super.key}); + @override + State createState() => _VertialBarState(); +} + +class _VertialBarState extends State { + PackageInfo? packageInfo; + String version = ''; + String buildNumber = ''; + + @override + void initState() { + super.initState(); + _initPackageInfo(); + } + + Future _initPackageInfo() async { + packageInfo = await PackageInfo.fromPlatform(); + setState(() { + version = packageInfo!.version; + buildNumber = packageInfo!.buildNumber; + }); + } + @override Widget build(BuildContext context) { return Container( @@ -43,7 +67,10 @@ class VertialBar extends StatelessWidget { IconButton( onPressed: () => showDialog( context: context, - builder: (BuildContext context) => AlertDialog(title: const Text('Thünen Institute'), content: const Text('AlertDialog description')), + builder: (BuildContext context) => AlertDialog( + title: const Text('Thünen Institute'), + content: Text('Version: ${'$version+$buildNumber'}'), + ), ), icon: const Icon( Icons.contact_support, diff --git a/macos/Flutter/GeneratedPluginRegistrant.swift b/macos/Flutter/GeneratedPluginRegistrant.swift index dcd9102..76db50a 100644 --- a/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/macos/Flutter/GeneratedPluginRegistrant.swift @@ -9,6 +9,7 @@ import connectivity_plus import flutter_blue_plus import flutter_libserialport import geolocator_apple +import package_info_plus import path_provider_foundation func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { @@ -16,5 +17,6 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { FlutterBluePlusPlugin.register(with: registry.registrar(forPlugin: "FlutterBluePlusPlugin")) FlutterLibserialportPlugin.register(with: registry.registrar(forPlugin: "FlutterLibserialportPlugin")) GeolocatorPlugin.register(with: registry.registrar(forPlugin: "GeolocatorPlugin")) + FPPPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FPPPackageInfoPlusPlugin")) PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin")) } diff --git a/pubspec.lock b/pubspec.lock index a07c457..3c76e3c 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -781,6 +781,22 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.0" + package_info_plus: + dependency: "direct main" + description: + name: package_info_plus + sha256: a75164ade98cb7d24cfd0a13c6408927c6b217fa60dee5a7ff5c116a58f28918 + url: "https://pub.dev" + source: hosted + version: "8.0.2" + package_info_plus_platform_interface: + dependency: transitive + description: + name: package_info_plus_platform_interface + sha256: ac1f4a4847f1ade8e6a87d1f39f5d7c67490738642e2542f559ec38c37489a66 + url: "https://pub.dev" + source: hosted + version: "3.0.1" path: dependency: transitive description: @@ -1274,6 +1290,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.2.1" + win32: + dependency: transitive + description: + name: win32 + sha256: "68d1e89a91ed61ad9c370f9f8b6effed9ae5e0ede22a270bdfa6daf79fc2290a" + url: "https://pub.dev" + source: hosted + version: "5.5.4" wkt_parser: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 3218c55..27a0d8d 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -62,6 +62,7 @@ dependencies: hive_flutter: ^1.1.0 libserialport: ^0.3.0+1 nmea: ^3.3.2 + package_info_plus: ^8.0.2 #flutter_gen: any