I have a custom widget class which I need to render it into a bitmap icon using BitmapDescriptor, so I need to define it's GlobalKey.
GlobalKey<TheWidgetState> globalkey = GlobalKey<TheWidgetState>();
@override
Widget build(BuildContext context) {... TheWidget(globalkey) ...}
...
//Somewhere. Has nothing to do with the issue
BitmapDescriptor.fromBytes((await (await (globalkey.currentContext?.findRenderObject() as RenderRepaintBoundary).toImage()).toByteData(format: ui.ImageByteFormat.png))!.buffer.asUint8List());
...
Before doing that, I also need to update the state of the widget before render it like in above code, without changing it's position on the tree. So I also need to define it's ValueKey to do that.
I'm still confused about the purpose of every other key types in Flutter. But as for now I need both the purpose of GlobalKey and ValueKey for my widget. Since both need to be defined with variable name key, I have neither an idea on how to set the widget with both keys nor an answer which key serve both purposes that I need.
Greatly appreciate the help.