useAsImageFromRepaintBoundary method
Future<WallpaperResult>
useAsImageFromRepaintBoundary(
- GlobalKey<
State< boundaryKey, {StatefulWidget> > - double pixelRatio = 2.5,
override
Shares / uses an image captured from a RepaintBoundary.
Implementation
@override
Future<WallpaperResult> useAsImageFromRepaintBoundary(
GlobalKey boundaryKey, {
double pixelRatio = 2.5,
}) async {
try {
final bytes = await _captureWidget(boundaryKey, pixelRatio);
if (bytes == null) {
return WallpaperResult.failure(
WallpaperError.invalidImage,
message: 'Could not capture the RepaintBoundary widget.',
);
}
return await _useAsImageBytes(bytes);
} catch (e) {
return WallpaperResult.failure(
WallpaperError.platformError,
message: 'Failed to use image: $e',
);
}
}