widgetToIcon static method

Future<BitmapDescriptor> widgetToIcon(
  1. GlobalKey<State<StatefulWidget>> globalKey
)

Implementation

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