diff --git a/CHANGELOG.md b/CHANGELOG.md index 108ba9795..2f632e6d8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ # 0.23.1 +* FIX: Fix parseFloatingActionButtonLocation() to work on desktop ([#3496](https://github.com/flet-dev/flet/issues/3496)) * FIX: Flet 0.23 crashes on Ubuntu 22.04 ([#3495](https://github.com/flet-dev/flet/issues/3495)) * FIX: View.floating_action_button_location: conditionally use _set_attr. * FIX: Import `ParamSpec` from `typing` for Python >3.10. diff --git a/packages/flet/CHANGELOG.md b/packages/flet/CHANGELOG.md index b4ee11e7c..bcf0a83da 100644 --- a/packages/flet/CHANGELOG.md +++ b/packages/flet/CHANGELOG.md @@ -1,5 +1,6 @@ # 0.23.1 +* FIX: Fix parseFloatingActionButtonLocation() to work on desktop ([#3496](https://github.com/flet-dev/flet/issues/3496)) * FIX: Flet 0.23 crashes on Ubuntu 22.04 ([#3495](https://github.com/flet-dev/flet/issues/3495)) * FIX: View.floating_action_button_location: conditionally use _set_attr. * FIX: Import `ParamSpec` from `typing` for Python >3.10. diff --git a/packages/flet/lib/src/utils/buttons.dart b/packages/flet/lib/src/utils/buttons.dart index 6c208a165..09eab05b1 100644 --- a/packages/flet/lib/src/utils/buttons.dart +++ b/packages/flet/lib/src/utils/buttons.dart @@ -83,26 +83,26 @@ ButtonStyle? buttonStyleFromJSON(ThemeData theme, Map? json, FloatingActionButtonLocation parseFloatingActionButtonLocation( Control control, String propName, FloatingActionButtonLocation defValue) { - List fabLocations = [ - FloatingActionButtonLocation.centerDocked, - FloatingActionButtonLocation.centerFloat, - FloatingActionButtonLocation.centerTop, - FloatingActionButtonLocation.endContained, - FloatingActionButtonLocation.endDocked, - FloatingActionButtonLocation.endFloat, - FloatingActionButtonLocation.endTop, - FloatingActionButtonLocation.miniCenterDocked, - FloatingActionButtonLocation.miniCenterFloat, - FloatingActionButtonLocation.miniCenterTop, - FloatingActionButtonLocation.miniEndFloat, - FloatingActionButtonLocation.miniEndTop, - FloatingActionButtonLocation.miniStartDocked, - FloatingActionButtonLocation.miniStartFloat, - FloatingActionButtonLocation.miniStartTop, - FloatingActionButtonLocation.startDocked, - FloatingActionButtonLocation.startFloat, - FloatingActionButtonLocation.startTop - ]; + const Map fabLocations = { + "centerdocked": FloatingActionButtonLocation.centerDocked, + "centerfloat": FloatingActionButtonLocation.centerFloat, + "centertop": FloatingActionButtonLocation.centerTop, + "endcontained": FloatingActionButtonLocation.endContained, + "enddocked": FloatingActionButtonLocation.endDocked, + "endfloat": FloatingActionButtonLocation.endFloat, + "endtop": FloatingActionButtonLocation.endTop, + "minicenterdocked": FloatingActionButtonLocation.miniCenterDocked, + "minicenterfloat": FloatingActionButtonLocation.miniCenterFloat, + "minicentertop": FloatingActionButtonLocation.miniCenterTop, + "miniendfloat": FloatingActionButtonLocation.miniEndFloat, + "miniendtop": FloatingActionButtonLocation.miniEndTop, + "ministartdocked": FloatingActionButtonLocation.miniStartDocked, + "ministartfloat": FloatingActionButtonLocation.miniStartFloat, + "ministarttop": FloatingActionButtonLocation.miniStartTop, + "startdocked": FloatingActionButtonLocation.startDocked, + "startfloat": FloatingActionButtonLocation.startFloat, + "starttop": FloatingActionButtonLocation.startTop + }; try { OffsetDetails? fabLocationOffsetDetails = parseOffset(control, propName); @@ -113,11 +113,8 @@ FloatingActionButtonLocation parseFloatingActionButtonLocation( return defValue; } } catch (e) { - return fabLocations.firstWhere( - (l) => - l.toString().split('.').last.toLowerCase() == - control.attrString(propName, "")!.toLowerCase(), - orElse: () => defValue); + var key = control.attrString(propName, "")!.toLowerCase(); + return fabLocations.containsKey(key) ? fabLocations[key]! : defValue; } }