Skip to content

Commit 892796e

Browse files
committed
Fix
1 parent e78e4ee commit 892796e

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

packages/flutter_adaptive_scaffold/lib/src/breakpoints.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@ class Breakpoint {
226226
final SlotLayout? slotLayout =
227227
context.findAncestorWidgetOfExactType<SlotLayout>();
228228
Breakpoint? fallbackBreakpoint;
229+
229230
if (slotLayout != null) {
230231
for (final MapEntry<Breakpoint, SlotLayoutConfig?> config
231232
in slotLayout.config.entries) {

packages/flutter_adaptive_scaffold/lib/src/slot_layout.dart

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,24 @@ class SlotLayout extends StatefulWidget {
2020
static SlotLayoutConfig? pickWidget(
2121
BuildContext context, Map<Breakpoint, SlotLayoutConfig?> config) {
2222
SlotLayoutConfig? chosenWidget;
23-
SlotLayoutConfig? fallbackWidget;
24-
config.forEach((Breakpoint breakpoint, SlotLayoutConfig? pickedWidget) {
23+
24+
for (final Breakpoint breakpoint in config.keys) {
2525
if (breakpoint.isActive(context)) {
26-
if (breakpoint.platform != null) {
27-
chosenWidget = pickedWidget;
28-
} else if (chosenWidget == null && pickedWidget != null) {
29-
fallbackWidget = pickedWidget;
26+
final SlotLayoutConfig? pickedWidget = config[breakpoint];
27+
if (pickedWidget != null) {
28+
if (breakpoint.platform != null) {
29+
// Prioritize platform-specific breakpoints
30+
return pickedWidget;
31+
} else {
32+
// Fallback to non-platform-specific
33+
chosenWidget = pickedWidget;
34+
}
35+
} else {
36+
chosenWidget = null;
3037
}
3138
}
32-
});
33-
chosenWidget ??= fallbackWidget;
39+
}
40+
3441
return chosenWidget;
3542
}
3643

0 commit comments

Comments
 (0)