WallPaper_FSX_Flutter/lib/common/plugin/set_wallpaper.dart
fengshengxiong 9caadfb09a 1.按照UI图修改
2.完善其他功能
2024-05-17 17:02:22 +08:00

24 lines
703 B
Dart

// Author: fengshengxiong
// Date: 2024/5/17
// Description: 设置壁纸插件
import 'package:flutter/services.dart';
class SetWallpaper {
static const MethodChannel _channel = MethodChannel('set_wallpaper');
static Future<String> setWallpaper(String path, int wallpaperType) async {
try {
final String result = await _channel.invokeMethod('setWallpaper', {
"path": path,
"wallpaperType": wallpaperType // 0 for home screen, 1 for lock screen, 2 for both
});
print(result);
return result;
} on PlatformException catch (e) {
print('Failed to set wallpaper: ${e.message}.');
return 'Failed to set wallpaper: ${e.message}.';
}
}
}