widgetToIcon static method

Future<BitmapDescriptor> widgetToIcon(
  1. GlobalKey<State<StatefulWidget>> globalKey, {
  2. Size? size,
})

Implementation

static Future<BitmapDescriptor> widgetToIcon(GlobalKey globalKey,
    {Size? size}) async {
  RenderRepaintBoundary boundary =
      globalKey.currentContext?.findRenderObject() as RenderRepaintBoundary;
  ui.Image image = await boundary.toImage(pixelRatio: 3.0);
  ByteData? byteData = await image.toByteData(format: ui.ImageByteFormat.png);
  return BitmapDescriptor.fromBytes(
    byteData!.buffer.asUint8List(),
    size: size,
  );
}