diff --git a/packages/device_info_plus/device_info_plus/README.md b/packages/device_info_plus/device_info_plus/README.md index 4654e6adc6..48f3e9b542 100644 --- a/packages/device_info_plus/device_info_plus/README.md +++ b/packages/device_info_plus/device_info_plus/README.md @@ -20,10 +20,10 @@ Get current device information from within the Flutter application. - Dart >=3.7.0 <4.0.0 - iOS >=12.0 - macOS >=10.14 -- Android `compileSDK` 34 - Java 17 -- Android Gradle Plugin >=8.3.0 -- Gradle wrapper >=8.4 +- Kotlin 2.2.0 +- Android Gradle Plugin >=8.12.1 +- Gradle wrapper >=8.13 # Usage diff --git a/packages/device_info_plus/device_info_plus/android/build.gradle b/packages/device_info_plus/device_info_plus/android/build.gradle index 5213cd0a10..79a345a487 100644 --- a/packages/device_info_plus/device_info_plus/android/build.gradle +++ b/packages/device_info_plus/device_info_plus/android/build.gradle @@ -2,14 +2,14 @@ group 'dev.fluttercommunity.plus.device_info' version '1.0-SNAPSHOT' buildscript { - ext.kotlin_version = '1.7.22' + ext.kotlin_version = '2.2.0' repositories { google() mavenCentral() } dependencies { - classpath 'com.android.tools.build:gradle:8.3.1' + classpath 'com.android.tools.build:gradle:8.12.1' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } @@ -25,9 +25,8 @@ apply plugin: 'com.android.library' apply plugin: 'kotlin-android' android { - compileSdk 34 - namespace 'dev.fluttercommunity.plus.device_info' + compileSdk = flutter.compileSdkVersion compileOptions { sourceCompatibility JavaVersion.VERSION_17 diff --git a/packages/device_info_plus/device_info_plus/android/gradle/wrapper/gradle-wrapper.properties b/packages/device_info_plus/device_info_plus/android/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index e411586a54..0000000000 --- a/packages/device_info_plus/device_info_plus/android/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,5 +0,0 @@ -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists diff --git a/packages/device_info_plus/device_info_plus/example/android/app/build.gradle b/packages/device_info_plus/device_info_plus/example/android/app/build.gradle index 1e70360c4e..c6e51e660d 100644 --- a/packages/device_info_plus/device_info_plus/example/android/app/build.gradle +++ b/packages/device_info_plus/device_info_plus/example/android/app/build.gradle @@ -23,9 +23,8 @@ if (flutterVersionName == null) { } android { - compileSdk 34 - namespace 'io.flutter.plugins.deviceinfoexample.example' + compileSdk = flutter.compileSdkVersion compileOptions { sourceCompatibility JavaVersion.VERSION_17 @@ -46,8 +45,8 @@ android { defaultConfig { applicationId "io.flutter.plugins.deviceinfoexample.example" - minSdk 21 - targetSdk 34 + minSdk flutter.minSdkVersion + targetSdk flutter.targetSdkVersion versionCode flutterVersionCode.toInteger() versionName flutterVersionName } diff --git a/packages/device_info_plus/device_info_plus/example/android/gradle/wrapper/gradle-wrapper.properties b/packages/device_info_plus/device_info_plus/example/android/gradle/wrapper/gradle-wrapper.properties index 448814c79e..f3dd2fa1bd 100644 --- a/packages/device_info_plus/device_info_plus/example/android/gradle/wrapper/gradle-wrapper.properties +++ b/packages/device_info_plus/device_info_plus/example/android/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ #Tue Oct 05 15:15:38 CEST 2021 distributionBase=GRADLE_USER_HOME -distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip distributionPath=wrapper/dists zipStorePath=wrapper/dists zipStoreBase=GRADLE_USER_HOME diff --git a/packages/device_info_plus/device_info_plus/example/android/settings.gradle b/packages/device_info_plus/device_info_plus/example/android/settings.gradle index fa3b4d0878..f1c2904d82 100644 --- a/packages/device_info_plus/device_info_plus/example/android/settings.gradle +++ b/packages/device_info_plus/device_info_plus/example/android/settings.gradle @@ -18,8 +18,8 @@ pluginManagement { plugins { id "dev.flutter.flutter-plugin-loader" version "1.0.0" - id "com.android.application" version "8.3.1" apply false - id "org.jetbrains.kotlin.android" version "1.9.23" apply false + id "com.android.application" version "8.12.1" apply false + id "org.jetbrains.kotlin.android" version "2.2.0" apply false } include ":app" diff --git a/packages/device_info_plus/device_info_plus/example/integration_test/device_info_plus_test.dart b/packages/device_info_plus/device_info_plus/example/integration_test/device_info_plus_test.dart index 2cb0a98006..2ce1dc17eb 100644 --- a/packages/device_info_plus/device_info_plus/example/integration_test/device_info_plus_test.dart +++ b/packages/device_info_plus/device_info_plus/example/integration_test/device_info_plus_test.dart @@ -65,8 +65,9 @@ void main() { } }); - testWidgets('Can get non-null iOS utsname fields', - (WidgetTester tester) async { + testWidgets('Can get non-null iOS utsname fields', ( + WidgetTester tester, + ) async { expect(iosInfo.utsname.machine, isNotNull); expect(iosInfo.utsname.nodename, isNotNull); expect(iosInfo.utsname.release, isNotNull); @@ -74,8 +75,9 @@ void main() { expect(iosInfo.utsname.version, isNotNull); }, skip: !Platform.isIOS); - testWidgets('Check all android info values are available', - (WidgetTester tester) async { + testWidgets('Check all android info values are available', ( + WidgetTester tester, + ) async { if (androidInfo.version.sdkInt >= 23) { expect(androidInfo.version.baseOS, isNotNull); expect(androidInfo.version.previewSdkInt, isNotNull); @@ -112,8 +114,9 @@ void main() { expect(androidInfo.serialNumber, isNotNull); }, skip: !Platform.isAndroid); - testWidgets('Check all macos info values are available', - ((WidgetTester tester) async { + testWidgets('Check all macos info values are available', (( + WidgetTester tester, + ) async { expect(macosInfo.computerName, isNotNull); expect(macosInfo.hostName, isNotNull); expect(macosInfo.arch, isNotNull); @@ -127,8 +130,9 @@ void main() { expect(macosInfo.systemGUID, isNotNull); }), skip: !Platform.isMacOS); - testWidgets('Check all Linux info values are available', - ((WidgetTester tester) async { + testWidgets('Check all Linux info values are available', (( + WidgetTester tester, + ) async { expect(linuxInfo.name, isNotNull); expect(linuxInfo.version, isNotNull); expect(linuxInfo.id, isNotNull); @@ -141,96 +145,43 @@ void main() { expect(linuxInfo.variantId, isNull); }), skip: !Platform.isLinux); - testWidgets('Check all Windows info values are available', - ((WidgetTester tester) async { - expect( - windowsInfo.numberOfCores, - isPositive, - ); - expect( - windowsInfo.computerName, - isNotEmpty, - ); - expect( - windowsInfo.systemMemoryInMegabytes, - isPositive, - ); - expect( - windowsInfo.userName, - isNotEmpty, - ); - expect( - windowsInfo.majorVersion, - equals(10), - ); - expect( - windowsInfo.minorVersion, - equals(0), - ); - expect( - windowsInfo.buildNumber, - greaterThan(10240), - ); - expect( - windowsInfo.platformId, - equals(2), - ); - expect( - windowsInfo.reserved, - isZero, - ); - expect( - windowsInfo.buildLab, - isNotEmpty, - ); + testWidgets('Check all Windows info values are available', (( + WidgetTester tester, + ) async { + expect(windowsInfo.numberOfCores, isPositive); + expect(windowsInfo.computerName, isNotEmpty); + expect(windowsInfo.systemMemoryInMegabytes, isPositive); + expect(windowsInfo.userName, isNotEmpty); + expect(windowsInfo.majorVersion, equals(10)); + expect(windowsInfo.minorVersion, equals(0)); + expect(windowsInfo.buildNumber, greaterThan(10240)); + expect(windowsInfo.platformId, equals(2)); + expect(windowsInfo.reserved, isZero); + expect(windowsInfo.buildLab, isNotEmpty); expect( windowsInfo.buildLab, - startsWith( - windowsInfo.buildNumber.toString(), - ), - ); - expect( - windowsInfo.buildLabEx, - isNotEmpty, + startsWith(windowsInfo.buildNumber.toString()), ); + expect(windowsInfo.buildLabEx, isNotEmpty); expect( windowsInfo.buildLab, startsWith(windowsInfo.buildNumber.toString()), ); + expect(windowsInfo.digitalProductId, isNotEmpty); + expect(windowsInfo.editionId, isNotEmpty); + expect(windowsInfo.productId, isNotEmpty); expect( - windowsInfo.digitalProductId, - isNotEmpty, - ); - expect( - windowsInfo.editionId, - isNotEmpty, - ); - expect( - windowsInfo.productId, - isNotEmpty, - ); - expect( - RegExp(r'^([A-Z0-9]{5}-){4}[A-Z0-9]{5}$') - .hasMatch(windowsInfo.productId) || - RegExp(r'^([A-Z0-9]{5}-){3}[A-Z0-9]{5}$') - .hasMatch(windowsInfo.productId), + RegExp( + r'^([A-Z0-9]{5}-){4}[A-Z0-9]{5}$', + ).hasMatch(windowsInfo.productId) || + RegExp( + r'^([A-Z0-9]{5}-){3}[A-Z0-9]{5}$', + ).hasMatch(windowsInfo.productId), isTrue, ); - expect( - windowsInfo.productName, - isNotEmpty, - ); - expect( - windowsInfo.productName, - startsWith('Windows'), - ); - expect( - windowsInfo.releaseId, - isNotEmpty, - ); - expect( - windowsInfo.deviceId, - isNotEmpty, - ); + expect(windowsInfo.productName, isNotEmpty); + expect(windowsInfo.productName, startsWith('Windows')); + expect(windowsInfo.releaseId, isNotEmpty); + expect(windowsInfo.deviceId, isNotEmpty); }), skip: !Platform.isWindows); } diff --git a/packages/device_info_plus/device_info_plus/example/lib/main.dart b/packages/device_info_plus/device_info_plus/example/lib/main.dart index 89004e302c..fcd3b4d221 100644 --- a/packages/device_info_plus/device_info_plus/example/lib/main.dart +++ b/packages/device_info_plus/device_info_plus/example/lib/main.dart @@ -13,11 +13,14 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; void main() { - runZonedGuarded(() { - runApp(const MyApp()); - }, (dynamic error, dynamic stack) { - developer.log("Something went wrong!", error: error, stackTrace: stack); - }); + runZonedGuarded( + () { + runApp(const MyApp()); + }, + (dynamic error, dynamic stack) { + developer.log("Something went wrong!", error: error, stackTrace: stack); + }, + ); } class MyApp extends StatefulWidget { @@ -45,24 +48,29 @@ class _MyAppState extends State { deviceData = _readWebBrowserInfo(await deviceInfoPlugin.webBrowserInfo); } else { deviceData = switch (defaultTargetPlatform) { - TargetPlatform.android => - _readAndroidBuildData(await deviceInfoPlugin.androidInfo), - TargetPlatform.iOS => - _readIosDeviceInfo(await deviceInfoPlugin.iosInfo), - TargetPlatform.linux => - _readLinuxDeviceInfo(await deviceInfoPlugin.linuxInfo), - TargetPlatform.windows => - _readWindowsDeviceInfo(await deviceInfoPlugin.windowsInfo), - TargetPlatform.macOS => - _readMacOsDeviceInfo(await deviceInfoPlugin.macOsInfo), + TargetPlatform.android => _readAndroidBuildData( + await deviceInfoPlugin.androidInfo, + ), + TargetPlatform.iOS => _readIosDeviceInfo( + await deviceInfoPlugin.iosInfo, + ), + TargetPlatform.linux => _readLinuxDeviceInfo( + await deviceInfoPlugin.linuxInfo, + ), + TargetPlatform.windows => _readWindowsDeviceInfo( + await deviceInfoPlugin.windowsInfo, + ), + TargetPlatform.macOS => _readMacOsDeviceInfo( + await deviceInfoPlugin.macOsInfo, + ), TargetPlatform.fuchsia => { - 'Error:': 'Fuchsia platform isn\'t supported' - }, + 'Error:': 'Fuchsia platform isn\'t supported', + }, }; } } on PlatformException { deviceData = { - 'Error:': 'Failed to get platform version.' + 'Error:': 'Failed to get platform version.', }; } @@ -227,51 +235,46 @@ class _MyAppState extends State { colorSchemeSeed: const Color(0x9f4376f8), ), home: Scaffold( - appBar: AppBar( - title: Text(_getAppBarTitle()), - elevation: 4, - ), + appBar: AppBar(title: Text(_getAppBarTitle()), elevation: 4), body: ListView( - children: _deviceData.keys.map( - (String property) { - return Row( - children: [ - Container( - padding: const EdgeInsets.all(10), - child: Text( - property, - style: const TextStyle( - fontWeight: FontWeight.bold, + children: + _deviceData.keys.map((String property) { + return Row( + children: [ + Container( + padding: const EdgeInsets.all(10), + child: Text( + property, + style: const TextStyle(fontWeight: FontWeight.bold), ), ), - ), - Expanded( - child: Container( - padding: const EdgeInsets.symmetric(vertical: 10), - child: Text( - '${_deviceData[property]}', - maxLines: 10, - overflow: TextOverflow.ellipsis, + Expanded( + child: Container( + padding: const EdgeInsets.symmetric(vertical: 10), + child: Text( + '${_deviceData[property]}', + maxLines: 10, + overflow: TextOverflow.ellipsis, + ), ), ), - ), - ], - ); - }, - ).toList(), + ], + ); + }).toList(), ), ), ); } - String _getAppBarTitle() => kIsWeb - ? 'Web Browser info' - : switch (defaultTargetPlatform) { - TargetPlatform.android => 'Android Device Info', - TargetPlatform.iOS => 'iOS Device Info', - TargetPlatform.linux => 'Linux Device Info', - TargetPlatform.windows => 'Windows Device Info', - TargetPlatform.macOS => 'MacOS Device Info', - TargetPlatform.fuchsia => 'Fuchsia Device Info', - }; + String _getAppBarTitle() => + kIsWeb + ? 'Web Browser info' + : switch (defaultTargetPlatform) { + TargetPlatform.android => 'Android Device Info', + TargetPlatform.iOS => 'iOS Device Info', + TargetPlatform.linux => 'Linux Device Info', + TargetPlatform.windows => 'Windows Device Info', + TargetPlatform.macOS => 'MacOS Device Info', + TargetPlatform.fuchsia => 'Fuchsia Device Info', + }; } diff --git a/packages/device_info_plus/device_info_plus/example/pubspec.yaml b/packages/device_info_plus/device_info_plus/example/pubspec.yaml index d318ba9c76..fba8fd6db0 100644 --- a/packages/device_info_plus/device_info_plus/example/pubspec.yaml +++ b/packages/device_info_plus/device_info_plus/example/pubspec.yaml @@ -19,7 +19,7 @@ flutter: uses-material-design: true environment: - sdk: '>=3.4.0 <4.0.0' - flutter: '>=3.22.0' + sdk: '>=3.7.0 <4.0.0' + flutter: '>=3.29.0'