Skip to content

Commit 6ebc0ea

Browse files
authored
fix(device_info_plus): Specify correct Dart and Flutter version requirements (#3597)
1 parent e1152bb commit 6ebc0ea

13 files changed

Lines changed: 126 additions & 104 deletions

packages/device_info_plus/device_info_plus/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ Get current device information from within the Flutter application.
1616

1717
## Requirements
1818

19-
- Flutter >=3.22.0
20-
- Dart >=3.4.0 <4.0.0
19+
- Flutter >=3.29.0
20+
- Dart >=3.7.0 <4.0.0
2121
- iOS >=12.0
2222
- MacOS >=10.14
2323
- Android `compileSDK` 34

packages/device_info_plus/device_info_plus/lib/device_info_plus.dart

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,26 +50,30 @@ class DeviceInfoPlugin {
5050
///
5151
/// See: https://developer.android.com/reference/android/os/Build.html
5252
Future<AndroidDeviceInfo> get androidInfo async =>
53-
_cachedAndroidDeviceInfo ??=
54-
AndroidDeviceInfo.fromMap((await _platform.deviceInfo()).data);
53+
_cachedAndroidDeviceInfo ??= AndroidDeviceInfo.fromMap(
54+
(await _platform.deviceInfo()).data,
55+
);
5556

5657
/// This information does not change from call to call. Cache it.
5758
IosDeviceInfo? _cachedIosDeviceInfo;
5859

5960
/// Information derived from `UIDevice`.
6061
///
6162
/// See: https://developer.apple.com/documentation/uikit/uidevice
62-
Future<IosDeviceInfo> get iosInfo async => _cachedIosDeviceInfo ??=
63-
IosDeviceInfo.fromMap((await _platform.deviceInfo()).data);
63+
Future<IosDeviceInfo> get iosInfo async =>
64+
_cachedIosDeviceInfo ??= IosDeviceInfo.fromMap(
65+
(await _platform.deviceInfo()).data,
66+
);
6467

6568
/// This information does not change from call to call. Cache it.
6669
LinuxDeviceInfo? _cachedLinuxDeviceInfo;
6770

6871
/// Information derived from `/etc/os-release`.
6972
///
7073
/// See: https://www.freedesktop.org/software/systemd/man/os-release.html
71-
Future<LinuxDeviceInfo> get linuxInfo async => _cachedLinuxDeviceInfo ??=
72-
await _platform.deviceInfo() as LinuxDeviceInfo;
74+
Future<LinuxDeviceInfo> get linuxInfo async =>
75+
_cachedLinuxDeviceInfo ??=
76+
await _platform.deviceInfo() as LinuxDeviceInfo;
7377

7478
/// This information does not change from call to call. Cache it.
7579
WebBrowserInfo? _cachedWebBrowserInfo;
@@ -82,8 +86,10 @@ class DeviceInfoPlugin {
8286
MacOsDeviceInfo? _cachedMacosDeviceInfo;
8387

8488
/// Returns device information for macos. Information sourced from Sysctl.
85-
Future<MacOsDeviceInfo> get macOsInfo async => _cachedMacosDeviceInfo ??=
86-
MacOsDeviceInfo.fromMap((await _platform.deviceInfo()).data);
89+
Future<MacOsDeviceInfo> get macOsInfo async =>
90+
_cachedMacosDeviceInfo ??= MacOsDeviceInfo.fromMap(
91+
(await _platform.deviceInfo()).data,
92+
);
8793

8894
WindowsDeviceInfo? _cachedWindowsDeviceInfo;
8995

packages/device_info_plus/device_info_plus/lib/src/device_info_plus_linux.dart

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class DeviceInfoPlusLinuxPlugin extends DeviceInfoPlatform {
1818

1919
///
2020
DeviceInfoPlusLinuxPlugin({@visibleForTesting FileSystem? fileSystem})
21-
: _fileSystem = fileSystem ?? const LocalFileSystem();
21+
: _fileSystem = fileSystem ?? const LocalFileSystem();
2222

2323
@override
2424
Future<BaseDeviceInfo> deviceInfo() async {
@@ -50,8 +50,9 @@ class DeviceInfoPlusLinuxPlugin extends DeviceInfoPlatform {
5050
}
5151

5252
Future<Map<String, String?>?> _getOsRelease() {
53-
return _tryReadKeyValues('/etc/os-release').then((value) async =>
54-
value ?? await _tryReadKeyValues('/usr/lib/os-release'));
53+
return _tryReadKeyValues('/etc/os-release').then(
54+
(value) async => value ?? await _tryReadKeyValues('/usr/lib/os-release'),
55+
);
5556
}
5657

5758
Future<Map<String, String?>?> _getLsbRelease() {
@@ -95,10 +96,12 @@ extension _Unquote on String {
9596

9697
extension _KeyValues on List<String> {
9798
Map<String, String?> toKeyValues() {
98-
return Map.fromEntries(map((line) {
99-
final parts = line.split('=');
100-
if (parts.length != 2) return MapEntry(line, null);
101-
return MapEntry(parts.first, parts.last.unquote());
102-
}));
99+
return Map.fromEntries(
100+
map((line) {
101+
final parts = line.split('=');
102+
if (parts.length != 2) return MapEntry(line, null);
103+
return MapEntry(parts.first, parts.last.unquote());
104+
}),
105+
);
103106
}
104107
}

packages/device_info_plus/device_info_plus/lib/src/device_info_plus_web.dart

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -17,31 +17,30 @@ class DeviceInfoPlusWebPlugin extends DeviceInfoPlatform {
1717
/// Factory method that initializes the DeviceInfoPlus plugin platform
1818
/// with an instance of the plugin for the web.
1919
static void registerWith(Registrar registrar) {
20-
DeviceInfoPlatform.instance =
21-
DeviceInfoPlusWebPlugin(html.window.navigator);
20+
DeviceInfoPlatform.instance = DeviceInfoPlusWebPlugin(
21+
html.window.navigator,
22+
);
2223
}
2324

2425
@override
2526
Future<BaseDeviceInfo> deviceInfo() {
2627
return Future<WebBrowserInfo>.value(
27-
WebBrowserInfo.fromMap(
28-
{
29-
'appCodeName': _navigator.appCodeName,
30-
'appName': _navigator.appName,
31-
'appVersion': _navigator.appVersion,
32-
'deviceMemory': _navigator.safeDeviceMemory,
33-
'language': _navigator.language,
34-
'languages': _navigator.languages.toDart,
35-
'platform': _navigator.platform,
36-
'product': _navigator.product,
37-
'productSub': _navigator.productSub,
38-
'userAgent': _navigator.userAgent,
39-
'vendor': _navigator.vendor,
40-
'vendorSub': _navigator.vendorSub,
41-
'hardwareConcurrency': _navigator.hardwareConcurrency,
42-
'maxTouchPoints': _navigator.maxTouchPoints,
43-
},
44-
),
28+
WebBrowserInfo.fromMap({
29+
'appCodeName': _navigator.appCodeName,
30+
'appName': _navigator.appName,
31+
'appVersion': _navigator.appVersion,
32+
'deviceMemory': _navigator.safeDeviceMemory,
33+
'language': _navigator.language,
34+
'languages': _navigator.languages.toDart,
35+
'platform': _navigator.platform,
36+
'product': _navigator.product,
37+
'productSub': _navigator.productSub,
38+
'userAgent': _navigator.userAgent,
39+
'vendor': _navigator.vendor,
40+
'vendorSub': _navigator.vendorSub,
41+
'hardwareConcurrency': _navigator.hardwareConcurrency,
42+
'maxTouchPoints': _navigator.maxTouchPoints,
43+
}),
4544
);
4645
}
4746
}

packages/device_info_plus/device_info_plus/lib/src/device_info_plus_windows.dart

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,12 @@ class DeviceInfoPlusWindowsPlugin extends DeviceInfoPlatform {
3030
// package:win32, so we have to manually define it here.
3131
//
3232
// ignore: non_constant_identifier_names
33-
void Function(Pointer<OSVERSIONINFOEX>) RtlGetVersion =
34-
DynamicLibrary.open('ntdll.dll').lookupFunction<
35-
Void Function(Pointer<OSVERSIONINFOEX>),
36-
void Function(Pointer<OSVERSIONINFOEX>)>('RtlGetVersion');
33+
void Function(Pointer<OSVERSIONINFOEX>) RtlGetVersion = DynamicLibrary.open(
34+
'ntdll.dll',
35+
).lookupFunction<
36+
Void Function(Pointer<OSVERSIONINFOEX>),
37+
void Function(Pointer<OSVERSIONINFOEX>)
38+
>('RtlGetVersion');
3739

3840
/// Returns a [WindowsDeviceInfo] with information about the device.
3941
@override
@@ -44,30 +46,36 @@ class DeviceInfoPlusWindowsPlugin extends DeviceInfoPlatform {
4446
@visibleForTesting
4547
WindowsDeviceInfo getInfo() {
4648
final systemInfo = calloc<SYSTEM_INFO>();
47-
final osVersionInfo = calloc<OSVERSIONINFOEX>()
48-
..ref.dwOSVersionInfoSize = sizeOf<OSVERSIONINFOEX>();
49+
final osVersionInfo =
50+
calloc<OSVERSIONINFOEX>()
51+
..ref.dwOSVersionInfoSize = sizeOf<OSVERSIONINFOEX>();
4952

5053
try {
51-
final currentVersionKey = Registry.openPath(RegistryHive.localMachine,
52-
path: r'SOFTWARE\Microsoft\Windows NT\CurrentVersion');
54+
final currentVersionKey = Registry.openPath(
55+
RegistryHive.localMachine,
56+
path: r'SOFTWARE\Microsoft\Windows NT\CurrentVersion',
57+
);
5358
final buildLab = currentVersionKey.getStringValue('BuildLab') ?? '';
5459
final buildLabEx = currentVersionKey.getStringValue('BuildLabEx') ?? '';
5560
final digitalProductId =
5661
currentVersionKey.getBinaryValue('DigitalProductId') ??
57-
Uint8List.fromList([]);
62+
Uint8List.fromList([]);
5863
final displayVersion =
5964
currentVersionKey.getStringValue('DisplayVersion') ?? '';
6065
final editionId = currentVersionKey.getStringValue('EditionID') ?? '';
6166
final installDate = DateTime.fromMillisecondsSinceEpoch(
62-
1000 * (currentVersionKey.getIntValue('InstallDate') ?? 0));
67+
1000 * (currentVersionKey.getIntValue('InstallDate') ?? 0),
68+
);
6369
final productId = currentVersionKey.getStringValue('ProductID') ?? '';
6470
var productName = currentVersionKey.getStringValue('ProductName') ?? '';
6571
final registeredOwner =
6672
currentVersionKey.getStringValue('RegisteredOwner') ?? '';
6773
final releaseId = currentVersionKey.getStringValue('ReleaseId') ?? '';
6874

69-
final sqmClientKey = Registry.openPath(RegistryHive.localMachine,
70-
path: r'SOFTWARE\Microsoft\SQMClient');
75+
final sqmClientKey = Registry.openPath(
76+
RegistryHive.localMachine,
77+
path: r'SOFTWARE\Microsoft\SQMClient',
78+
);
7179
final machineId = sqmClientKey.getStringValue('MachineId') ?? '';
7280

7381
GetSystemInfo(systemInfo);
@@ -140,8 +148,11 @@ class DeviceInfoPlusWindowsPlugin extends DeviceInfoPlatform {
140148
// Now allocate memory for a native string and call this a second time.
141149
final lpBuffer = wsalloc(nSize.value);
142150
try {
143-
final result =
144-
GetComputerNameEx(ComputerNameDnsFullyQualified, lpBuffer, nSize);
151+
final result = GetComputerNameEx(
152+
ComputerNameDnsFullyQualified,
153+
lpBuffer,
154+
nSize,
155+
);
145156

146157
if (result != 0) {
147158
return lpBuffer.toDartString();

packages/device_info_plus/device_info_plus/lib/src/model/android_device_info.dart

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ class AndroidDeviceInfo extends BaseDeviceInfo {
3838
required this.isLowRamDevice,
3939
required this.physicalRamSize,
4040
required this.availableRamSize,
41-
}) : supported32BitAbis = List<String>.unmodifiable(supported32BitAbis),
42-
supported64BitAbis = List<String>.unmodifiable(supported64BitAbis),
43-
supportedAbis = List<String>.unmodifiable(supportedAbis),
44-
systemFeatures = List<String>.unmodifiable(systemFeatures),
45-
super(data);
41+
}) : supported32BitAbis = List<String>.unmodifiable(supported32BitAbis),
42+
supported64BitAbis = List<String>.unmodifiable(supported64BitAbis),
43+
supportedAbis = List<String>.unmodifiable(supportedAbis),
44+
systemFeatures = List<String>.unmodifiable(systemFeatures),
45+
super(data);
4646

4747
/// Android operating system version values derived from `android.os.Build.VERSION`.
4848
final AndroidBuildVersion version;
@@ -175,7 +175,8 @@ class AndroidDeviceInfo extends BaseDeviceInfo {
175175
return AndroidDeviceInfo._(
176176
data: map,
177177
version: AndroidBuildVersion._fromMap(
178-
map['version']?.cast<String, dynamic>() ?? {}),
178+
map['version']?.cast<String, dynamic>() ?? {},
179+
),
179180
board: map['board'],
180181
bootloader: map['bootloader'],
181182
brand: map['brand'],

packages/device_info_plus/device_info_plus/lib/src/model/ios_device_info.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,9 @@ class IosDeviceInfo extends BaseDeviceInfo {
9999
physicalRamSize: map['physicalRamSize'],
100100
availableRamSize: map['availableRamSize'],
101101
isiOSAppOnMac: map['isiOSAppOnMac'],
102-
utsname:
103-
IosUtsname._fromMap(map['utsname']?.cast<String, dynamic>() ?? {}),
102+
utsname: IosUtsname._fromMap(
103+
map['utsname']?.cast<String, dynamic>() ?? {},
104+
),
104105
);
105106
}
106107

packages/device_info_plus/device_info_plus/pubspec.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,5 @@ dev_dependencies:
4949
test: ^1.25.15
5050

5151
environment:
52-
sdk: ">=3.4.0 <4.0.0"
53-
flutter: ">=3.22.0"
52+
sdk: ">=3.7.0 <4.0.0"
53+
flutter: ">=3.29.0"

packages/device_info_plus/device_info_plus/test/device_info_plus_web_test.dart

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,23 @@ import 'package:flutter_test/flutter_test.dart';
66

77
void main() {
88
test('WebBrowserInfo from Map with values', () {
9-
final info = WebBrowserInfo.fromMap(
10-
{
11-
'appCodeName': 'CODENAME',
12-
'appName': 'NAME',
13-
'appVersion': 'VERSION',
14-
'deviceMemory': 64,
15-
'language': 'en',
16-
'languages': ['en', 'es'],
17-
'platform': 'PLATFORM',
18-
'product': 'PRODUCT',
19-
'productSub': 'PRODUCTSUB',
20-
'userAgent':
21-
'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:61.0) Gecko/20100101 Firefox/61.0',
22-
'vendor': 'VENDOR',
23-
'vendorSub': 'VENDORSUB',
24-
'hardwareConcurrency': 1,
25-
'maxTouchPoints': 2,
26-
},
27-
);
9+
final info = WebBrowserInfo.fromMap({
10+
'appCodeName': 'CODENAME',
11+
'appName': 'NAME',
12+
'appVersion': 'VERSION',
13+
'deviceMemory': 64,
14+
'language': 'en',
15+
'languages': ['en', 'es'],
16+
'platform': 'PLATFORM',
17+
'product': 'PRODUCT',
18+
'productSub': 'PRODUCTSUB',
19+
'userAgent':
20+
'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:61.0) Gecko/20100101 Firefox/61.0',
21+
'vendor': 'VENDOR',
22+
'vendorSub': 'VENDORSUB',
23+
'hardwareConcurrency': 1,
24+
'maxTouchPoints': 2,
25+
});
2826

2927
expect(info.appName, 'NAME');
3028
expect(info.browserName, BrowserName.firefox);

packages/device_info_plus/device_info_plus/test/model/android_device_info_test.dart

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ part '../model/android_device_info_fake.dart';
88
void main() {
99
group('$AndroidDeviceInfo fromMap | toMap', () {
1010
test('fromMap should return $AndroidDeviceInfo with correct values', () {
11-
final androidDeviceInfo =
12-
AndroidDeviceInfo.fromMap(_fakeAndroidDeviceInfo);
11+
final androidDeviceInfo = AndroidDeviceInfo.fromMap(
12+
_fakeAndroidDeviceInfo,
13+
);
1314

1415
expect(androidDeviceInfo.id, 'id');
1516
expect(androidDeviceInfo.host, 'host');
@@ -47,8 +48,9 @@ void main() {
4748
});
4849

4950
test('toMap should return map with correct key and map', () {
50-
final androidDeviceInfo =
51-
AndroidDeviceInfo.fromMap(_fakeAndroidDeviceInfo);
51+
final androidDeviceInfo = AndroidDeviceInfo.fromMap(
52+
_fakeAndroidDeviceInfo,
53+
);
5254

5355
expect(androidDeviceInfo.data, _fakeAndroidDeviceInfo);
5456
});

0 commit comments

Comments
 (0)