useAsImage method

  1. @override
Future<bool> useAsImage(
  1. GlobalKey<State<StatefulWidget>> boundaryKey, {
  2. double pixelRatio = 2.5,
})
override

Implementation

@override
Future<bool> useAsImage(
  GlobalKey boundaryKey, {
  double pixelRatio = 2.5,
}) async {
  try {
    final bytes = await _captureWidget(boundaryKey, pixelRatio);
    if (bytes == null) return false;

    final filePath = await _saveTempFile(bytes, 'use_as_temp');

    await methodChannel.invokeMethod('useAsImage', {'path': filePath});

    return true;
  } on PlatformException catch (e) {
    debugPrint('useAsImage error: ${e.message}');
    return false;
  }
}