attachTo static method
OverlayEntry
attachTo(
- BuildContext context, {
- bool rootOverlay = true,
- double bottom = _defaultPadding,
- double right = _defaultPadding,
- bool draggable = true,
Attach overlay to specified context
. The FAB will be draggable unless
draggable
set to false
. Initial distance from the button to the screen
edge can be configured using bottom
and right
parameters.
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, () {
final overlay = Overlay.maybeOf(context, rootOverlay: rootOverlay);
if (overlay == null) {
throw FlutterError(
'FlutterNetworkLogger: No Overlay widget found. '
' The most common way to add an Overlay to an application is to include a MaterialApp or Navigator above widget that calls NetworkLoggerOverlay.attachTo()',
);
}
overlay.insert(entry);
});
// return
return entry;
}