findRenderObject static method
Safely call findRenderObject method.
Implementation
static RenderObject? findRenderObject(BuildContext? context) {
bool isMounted = context?.mounted ?? false;
if (!isMounted) {
return null;
}
try {
// It throws an exception when getting renderObject of inactive element.
return context?.findRenderObject();
} catch (e) {
Log.warning('Cannot get renderObject of inactive element.\n'
'Please call the reattach method of ObserverController to re-record '
'BuildContext.');
return null;
}
}