@@ -68,8 +68,7 @@ class BottomNavPageGroup extends StatefulWidget {
68
68
69
69
class _BottomNavPageGroupState extends State <BottomNavPageGroup > {
70
70
late List <MenuItem > menuItems;
71
- Widget ? fab;
72
- FloatingAlignment floatingAlignment = FloatingAlignment .none;
71
+ FloatingAlignment floatingAlignment = FloatingAlignment .center;
73
72
int ? floatingMargin;
74
73
MenuItem ? fabMenuItem;
75
74
@@ -88,9 +87,13 @@ class _BottomNavPageGroupState extends State<BottomNavPageGroup> {
88
87
if (fabItems.isNotEmpty) {
89
88
fabMenuItem = fabItems.first;
90
89
}
90
+ if (fabMenuItem != null && fabMenuItem? .floatingAlignment != null ) {
91
+ floatingAlignment =
92
+ FloatingAlignment .values.byName (fabMenuItem! .floatingAlignment);
93
+ }
91
94
}
92
95
93
- void _floatingButton () {
96
+ Widget ? _buildFloatingButton () {
94
97
if (fabMenuItem != null ) {
95
98
floatingMargin = fabMenuItem! .floatingMargin;
96
99
final dynamic customIcon = _buildCustomIcon (fabMenuItem! );
@@ -102,7 +105,7 @@ class _BottomNavPageGroupState extends State<BottomNavPageGroup> {
102
105
Utils .getColor (widget.menu.styles? ['floatingBackgroundColor' ]) ??
103
106
Theme .of (context).colorScheme.secondary;
104
107
105
- fab = Theme (
108
+ return Theme (
106
109
data: ThemeData (useMaterial3: false ),
107
110
child: customIcon ??
108
111
FloatingActionButton (
@@ -115,11 +118,8 @@ class _BottomNavPageGroupState extends State<BottomNavPageGroup> {
115
118
onPressed: () => _floatingButtonTapped (fabMenuItem! ),
116
119
),
117
120
);
118
- if (fab != null ) {
119
- floatingAlignment =
120
- FloatingAlignment .values.byName (fabMenuItem! .floatingAlignment);
121
- }
122
121
}
122
+ return null ;
123
123
}
124
124
125
125
void _floatingButtonTapped (MenuItem fabMenuItem) {
@@ -132,16 +132,13 @@ class _BottomNavPageGroupState extends State<BottomNavPageGroup> {
132
132
133
133
@override
134
134
Widget build (BuildContext context) {
135
- _floatingButton ();
136
-
137
135
return Scaffold (
138
136
resizeToAvoidBottomInset: false ,
139
137
bottomNavigationBar: _buildBottomNavBar (),
140
138
floatingActionButtonLocation: floatingAlignment == FloatingAlignment .none
141
139
? null
142
140
: floatingAlignment.location,
143
- floatingActionButton:
144
- floatingAlignment == FloatingAlignment .none ? null : fab,
141
+ floatingActionButton: _buildFloatingButton (),
145
142
body: PageGroupWidget (
146
143
scopeManager: widget.scopeManager,
147
144
child: widget.child,
0 commit comments