Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -155,35 +155,35 @@ class _MyAppState extends State<MyApp> {
),
body: Column(
children: <Widget>[
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,
),
Expand Down
40 changes: 20 additions & 20 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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"
26 changes: 13 additions & 13 deletions lib/wallpaper_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -17,9 +17,9 @@ class WallpaperManager {
static const int BOTH_SCREENS = 3;

/// Function to check working/validity of method channels
static Future<String> get platformVersion async {
static Future<String?> 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;
Expand All @@ -29,18 +29,18 @@ class WallpaperManager {
static Future<String> 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<int>);

/// 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<String> 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 {
Expand All @@ -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<String> 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<int>);

/// 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<String> 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 {
Expand All @@ -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.';
}
}
Loading