overlayment
overlayment copied to clipboard
Sometime error and can't do anything to close
hi, thanks for your work, this flexible and awesome package..
i have problem, so currently i play in desktop app.
so i use this package to open some OverPanel
using shortcut, when i spam the shortcut key, i got some error like this
[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: LateInitializationError: Field 'overlayAnimation' has not been initialized.
sample code:
class SomeView extends StatelessWidget {
const SomeView({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
body: CallbackShortcuts(
bindings: {
const SingleActivator(LogicalKeyboardKey.keyI): () async => await openPanelInfo(),
},
child: Focus(
autofocus: true,
focusNode: FocusNode(canRequestFocus: true),
child: VStack([
///...
]),
),
),
);
}
}
Future<void> openPanelInfo() async {
//....
await Overlayment.show(
context: context,
OverPanel(
actions: OverlayActions(
onOpen: () async {
try {
if (Overlayment.count > 1) await Overlayment.dismissAll();
} catch (_) {
await Overlayment.dismissAll();
}
},
),
alignment: Alignment.centerRight,
child:
///...
),
);
}