From 1554281b205e3ad5bfbebcbeea04af7ae06ec730 Mon Sep 17 00:00:00 2001 From: Larry Aasen Date: Sat, 7 Dec 2024 11:00:15 -0500 Subject: [PATCH] Minor syntax change to fix compiler warning. Added new method MockUpgraderOS.currentTypeFormatted to return the OS type pretty formatted. --- .github/workflows/main.yml | 2 +- .github/workflows/platforms.yml | 2 +- CHANGELOG.md | 5 +++++ lib/src/upgrade_messages.dart | 2 -- lib/src/upgrade_os.dart | 13 +++++++++++++ pubspec.yaml | 2 +- test/upgrader_os_test.dart | 11 +++++++++++ 7 files changed, 32 insertions(+), 5 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e3f30c2e..2cf3c4c3 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -21,7 +21,7 @@ jobs: flutter-version: ['3.24.0', '3.24.5'] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: subosito/flutter-action@v2 with: diff --git a/.github/workflows/platforms.yml b/.github/workflows/platforms.yml index cf56827c..aad90fd4 100644 --- a/.github/workflows/platforms.yml +++ b/.github/workflows/platforms.yml @@ -19,7 +19,7 @@ jobs: runs-on: ${{ matrix.runs-on-name }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: subosito/flutter-action@v2 with: diff --git a/CHANGELOG.md b/CHANGELOG.md index b38e9aea..5ad94144 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## 11.3.1 + +- Minor syntax change to fix compiler warning. +- Added new method MockUpgraderOS.currentTypeFormatted to return the OS type pretty formatted. + ## 11.3.0 - [429] Improved the Hindi ('hi') translations. (thanks to @aruhant) diff --git a/lib/src/upgrade_messages.dart b/lib/src/upgrade_messages.dart index 1d0763de..8d8310dd 100644 --- a/lib/src/upgrade_messages.dart +++ b/lib/src/upgrade_messages.dart @@ -77,9 +77,7 @@ class UpgraderMessages { return releaseNotes; case UpgraderMessage.title: return title; - default: } - return null; } /// Determine the current language code, either from the context, or diff --git a/lib/src/upgrade_os.dart b/lib/src/upgrade_os.dart index 3e13cf4e..51cecd0a 100644 --- a/lib/src/upgrade_os.dart +++ b/lib/src/upgrade_os.dart @@ -141,6 +141,19 @@ class UpgraderOS { } } + /// Get the current OS type formatted, such as 'Android', 'iOS', etc. + String get currentTypeFormatted { + return switch (currentOSType) { + UpgraderOSType.android => 'Android', + UpgraderOSType.fuchsia => 'Fuchsia', + UpgraderOSType.ios => 'iOS', + UpgraderOSType.linux => 'Linux', + UpgraderOSType.macos => 'macOS', + UpgraderOSType.web => 'Web', + UpgraderOSType.windows => 'Windows', + }; + } + @override String toString() { return 'operatingSystem: $operatingSystem, version: $operatingSystemVersion'; diff --git a/pubspec.yaml b/pubspec.yaml index f2d087e3..517c5453 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: upgrader description: Flutter package for prompting users to upgrade when there is a newer version of the app in the store. -version: 11.3.0 +version: 11.3.1 homepage: https://github.com/larryaasen/upgrader environment: diff --git a/test/upgrader_os_test.dart b/test/upgrader_os_test.dart index dca4c55e..7102375b 100644 --- a/test/upgrader_os_test.dart +++ b/test/upgrader_os_test.dart @@ -129,6 +129,17 @@ void main() { expect(MockUpgraderOS(windows: true).current, 'windows'); }); + test('MockUpgraderOS currentTypeFormatted', () async { + expect(MockUpgraderOS().currentTypeFormatted, 'Android'); + expect(MockUpgraderOS(android: true).currentTypeFormatted, 'Android'); + expect(MockUpgraderOS(fuchsia: true).currentTypeFormatted, 'Fuchsia'); + expect(MockUpgraderOS(ios: true).currentTypeFormatted, 'iOS'); + expect(MockUpgraderOS(linux: true).currentTypeFormatted, 'Linux'); + expect(MockUpgraderOS(macos: true).currentTypeFormatted, 'macOS'); + expect(MockUpgraderOS(web: true).currentTypeFormatted, 'Web'); + expect(MockUpgraderOS(windows: true).currentTypeFormatted, 'Windows'); + }); + test('MockUpgraderOS currentOSType', () async { expect(MockUpgraderOS().currentOSType, UpgraderOSType.android); expect(