ente/lib/ui/components/keyboard/keybiard_oveylay.dart
2022-11-27 07:14:12 +05:30

33 lines
697 B
Dart

import 'package:flutter/widgets.dart';
class KeyboardOverlay {
static OverlayEntry? _overlayEntry;
static showOverlay(BuildContext context, Widget child) {
if (_overlayEntry != null) {
return;
}
final OverlayState? overlayState = Overlay.of(context);
_overlayEntry = OverlayEntry(
builder: (context) {
return Positioned(
bottom: MediaQuery.of(context).viewInsets.bottom,
right: 0.0,
left: 0.0,
child: child,
);
},
);
overlayState!.insert(_overlayEntry!);
}
static removeOverlay() {
if (_overlayEntry != null) {
_overlayEntry!.remove();
_overlayEntry = null;
}
}
}