showDebugger method

void showDebugger(
  1. BuildContext context
)

显示浮窗

Implementation

void showDebugger(BuildContext context) async {
  if (_appContext == null) {
    _appContext = context;
    //find root context
    context.visitAncestorElements((element) {
      if (element.depth == 1) {
        _appContext = element;
        return false;
      }
      return true;
    });
    if (!appContext.isCompleted) {
      appContext.complete(_appContext);
    }
  }

  _debuggerOverlay?.remove();
  _debuggerOverlay = new OverlayEntry(
    builder: (context) {
      return FloatingButtonWidget();
    },
  );
  OverlayState? rootOverlay = await findRootOverlay();
  rootOverlay?.insert(_debuggerOverlay!);
}