Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix parseFloatingActionButtonLocation() to work on desktop #3496

Merged
merged 3 commits into from
Jun 19, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 22 additions & 25 deletions packages/flet/lib/src/utils/buttons.dart
Original file line number Diff line number Diff line change
Expand Up @@ -83,26 +83,26 @@ ButtonStyle? buttonStyleFromJSON(ThemeData theme, Map<String, dynamic>? json,

FloatingActionButtonLocation parseFloatingActionButtonLocation(
Control control, String propName, FloatingActionButtonLocation defValue) {
List<FloatingActionButtonLocation> 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
];
Map<String, FloatingActionButtonLocation> fabLocations = {
ndonkoHenri marked this conversation as resolved.
Show resolved Hide resolved
"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);
Expand All @@ -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();
ndonkoHenri marked this conversation as resolved.
Show resolved Hide resolved
return fabLocations.containsKey(key) ? fabLocations[key]! : defValue;
ndonkoHenri marked this conversation as resolved.
Show resolved Hide resolved
}
}

Expand Down