After extracting ExpandableFab as a component and its parent setState() {}, ExpandableFab cannot trigger
debugger always
flutter: onClose
flutter: afterClose

part of 'index.dart';
class TestPage extends StatefulWidget {
const TestPage({super.key});
@override
State<TestPage> createState() => _TestPageState();
}
class _TestPageState extends State<TestPage> {
@override
Widget build(BuildContext context) {
return Scaffold(
floatingActionButtonLocation: ExpandableFab.location,
body: Stack(
children: [
Positioned(
top: 0,
bottom: 10,
right: 0,
left: 0,
child: ExpandMenu(
afterOpen: () {
setState(() {});
},
afterClose: () {
setState(() {});
},
),
),
],
),
);
}
}
class ExpandMenu extends StatefulWidget {
const ExpandMenu({
super.key,
this.afterClose,
this.afterOpen,
});
final VoidCallback? afterClose;
final VoidCallback? afterOpen;
@override
State<ExpandMenu> createState() => _ExpandMenuState();
}
class _ExpandMenuState extends State<ExpandMenu> {
final _key = GlobalKey<ExpandableFabState>();
@override
Widget build(BuildContext context) {
return ExpandableFab(
key: _key,
type: ExpandableFabType.side,
distance: 60,
duration: const Duration(milliseconds: 500),
initialOpen: true,
onClose: () {
print('onClose');
},
onOpen: () {
print('onOpen');
},
afterOpen: () {
print('afterOpen');
widget.afterOpen?.call();
},
afterClose: () {
print('afterClose');
widget.afterClose?.call();
},
openButtonBuilder: FloatingActionButtonBuilder(
size: 50,
builder: (BuildContext ctx, onPressed, Animation<double> progress) {
return Icon(Icons.menu);
},
),
closeButtonBuilder: FloatingActionButtonBuilder(
size: 50,
builder: (BuildContext ctx, onPressed, Animation<double> progress) {
return Icon(Icons.close);
},
),
openCloseStackAlignment: Alignment.topCenter,
children: List.generate(4, (idx) => Text('$idx')),
);
}
}
After extracting ExpandableFab as a component and its parent setState() {}, ExpandableFab cannot trigger
debugger always
flutter: onClose
flutter: afterClose