diff --git a/integration_test/app_test.dart b/integration_test/app_test.dart index 45f8840..5d0d40f 100644 --- a/integration_test/app_test.dart +++ b/integration_test/app_test.dart @@ -879,6 +879,7 @@ void main() async { await tester.tap(find.byIcon(Icons.settings)); await tester.pumpAndSettle(); + expect(find.byKey(const Key('version')), findsOneWidget); expect(find.byKey(const Key('copyright')), findsOneWidget); await tester.pageBack(); diff --git a/lib/src/settings/presentations/settings_page.dart b/lib/src/settings/presentations/settings_page.dart index 53e140b..71c666c 100644 --- a/lib/src/settings/presentations/settings_page.dart +++ b/lib/src/settings/presentations/settings_page.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:nwt_reading/src/settings/stories/theme_mode_story.dart'; +import 'package:package_info_plus/package_info_plus.dart'; class SettingsPage extends ConsumerWidget { const SettingsPage({super.key}); @@ -15,7 +16,7 @@ class SettingsPage extends ConsumerWidget { appBar: AppBar( title: const Text('Settings'), ), - body: Column(children: [ + body: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ Padding( padding: const EdgeInsets.all(16), child: DropdownButton( @@ -40,11 +41,31 @@ class SettingsPage extends ConsumerWidget { ), ), ListTile( - subtitle: const Text( - 'Copyright © 2024 searchwork.org', - key: Key('copyright'), - ), - ) + subtitle: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + FutureBuilder( + future: PackageInfo.fromPlatform(), + builder: (context, snapshot) { + if (snapshot.connectionState == ConnectionState.waiting) { + return CircularProgressIndicator(); + } else if (snapshot.hasError) { + return Text('Error: ${snapshot.error}'); + } else { + return Text( + 'Version: ${snapshot.data?.version}', + key: Key('version'), + ); + } + }, + ), + const Text( + 'Copyright © 2024 searchwork.org', + style: TextStyle(height: 3), + key: Key('copyright'), + ), + ], + )), ]), ); } diff --git a/macos/Flutter/GeneratedPluginRegistrant.swift b/macos/Flutter/GeneratedPluginRegistrant.swift index 997e35d..cc667fc 100644 --- a/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/macos/Flutter/GeneratedPluginRegistrant.swift @@ -5,10 +5,12 @@ import FlutterMacOS import Foundation +import package_info_plus import shared_preferences_foundation import url_launcher_macos func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { + FPPPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FPPPackageInfoPlusPlugin")) SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin")) UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin")) } diff --git a/macos/Podfile.lock b/macos/Podfile.lock index 6741893..6a36798 100644 --- a/macos/Podfile.lock +++ b/macos/Podfile.lock @@ -1,5 +1,7 @@ PODS: - FlutterMacOS (1.0.0) + - package_info_plus (0.0.1): + - FlutterMacOS - shared_preferences_foundation (0.0.1): - Flutter - FlutterMacOS @@ -8,12 +10,15 @@ PODS: DEPENDENCIES: - FlutterMacOS (from `Flutter/ephemeral`) + - package_info_plus (from `Flutter/ephemeral/.symlinks/plugins/package_info_plus/macos`) - shared_preferences_foundation (from `Flutter/ephemeral/.symlinks/plugins/shared_preferences_foundation/darwin`) - url_launcher_macos (from `Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos`) EXTERNAL SOURCES: FlutterMacOS: :path: Flutter/ephemeral + package_info_plus: + :path: Flutter/ephemeral/.symlinks/plugins/package_info_plus/macos shared_preferences_foundation: :path: Flutter/ephemeral/.symlinks/plugins/shared_preferences_foundation/darwin url_launcher_macos: @@ -21,6 +26,7 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: FlutterMacOS: 8f6f14fa908a6fb3fba0cd85dbd81ec4b251fb24 + package_info_plus: 12f1c5c2cfe8727ca46cbd0b26677728972d9a5b shared_preferences_foundation: fcdcbc04712aee1108ac7fda236f363274528f78 url_launcher_macos: c82c93949963e55b228a30115bd219499a6fe404 diff --git a/pubspec.lock b/pubspec.lock index 4863ded..cb3bc2c 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -292,6 +292,22 @@ packages: url: "https://pub.dev" source: hosted version: "4.2.0" + http: + dependency: transitive + description: + name: http + sha256: b9c29a161230ee03d3ccf545097fccd9b87a5264228c5d348202e0f0c28f9010 + url: "https://pub.dev" + source: hosted + version: "1.2.2" + http_parser: + dependency: transitive + description: + name: http_parser + sha256: "2aa08ce0341cc9b354a498388e30986515406668dbcc4f7c950c3e715496693b" + url: "https://pub.dev" + source: hosted + version: "4.0.2" image: dependency: transitive description: @@ -409,6 +425,22 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.0" + package_info_plus: + dependency: "direct main" + description: + name: package_info_plus + sha256: da8d9ac8c4b1df253d1a328b7bf01ae77ef132833479ab40763334db13b91cce + url: "https://pub.dev" + source: hosted + version: "8.1.1" + 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: @@ -782,6 +814,14 @@ packages: url: "https://pub.dev" source: hosted version: "3.0.3" + win32: + dependency: transitive + description: + name: win32 + sha256: "84ba388638ed7a8cb3445a320c8273136ab2631cd5f2c57888335504ddab1bc2" + url: "https://pub.dev" + source: hosted + version: "5.8.0" xdg_directories: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 12b9bcb..046b77c 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -18,6 +18,7 @@ dependencies: flutter_riverpod: ^2.6.1 flutter_staggered_grid_view: ^0.7.0 intl: ^0.19.0 + package_info_plus: ^8.1.1 shared_preferences: ^2.3.2 url_launcher: ^6.3.1 uuid: ^4.5.1