@@ -2,7 +2,7 @@ import 'package:macos_ui/macos_ui.dart';
22import 'package:macos_ui/src/library.dart' ;
33
44/// A button to show at the far right side of the toolbar.
5- class ToolbarOverflowButton extends StatelessWidget {
5+ class ToolbarOverflowButton extends StatefulWidget {
66 /// Builds a button to show at the far right side of the toolbar, when the
77 /// toolbar actions are overflowing the available horizontal space.
88 ///
@@ -20,12 +20,24 @@ class ToolbarOverflowButton extends StatelessWidget {
2020 /// Whether the icon button should be smaller in size (half the toolbar height).
2121 final bool isDense;
2222
23+ @override
24+ State <ToolbarOverflowButton > createState () => _ToolbarOverflowButtonState ();
25+ }
26+
27+ class _ToolbarOverflowButtonState extends State <ToolbarOverflowButton > {
28+ late final GlobalKey <ToolbarPopupState > popupKey;
29+
30+ @override
31+ void initState () {
32+ super .initState ();
33+ popupKey = GlobalKey <ToolbarPopupState >();
34+ }
35+
2336 @override
2437 Widget build (BuildContext context) {
25- final popupKey = GlobalKey <ToolbarPopupState >();
2638 return ToolbarPopup (
2739 key: popupKey,
28- content: overflowContentBuilder,
40+ content: widget. overflowContentBuilder,
2941 verticalOffset: 8.0 ,
3042 horizontalOffset: 10.0 ,
3143 position: ToolbarPopupPosition .below,
@@ -38,7 +50,7 @@ class ToolbarOverflowButton extends StatelessWidget {
3850 onPressed: () {
3951 popupKey.currentState? .openPopup ();
4052 },
41- showLabel: isDense,
53+ showLabel: widget. isDense,
4254 ).build (context, ToolbarItemDisplayMode .inToolbar),
4355 );
4456 }
0 commit comments