setWallpaper method
Future<bool>
setWallpaper(
- GlobalKey<
State< boundaryKey,StatefulWidget> > - String target, {
- double pixelRatio = 2.5,
override
Implementation
@override
Future<bool> setWallpaper(
GlobalKey boundaryKey,
String target, {
double pixelRatio = 2.5,
}) async {
try {
final bytes = await _captureWidget(boundaryKey, pixelRatio);
if (bytes == null) return false;
final filePath = await _saveTempFile(bytes, 'wallpaper');
final bool success =
await methodChannel.invokeMethod('setWallpaper', {
'path': filePath,
'target': target,
}) ??
false;
// Cleanup
await File(filePath).delete().catchError((_) => File(filePath));
return success;
} on PlatformException catch (e) {
debugPrint('setWallpaper error: ${e.message}');
return false;
}
}