From 79ea0aa40372d5511c696a1e6870ba40251346c3 Mon Sep 17 00:00:00 2001 From: nilsreichardt Date: Fri, 30 Sep 2022 20:48:26 +0200 Subject: [PATCH 1/5] `randomString()` --- .../test/random_string/random_string_test.dart | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 lib/sharezone_utils/test/random_string/random_string_test.dart diff --git a/lib/sharezone_utils/test/random_string/random_string_test.dart b/lib/sharezone_utils/test/random_string/random_string_test.dart new file mode 100644 index 000000000..9516c5fe7 --- /dev/null +++ b/lib/sharezone_utils/test/random_string/random_string_test.dart @@ -0,0 +1,10 @@ +import 'package:flutter_test/flutter_test.dart'; +import 'package:sharezone_utils/random_string.dart'; + +void main() { + test('randomString()', () { + for (int i = 0; i < 50; i++) { + expect(randomString(10), hasLength(10)); + } + }); +} From 0e8a88e8333a82ef9771dfd42e9de821a4ab7712 Mon Sep 17 00:00:00 2001 From: nilsreichardt Date: Fri, 30 Sep 2022 20:48:40 +0200 Subject: [PATCH 2/5] `randomIDString()` --- .../test/random_string/random_string_test.dart | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/sharezone_utils/test/random_string/random_string_test.dart b/lib/sharezone_utils/test/random_string/random_string_test.dart index 9516c5fe7..9f4325538 100644 --- a/lib/sharezone_utils/test/random_string/random_string_test.dart +++ b/lib/sharezone_utils/test/random_string/random_string_test.dart @@ -7,4 +7,10 @@ void main() { expect(randomString(10), hasLength(10)); } }); + + test('randomIDString()', () { + for (int i = 0; i < 50; i++) { + expect(randomIDString(10), hasLength(10)); + } + }); } From f26312fd146bfc71ea64c7847b4b5e2fc25ce7ca Mon Sep 17 00:00:00 2001 From: nilsreichardt Date: Fri, 30 Sep 2022 21:04:21 +0200 Subject: [PATCH 3/5] Upgrade dependenices --- lib/sharezone_utils/pubspec.lock | 79 ++++++++++++++++++++++++++++---- lib/sharezone_utils/pubspec.yaml | 6 +-- 2 files changed, 72 insertions(+), 13 deletions(-) diff --git a/lib/sharezone_utils/pubspec.lock b/lib/sharezone_utils/pubspec.lock index 88f51ea96..93859ada3 100644 --- a/lib/sharezone_utils/pubspec.lock +++ b/lib/sharezone_utils/pubspec.lock @@ -43,20 +43,48 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.15.0" - device_info: + device_info_plus: dependency: "direct main" description: - name: device_info + name: device_info_plus url: "https://pub.dartlang.org" source: hosted - version: "2.0.2" - device_info_platform_interface: + version: "3.2.4" + device_info_plus_linux: dependency: transitive description: - name: device_info_platform_interface + name: device_info_plus_linux url: "https://pub.dartlang.org" source: hosted - version: "2.0.1" + version: "2.1.1" + device_info_plus_macos: + dependency: transitive + description: + name: device_info_plus_macos + url: "https://pub.dartlang.org" + source: hosted + version: "2.2.3" + device_info_plus_platform_interface: + dependency: transitive + description: + name: device_info_plus_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "2.6.1" + device_info_plus_web: + dependency: transitive + description: + name: device_info_plus_web + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.0" + device_info_plus_windows: + dependency: transitive + description: + name: device_info_plus_windows + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.1" fake_async: dependency: transitive description: @@ -64,6 +92,20 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.2.0" + ffi: + dependency: transitive + description: + name: ffi + url: "https://pub.dartlang.org" + source: hosted + version: "1.2.1" + file: + dependency: transitive + description: + name: file + url: "https://pub.dartlang.org" + source: hosted + version: "6.1.4" flutter: dependency: "direct main" description: flutter @@ -74,6 +116,18 @@ packages: description: flutter source: sdk version: "0.0.0" + flutter_web_plugins: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" + js: + dependency: transitive + description: + name: js + url: "https://pub.dartlang.org" + source: hosted + version: "0.6.3" matcher: dependency: transitive description: @@ -115,7 +169,7 @@ packages: name: rxdart url: "https://pub.dartlang.org" source: hosted - version: "0.27.1" + version: "0.27.5" sky_engine: dependency: transitive description: flutter @@ -177,6 +231,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.1.1" + win32: + dependency: transitive + description: + name: win32 + url: "https://pub.dartlang.org" + source: hosted + version: "2.5.2" sdks: - dart: ">=2.14.0 <3.0.0" - flutter: ">=1.12.13+hotfix.5" + dart: ">=2.15.0 <3.0.0" + flutter: ">=1.20.0" diff --git a/lib/sharezone_utils/pubspec.yaml b/lib/sharezone_utils/pubspec.yaml index e5c23b79d..94625b6f4 100644 --- a/lib/sharezone_utils/pubspec.yaml +++ b/lib/sharezone_utils/pubspec.yaml @@ -15,13 +15,11 @@ environment: sdk: ">=2.10.0 <3.0.0" dependencies: + device_info_plus: ^3.1.2 flutter: sdk: flutter - device_info: ^2.0.2 - rxdart: ^0.27.1 + rxdart: ^0.27.5 dev_dependencies: flutter_test: sdk: flutter - -flutter: null From 401df7bf257e518dfeaf7944f2d723bb65ea2607 Mon Sep 17 00:00:00 2001 From: nilsreichardt Date: Fri, 30 Sep 2022 21:43:12 +0200 Subject: [PATCH 4/5] Migrate `sharezone_utils` to null safety --- .../android_information.dart | 86 +++++++++---------- .../ios_information.dart | 48 +++++------ .../mobile_device_information_manager.dart | 8 +- .../lib/src/dimensions/dimensions.dart | 30 +++---- .../lib/src/platform/platform_check.dart | 6 +- lib/sharezone_utils/lib/src/streams.dart | 38 ++------ lib/sharezone_utils/pubspec.yaml | 2 +- 7 files changed, 97 insertions(+), 121 deletions(-) diff --git a/lib/sharezone_utils/lib/src/device_information_manager/android_information.dart b/lib/sharezone_utils/lib/src/device_information_manager/android_information.dart index a8f0f8907..656b32561 100644 --- a/lib/sharezone_utils/lib/src/device_information_manager/android_information.dart +++ b/lib/sharezone_utils/lib/src/device_information_manager/android_information.dart @@ -14,26 +14,26 @@ import 'package:meta/meta.dart'; /// See: https://developer.android.com/reference/android/os/Build.VERSION.html class AndroidDeviceInformation { AndroidDeviceInformation({ - @required this.version, - @required this.board, - @required this.bootloader, - @required this.brand, - @required this.device, - @required this.display, - @required this.fingerprint, - @required this.hardware, - @required this.host, - @required this.id, - @required this.manufacturer, - @required this.model, - @required this.product, - @required List supported32BitAbis, - @required List supported64BitAbis, - @required List supportedAbis, - @required this.tags, - @required this.type, - @required this.isPhysicalDevice, - @required this.androidId, + required this.version, + required this.board, + required this.bootloader, + required this.brand, + required this.device, + required this.display, + required this.fingerprint, + required this.hardware, + required this.host, + required this.id, + required this.manufacturer, + required this.model, + required this.product, + required List supported32BitAbis, + required List supported64BitAbis, + required List supportedAbis, + required this.tags, + required this.type, + required this.isPhysicalDevice, + required this.androidId, }) : supported32BitAbis = List.unmodifiable(supported32BitAbis), supported64BitAbis = List.unmodifiable(supported64BitAbis), supportedAbis = List.unmodifiable(supportedAbis); @@ -42,40 +42,40 @@ class AndroidDeviceInformation { final AndroidBuildVersion version; /// The name of the underlying board, like "goldfish". - final String board; + final String? board; /// The system bootloader version number. - final String bootloader; + final String? bootloader; /// The consumer-visible brand with which the product/hardware will be associated, if any. - final String brand; + final String? brand; /// The name of the industrial design. - final String device; + final String? device; /// A build ID string meant for displaying to the user. - final String display; + final String? display; /// A string that uniquely identifies this build. - final String fingerprint; + final String? fingerprint; /// The name of the hardware (from the kernel command line or /proc). - final String hardware; + final String? hardware; /// Hostname. - final String host; + final String? host; /// Either a changelist number, or a label like "M4-rc20". - final String id; + final String? id; /// The manufacturer of the product/hardware. - final String manufacturer; + final String? manufacturer; /// The end-user-visible name for the end product. - final String model; + final String? model; /// The name of the overall product. - final String product; + final String? product; /// An ordered list of 32 bit ABIs supported by this device. final List supported32BitAbis; @@ -87,16 +87,16 @@ class AndroidDeviceInformation { final List supportedAbis; /// Comma-separated tags describing the build, like "unsigned,debug". - final String tags; + final String? tags; /// The type of build, like "user" or "eng". - final String type; + final String? type; /// `false` if the application is running in an emulator, `true` otherwise. - final bool isPhysicalDevice; + final bool? isPhysicalDevice; /// The Android hardware device ID that is unique between the device + user and app signing. - final String androidId; + final String? androidId; } class AndroidBuildVersion { @@ -111,25 +111,25 @@ class AndroidBuildVersion { }); /// The base OS build the product is based on. - final String baseOS; + final String? baseOS; /// The current development codename, or the string "REL" if this is a release build. - final String codename; + final String? codename; /// The internal value used by the underlying source control to represent this build. - final String incremental; + final String? incremental; /// The developer preview revision of a prerelease SDK. - final int previewSdkInt; + final int? previewSdkInt; /// The user-visible version string. - final String release; + final String? release; /// The user-visible SDK version of the framework. /// /// Possible values are defined in: https://developer.android.com/reference/android/os/Build.VERSION_CODES.html - final int sdkInt; + final int? sdkInt; /// The user-visible security patch level. - final String securityPatch; + final String? securityPatch; } \ No newline at end of file diff --git a/lib/sharezone_utils/lib/src/device_information_manager/ios_information.dart b/lib/sharezone_utils/lib/src/device_information_manager/ios_information.dart index 34bb78616..b0dde3b71 100644 --- a/lib/sharezone_utils/lib/src/device_information_manager/ios_information.dart +++ b/lib/sharezone_utils/lib/src/device_information_manager/ios_information.dart @@ -13,33 +13,33 @@ import 'package:meta/meta.dart'; /// See: https://developer.apple.com/documentation/uikit/uidevice class IosDeviceInformation { IosDeviceInformation({ - @required this.name, - @required this.systemName, - @required this.systemVersion, - @required this.model, - @required this.localizedModel, - @required this.identifierForVendor, - @required this.isPhysicalDevice, - @required this.utsname, + required this.name, + required this.systemName, + required this.systemVersion, + required this.model, + required this.localizedModel, + required this.identifierForVendor, + required this.isPhysicalDevice, + required this.utsname, }); /// Device name. - final String name; + final String? name; /// The name of the current operating system. - final String systemName; + final String? systemName; /// The current operating system version. - final String systemVersion; + final String? systemVersion; /// Device model. - final String model; + final String? model; /// Localized name of the device model. - final String localizedModel; + final String? localizedModel; /// Unique UUID value identifying the current device. - final String identifierForVendor; + final String? identifierForVendor; /// `false` if the application is running in a simulator, `true` otherwise. final bool isPhysicalDevice; @@ -52,25 +52,25 @@ class IosDeviceInformation { /// See http://pubs.opengroup.org/onlinepubs/7908799/xsh/sysutsname.h.html for details. class IosUtsname { IosUtsname({ - @required this.sysname, - @required this.nodename, - @required this.release, - @required this.version, - @required this.machine, + required this.sysname, + required this.nodename, + required this.release, + required this.version, + required this.machine, }); /// Operating system name. - final String sysname; + final String? sysname; /// Network node name. - final String nodename; + final String? nodename; /// Release level. - final String release; + final String? release; /// Version level. - final String version; + final String? version; /// Hardware type (e.g. 'iPhone7,1' for iPhone 6 Plus). - final String machine; + final String? machine; } \ No newline at end of file diff --git a/lib/sharezone_utils/lib/src/device_information_manager/mobile_device_information_manager.dart b/lib/sharezone_utils/lib/src/device_information_manager/mobile_device_information_manager.dart index fcc53b5c0..24940f954 100644 --- a/lib/sharezone_utils/lib/src/device_information_manager/mobile_device_information_manager.dart +++ b/lib/sharezone_utils/lib/src/device_information_manager/mobile_device_information_manager.dart @@ -6,7 +6,7 @@ // // SPDX-License-Identifier: EUPL-1.2 -import 'package:device_info/device_info.dart' +import 'package:device_info_plus/device_info_plus.dart' hide AndroidBuildVersion, IosUtsname; import 'package:flutter/cupertino.dart'; @@ -86,7 +86,7 @@ class MobileDeviceInformationRetreiver extends DeviceInformationRetreiver { /// 30 - v11 - Android11\ /// /// Source: https://source.android.com/setup/start/build-numbers - Future androidSdkInt() async { + Future androidSdkInt() async { final info = await androidInfo; return info.version.sdkInt; } @@ -116,14 +116,14 @@ class MobileDeviceInformationRetreiver extends DeviceInformationRetreiver { @visibleForTesting class MockMobileDeviceInformationRetreiver implements MobileDeviceInformationRetreiver { - int _androidSdkInt; + int? _androidSdkInt; @override Future get androidInfo => throw UnimplementedError(); @override - Future androidSdkInt() async { + Future androidSdkInt() async { return _androidSdkInt; } diff --git a/lib/sharezone_utils/lib/src/dimensions/dimensions.dart b/lib/sharezone_utils/lib/src/dimensions/dimensions.dart index e1abdcea1..8f329aa05 100644 --- a/lib/sharezone_utils/lib/src/dimensions/dimensions.dart +++ b/lib/sharezone_utils/lib/src/dimensions/dimensions.dart @@ -34,17 +34,17 @@ class Dimensions { } EdgeInsets get dialogPaddingDimensions { - if (isDesktopModus == false) + if (isDesktopModus == false) { return EdgeInsets.zero; - else { - return EdgeInsets.symmetric( - horizontal: 32, - vertical: sizeByPixels( - height, - min: 0, - max: 64, - )); } + + return EdgeInsets.symmetric( + horizontal: 32, + vertical: _sizeByPixels( + height, + max: 64, + ), + ); } double get dialogBorderRadiusDimensions { @@ -56,19 +56,17 @@ class Dimensions { } } -double sizeByPixels( +double _sizeByPixels( double pixels, { - double min, - double max, - double factor, - double breakpoint, + required double max, + double min = 0, }) { - double value = pow(100 * e, (pixels / 300) - 1); + final value = pow(100 * e, (pixels / 300) - 1); if (value < min) { return min; } if (value > max) { return max; } - return value; + return value as double; } diff --git a/lib/sharezone_utils/lib/src/platform/platform_check.dart b/lib/sharezone_utils/lib/src/platform/platform_check.dart index 2ff68d1a2..1d354f521 100644 --- a/lib/sharezone_utils/lib/src/platform/platform_check.dart +++ b/lib/sharezone_utils/lib/src/platform/platform_check.dart @@ -29,11 +29,11 @@ class PlatformCheck { } @visibleForTesting - static void setCurrentPlatformForTesting(Platform currentPlatform) { + static void setCurrentPlatformForTesting(Platform? currentPlatform) { _mockedCurrentPlatformForTesting = currentPlatform; } - static Platform _mockedCurrentPlatformForTesting; + static Platform? _mockedCurrentPlatformForTesting; static bool get isAndroid => currentPlatform == Platform.android; static bool get isIOS => currentPlatform == Platform.iOS; @@ -131,7 +131,7 @@ class PlatformCheckVariant extends TestVariant { /// This method behaviour is copied from TargetPlatformVariant @override - Future tearDown(Platform value, Platform memento) async { + Future tearDown(Platform value, Platform? memento) async { // Why setting [memento] as current platform? See in [TestVariant.tearDown] PlatformCheck.setCurrentPlatformForTesting(memento); } diff --git a/lib/sharezone_utils/lib/src/streams.dart b/lib/sharezone_utils/lib/src/streams.dart index 99b005206..d73955f9a 100644 --- a/lib/sharezone_utils/lib/src/streams.dart +++ b/lib/sharezone_utils/lib/src/streams.dart @@ -8,44 +8,22 @@ import 'package:rxdart/rxdart.dart'; -class TwoStreamSnapshot { - final T0 data0; - final T1 data1; +class TwoStreamSnapshot { + final T0? data0; + final T1? data1; const TwoStreamSnapshot(this.data0, this.data1); } -class TwoStreams { - final Stream stream0; - final Stream stream1; +class TwoStreams { + final Stream stream0; + final Stream stream1; TwoStreams(this.stream0, this.stream1); - Stream> get stream { + Stream> get stream { return CombineLatestStream([stream0, stream1], (snapshots) { - return TwoStreamSnapshot(snapshots[0], snapshots[1]); - }); - } -} - -class ThreeStreamSnapshot { - final T0 data0; - final T1 data1; - final T2 data2; - - const ThreeStreamSnapshot(this.data0, this.data1, this.data2); -} - -class ThreeStreams { - final Stream stream0; - final Stream stream1; - final Stream stream2; - - ThreeStreams(this.stream0, this.stream1, this.stream2); - - Stream> get stream { - return CombineLatestStream([stream0, stream1, stream2], (snapshots) { - return ThreeStreamSnapshot(snapshots[0], snapshots[1], snapshots[2]); + return TwoStreamSnapshot(snapshots[0] as T0?, snapshots[1] as T1?); }); } } diff --git a/lib/sharezone_utils/pubspec.yaml b/lib/sharezone_utils/pubspec.yaml index 94625b6f4..d59839f9c 100644 --- a/lib/sharezone_utils/pubspec.yaml +++ b/lib/sharezone_utils/pubspec.yaml @@ -12,7 +12,7 @@ version: 0.0.1 publish_to: none environment: - sdk: ">=2.10.0 <3.0.0" + sdk: ">=2.12.0 <3.0.0" dependencies: device_info_plus: ^3.1.2 From f82cabd77d9294b2f057196856f113b49fcc5a2e Mon Sep 17 00:00:00 2001 From: nilsreichardt Date: Fri, 30 Sep 2022 23:17:12 +0200 Subject: [PATCH 5/5] Fix CI --- .../device_information_manager/android_information.dart | 2 -- .../src/device_information_manager/ios_information.dart | 2 -- .../test/random_string/random_string_test.dart | 8 ++++++++ 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/sharezone_utils/lib/src/device_information_manager/android_information.dart b/lib/sharezone_utils/lib/src/device_information_manager/android_information.dart index 656b32561..b2274e1f3 100644 --- a/lib/sharezone_utils/lib/src/device_information_manager/android_information.dart +++ b/lib/sharezone_utils/lib/src/device_information_manager/android_information.dart @@ -6,8 +6,6 @@ // // SPDX-License-Identifier: EUPL-1.2 -import 'package:meta/meta.dart'; - /// Version values of the current Android operating system build derived from /// `android.os.Build.VERSION`. /// diff --git a/lib/sharezone_utils/lib/src/device_information_manager/ios_information.dart b/lib/sharezone_utils/lib/src/device_information_manager/ios_information.dart index b0dde3b71..9f74e9d3c 100644 --- a/lib/sharezone_utils/lib/src/device_information_manager/ios_information.dart +++ b/lib/sharezone_utils/lib/src/device_information_manager/ios_information.dart @@ -6,8 +6,6 @@ // // SPDX-License-Identifier: EUPL-1.2 -import 'package:meta/meta.dart'; - /// Information derived from `UIDevice`. /// /// See: https://developer.apple.com/documentation/uikit/uidevice diff --git a/lib/sharezone_utils/test/random_string/random_string_test.dart b/lib/sharezone_utils/test/random_string/random_string_test.dart index 9f4325538..f152922d5 100644 --- a/lib/sharezone_utils/test/random_string/random_string_test.dart +++ b/lib/sharezone_utils/test/random_string/random_string_test.dart @@ -1,3 +1,11 @@ +// Copyright (c) 2022 Sharezone UG (haftungsbeschränkt) +// Licensed under the EUPL-1.2-or-later. +// +// You may obtain a copy of the Licence at: +// https://joinup.ec.europa.eu/software/page/eupl +// +// SPDX-License-Identifier: EUPL-1.2 + import 'package:flutter_test/flutter_test.dart'; import 'package:sharezone_utils/random_string.dart';