Feat: Schließt den FloatingCreationButton beim Anklicken einer Option wieder.

This commit is contained in:
2025-12-28 02:24:30 +01:00
parent 7a2abc84cb
commit 93d4d7a854

View File

@@ -15,9 +15,11 @@ class FloatingCreationButton extends StatefulWidget {
class _FloatingCreationButtonState extends State<FloatingCreationButton> { class _FloatingCreationButtonState extends State<FloatingCreationButton> {
final AccountController _accountController = AccountController(); final AccountController _accountController = AccountController();
final _key = GlobalKey<ExpandableFabState>();
@override @override
Widget build(final BuildContext context) => ExpandableFab( Widget build(final BuildContext context) => ExpandableFab(
key: _key,
openButtonBuilder: RotateFloatingActionButtonBuilder( openButtonBuilder: RotateFloatingActionButtonBuilder(
child: const Icon(Icons.add), child: const Icon(Icons.add),
), ),
@@ -54,7 +56,14 @@ class _FloatingCreationButtonState extends State<FloatingCreationButton> {
const SizedBox(width: 12), const SizedBox(width: 12),
FloatingActionButton.small( FloatingActionButton.small(
heroTag: null, heroTag: null,
onPressed: onPressed, onPressed: () {
onPressed.call();
final ExpandableFabState? state = _key.currentState;
if (state != null && state.isOpen) {
state.close();
}
},
child: Icon(icon), child: Icon(icon),
), ),
], ],