attachTo static method

OverlayEntry attachTo(
  1. BuildContext context, {
  2. bool rootOverlay = true,
  3. double bottom = _defaultPadding,
  4. double right = _defaultPadding,
  5. bool draggable = true,
})

Attach overlay to specified context.

Implementation

static OverlayEntry attachTo(
  BuildContext context, {
  bool rootOverlay = true,
  double bottom = _defaultPadding,
  double right = _defaultPadding,
  bool draggable = true,
}) {
  // create overlay entry
  final entry = OverlayEntry(
    builder: (context) => NetworkLoggerOverlay._(
      bottom: bottom,
      right: right,
      draggable: draggable,
    ),
  );
  // insert on next frame
  Future.delayed(Duration.zero, () {
    if (!context.mounted) return;
    Overlay.of(context, rootOverlay: rootOverlay).insert(entry);
  });
  // return
  return entry;
}