WallPaper_FSX_Flutter/lib/common/plugin/set_wallpaper.dart
fengshengxiong 9f361ce560 1.集成firebase
2.优化功能
2024-05-23 18:22:18 +08:00

25 lines
775 B
Dart

// Author: fengshengxiong
// Date: 2024/5/17
// Description: 设置壁纸插件
import 'package:flutter/services.dart';
import 'package:hello_wallpaper/common/utils/log_print.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
});
LogPrint.d(result);
return result;
} on PlatformException catch (e) {
LogPrint.e('Failed to set wallpaper: ${e.message}.');
return 'Failed to set wallpaper: ${e.message}.';
}
}
}