Skip to content

Commit 00c3597

Browse files
authored
fix: incorrect positioning of non-FAB controls assigned to page.floating_action_button (#5049)
* fab can be of any type * cleanup
1 parent fd8daab commit 00c3597

File tree

4 files changed

+9
-11
lines changed

4 files changed

+9
-11
lines changed

packages/flet/lib/src/controls/markdown.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import '../utils/box.dart';
1010
import '../utils/images.dart';
1111
import '../utils/launch_url.dart';
1212
import '../utils/markdown.dart';
13-
import '../utils/text.dart';
1413
import '../utils/uri.dart';
1514
import 'create_control.dart';
1615
import 'error.dart';

packages/flet/lib/src/controls/page.dart

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -874,9 +874,7 @@ class _ViewControlState extends State<ViewControl> with FletStoreMixin {
874874
control.attrString("horizontalAlignment"),
875875
CrossAxisAlignment.start)!;
876876
final fabLocation = parseFloatingActionButtonLocation(
877-
control,
878-
"floatingActionButtonLocation",
879-
FloatingActionButtonLocation.endFloat);
877+
control, "floatingActionButtonLocation");
880878

881879
Control? appBar;
882880
Control? cupertinoAppBar;
@@ -898,18 +896,18 @@ class _ViewControlState extends State<ViewControl> with FletStoreMixin {
898896
} else if (ctrl.type == "bottomappbar") {
899897
bottomAppBar = ctrl;
900898
continue;
901-
} else if (ctrl.type == "floatingactionbutton") {
899+
} else if (ctrl.name == "fab") {
902900
fab = ctrl;
903901
continue;
904902
} else if (ctrl.type == "navigationbar" ||
905903
ctrl.type == "cupertinonavigationbar") {
906904
navBar = ctrl;
907905
continue;
908906
} else if (ctrl.type == "navigationdrawer" &&
909-
ctrl.name == "start") {
907+
ctrl.name == "drawer_start") {
910908
drawer = ctrl;
911909
continue;
912-
} else if (ctrl.type == "navigationdrawer" && ctrl.name == "end") {
910+
} else if (ctrl.type == "navigationdrawer" && ctrl.name == "drawer_end") {
913911
endDrawer = ctrl;
914912
continue;
915913
}

packages/flet/lib/src/utils/buttons.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@ ButtonStyle? buttonStyleFromJSON(ThemeData theme, Map<String, dynamic>? json,
9595
);
9696
}
9797

98-
FloatingActionButtonLocation parseFloatingActionButtonLocation(
99-
Control control, String propName, FloatingActionButtonLocation defValue) {
98+
FloatingActionButtonLocation? parseFloatingActionButtonLocation(
99+
Control control, String propName, [FloatingActionButtonLocation? defValue]) {
100100
const Map<String, FloatingActionButtonLocation> fabLocations = {
101101
"centerdocked": FloatingActionButtonLocation.centerDocked,
102102
"centerfloat": FloatingActionButtonLocation.centerFloat,

sdk/python/packages/flet/src/flet/core/view.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,14 +122,15 @@ def _get_children(self):
122122
if self.__bottom_appbar:
123123
children.append(self.__bottom_appbar)
124124
if self.__fab:
125+
self.__fab._set_attr_internal("n", "fab")
125126
children.append(self.__fab)
126127
if self.__navigation_bar:
127128
children.append(self.__navigation_bar)
128129
if self.__drawer:
129-
self.__drawer._set_attr_internal("n", "start")
130+
self.__drawer._set_attr_internal("n", "drawer_start")
130131
children.append(self.__drawer)
131132
if self.__end_drawer:
132-
self.__end_drawer._set_attr_internal("n", "end")
133+
self.__end_drawer._set_attr_internal("n", "drawer_end")
133134
children.append(self.__end_drawer)
134135
return children + self.__controls
135136

0 commit comments

Comments
 (0)