diff --git a/example/lib/main.dart b/example/lib/main.dart index b257600..ce41117 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -155,35 +155,35 @@ class _MyAppState extends State { ), body: Column( children: [ - RaisedButton( + ElevatedButton( child: Text("Platform Version"), onPressed: initPlatformState, ), Center( child: Text('Running on: $_platformVersion\n'), ), - RaisedButton( + ElevatedButton( child: Text("Set wallpaper from file"), onPressed: setWallpaperFromFile, ), Center( child: Text('Wallpaper status: $_wallpaperFile\n'), ), - RaisedButton( + ElevatedButton( child: Text("Set wallpaper from file with crop"), onPressed: setWallpaperFromFileWithCrop, ), Center( child: Text('Wallpaper status: $_wallpaperFileWithCrop\n'), ), - RaisedButton( + ElevatedButton( child: Text("Set wallpaper from asset"), onPressed: setWallpaperFromAsset, ), Center( child: Text('Wallpaper status: $_wallpaperAsset\n'), ), - RaisedButton( + ElevatedButton( child: Text("Set wallpaper from asset with crop"), onPressed: setWallpaperFromAssetWithCrop, ), diff --git a/example/pubspec.lock b/example/pubspec.lock index 68403bd..9b47d50 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -7,42 +7,42 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.4.1" + version: "2.6.1" boolean_selector: dependency: transitive description: name: boolean_selector url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.1.0" characters: dependency: transitive description: name: characters url: "https://pub.dartlang.org" source: hosted - version: "1.0.0" + version: "1.1.0" charcode: dependency: transitive description: name: charcode url: "https://pub.dartlang.org" source: hosted - version: "1.1.3" + version: "1.2.0" clock: dependency: transitive description: name: clock url: "https://pub.dartlang.org" source: hosted - version: "1.0.1" + version: "1.1.0" collection: dependency: transitive description: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.14.13" + version: "1.15.0" convert: dependency: transitive description: @@ -70,7 +70,7 @@ packages: name: fake_async url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.2.0" flutter: dependency: "direct main" description: flutter @@ -108,21 +108,21 @@ packages: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.8" + version: "0.12.10" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.1.8" + version: "1.3.0" path: dependency: transitive description: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.7.0" + version: "1.8.0" path_provider: dependency: transitive description: @@ -155,7 +155,7 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.7.0" + version: "1.8.1" sqflite: dependency: transitive description: @@ -169,21 +169,21 @@ packages: name: stack_trace url: "https://pub.dartlang.org" source: hosted - version: "1.9.3" + version: "1.10.0" stream_channel: dependency: transitive description: name: stream_channel url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.1.0" string_scanner: dependency: transitive description: name: string_scanner url: "https://pub.dartlang.org" source: hosted - version: "1.0.5" + version: "1.1.0" synchronized: dependency: transitive description: @@ -197,21 +197,21 @@ packages: name: term_glyph url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.2.0" test_api: dependency: transitive description: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.17" + version: "0.3.0" typed_data: dependency: transitive description: name: typed_data url: "https://pub.dartlang.org" source: hosted - version: "1.1.6" + version: "1.3.0" uuid: dependency: transitive description: @@ -225,7 +225,7 @@ packages: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.0.8" + version: "2.1.0" wallpaper_manager: dependency: "direct dev" description: @@ -234,5 +234,5 @@ packages: source: path version: "1.0.10" sdks: - dart: ">=2.9.0-14.0.dev <3.0.0" - flutter: ">=1.10.1 <2.0.0" + dart: ">=2.12.0 <3.0.0" + flutter: ">=1.10.1" diff --git a/lib/wallpaper_manager.dart b/lib/wallpaper_manager.dart index 1b88f0d..8694024 100644 --- a/lib/wallpaper_manager.dart +++ b/lib/wallpaper_manager.dart @@ -5,7 +5,7 @@ import 'package:flutter/services.dart'; class WallpaperManager { /// Define channel static const MethodChannel _channel = - const MethodChannel('wallpaper_manager'); + MethodChannel('wallpaper_manager'); /// Static code for Home Screen Wallpaper Choice static const int HOME_SCREEN = 1; @@ -17,9 +17,9 @@ class WallpaperManager { static const int BOTH_SCREENS = 3; /// Function to check working/validity of method channels - static Future get platformVersion async { + static Future get platformVersion async { /// String to store the version number before returning. This is just to test working/validity. - final String version = await _channel.invokeMethod('getPlatformVersion'); + final String? version = await _channel.invokeMethod('getPlatformVersion'); /// Function returns version number return version; @@ -29,18 +29,18 @@ class WallpaperManager { static Future setWallpaperFromFile( String filePath, int wallpaperLocation) async { /// Variable to store operation result - final int result = await _channel.invokeMethod('setWallpaperFromFile', - {'filePath': filePath, 'wallpaperLocation': wallpaperLocation}); + final int result = await (_channel.invokeMethod('setWallpaperFromFile', + {'filePath': filePath, 'wallpaperLocation': wallpaperLocation}) as FutureOr); /// Function returns the set String as result, use for debugging - return result > 0 ? "Wallpaper set" : "There was an error."; + return result > 0 ? 'Wallpaper set' : 'There was an error.'; } /// Function takes input file's path & location choice static Future setWallpaperFromFileWithCrop(String filePath, int wallpaperLocation, int left, int top, int right, int bottom) async { /// Variable to store operation result - int result; + int? result; if (left > right || top > bottom) { result = 0; } else { @@ -55,25 +55,25 @@ class WallpaperManager { } /// Function returns the set String as result, use for debugging - return result > 0 ? "Wallpaper set" : "There was an error."; + return result! > 0 ? 'Wallpaper set' : 'There was an error.'; } /// Function takes input file's asset (Dart/Flutter; pre-indexed in pubspec.yaml) & location choice static Future setWallpaperFromAsset( String assetPath, int wallpaperLocation) async { /// Variable to store operation result - final int result = await _channel.invokeMethod('setWallpaperFromAsset', - {'assetPath': assetPath, 'wallpaperLocation': wallpaperLocation}); + final int result = await (_channel.invokeMethod('setWallpaperFromAsset', + {'assetPath': assetPath, 'wallpaperLocation': wallpaperLocation}) as FutureOr); /// Function returns the set String as result, use for debugging - return result > 0 ? "Wallpaper set" : "There was an error."; + return result > 0 ? 'Wallpaper set' : 'There was an error.'; } /// Function takes input file's asset (Dart/Flutter; pre-indexed in pubspec.yaml) & location choice static Future setWallpaperFromAssetWithCrop(String assetPath, int wallpaperLocation, int left, int top, int right, int bottom) async { /// Variable to store operation result - int result; + int? result; if (left > right || top > bottom || left < 0 || top < 0) { result = 0; } else { @@ -88,6 +88,6 @@ class WallpaperManager { } /// Function returns the set String as result, use for debugging - return result > 0 ? "Wallpaper set" : "There was an error."; + return result! > 0 ? 'Wallpaper set' : 'There was an error.'; } } diff --git a/pubspec.lock b/pubspec.lock index e5d89a7..a861f54 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -7,49 +7,49 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.4.1" + version: "2.6.1" boolean_selector: dependency: transitive description: name: boolean_selector url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.1.0" characters: dependency: transitive description: name: characters url: "https://pub.dartlang.org" source: hosted - version: "1.0.0" + version: "1.1.0" charcode: dependency: transitive description: name: charcode url: "https://pub.dartlang.org" source: hosted - version: "1.1.3" + version: "1.2.0" clock: dependency: transitive description: name: clock url: "https://pub.dartlang.org" source: hosted - version: "1.0.1" + version: "1.1.0" collection: dependency: transitive description: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.14.13" + version: "1.15.0" fake_async: dependency: transitive description: name: fake_async url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.2.0" flutter: dependency: "direct main" description: flutter @@ -66,28 +66,28 @@ packages: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.8" + version: "0.12.10" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.1.8" + version: "1.3.0" path: dependency: transitive description: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.7.0" + version: "1.8.0" pedantic: dependency: "direct dev" description: name: pedantic url: "https://pub.dartlang.org" source: hosted - version: "1.8.0+1" + version: "1.11.1" sky_engine: dependency: transitive description: flutter @@ -99,55 +99,55 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.7.0" + version: "1.8.1" stack_trace: dependency: transitive description: name: stack_trace url: "https://pub.dartlang.org" source: hosted - version: "1.9.3" + version: "1.10.0" stream_channel: dependency: transitive description: name: stream_channel url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.1.0" string_scanner: dependency: transitive description: name: string_scanner url: "https://pub.dartlang.org" source: hosted - version: "1.0.5" + version: "1.1.0" term_glyph: dependency: transitive description: name: term_glyph url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.2.0" test_api: dependency: transitive description: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.17" + version: "0.3.0" typed_data: dependency: transitive description: name: typed_data url: "https://pub.dartlang.org" source: hosted - version: "1.1.6" + version: "1.3.0" vector_math: dependency: transitive description: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.0.8" + version: "2.1.0" sdks: - dart: ">=2.9.0-14.0.dev <3.0.0" + dart: ">=2.12.0 <3.0.0" diff --git a/pubspec.yaml b/pubspec.yaml index 264cc7f..8897b4e 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -4,7 +4,7 @@ version: 1.0.10 homepage: https://github.com/AdityaMulgundkar/wallpaper_manager environment: - sdk: ">=2.1.0 <3.0.0" + sdk: '>=2.12.0 <3.0.0' dependencies: flutter: @@ -13,7 +13,7 @@ dependencies: dev_dependencies: flutter_test: sdk: flutter - pedantic: 1.8.0+1 + pedantic: ^1.11.1 # For information on the generic Dart part of this file, see the # following page: https://dart.dev/tools/pub/pubspec