getRootElement method

Element? getRootElement(
  1. BuildContext buildContext
)

Implementation

Element? getRootElement(BuildContext buildContext) {
  Element? firstElement;
  if (ModalRoute.of(buildContext)?.isActive ?? false) {
    Navigator.of(buildContext, rootNavigator: true).context.visitChildElements((element) {
      firstElement = element;
    });
  } else {
    buildContext.visitChildElements((element) {
      firstElement = element;
    });
  }

  return firstElement;
}