addGlobalButton static method
添加全局按钮
context Returns void
Implementation
static void addGlobalButton(BuildContext? context) {
Future.delayed(const Duration(milliseconds: 10), () {
if (_currentGlobalButton == null && context != null) {
_isAddedGlobalButton = true;
OverlayState overlayState;
if (_currentOverlayState == null) {
overlayState = Overlay.of(context);
_currentOverlayState = overlayState;
} else {
overlayState = _currentOverlayState!;
}
_currentGlobalButton = OverlayEntry(
maintainState: true,
builder: (BuildContext context) => FnGlobalButton(
onPressed: () {
show(context);
}
),
);
overlayState.insert(_currentGlobalButton!);
}
});
}