aboutsummaryrefslogtreecommitdiff
path: root/lib/services/wallpaper_service.dart
diff options
context:
space:
mode:
Diffstat (limited to 'lib/services/wallpaper_service.dart')
-rw-r--r--lib/services/wallpaper_service.dart22
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/services/wallpaper_service.dart b/lib/services/wallpaper_service.dart
new file mode 100644
index 0000000..b753640
--- /dev/null
+++ b/lib/services/wallpaper_service.dart
@@ -0,0 +1,22 @@
+import 'package:aves/services/common/services.dart';
+import 'package:aves_model/aves_model.dart';
+import 'package:flutter/services.dart';
+import 'package:aves/services/common/channel.dart';
+
+class WallpaperService {
+ static const _platform = AvesMethodChannel('deckers.thibault/aves/wallpaper');
+
+ static Future<bool> set(Uint8List bytes, WallpaperTarget target) async {
+ try {
+ await _platform.invokeMethod('setWallpaper', <String, dynamic>{
+ 'bytes': bytes,
+ 'home': {WallpaperTarget.home, WallpaperTarget.homeLock}.contains(target),
+ 'lock': {WallpaperTarget.lock, WallpaperTarget.homeLock}.contains(target),
+ });
+ return true;
+ } on PlatformException catch (e, stack) {
+ await reportService.recordError(e, stack);
+ }
+ return false;
+ }
+}