getActiveBreakpointId method
Finds the active BreakpointId for a given screen width. Assumes breakpoints are ordered from smallest to largest for correct matching.
Implementation
BreakpointId getActiveBreakpointId(double screenWidth) {
// Iterate from largest to smallest to ensure correct matching for overlapping (if any) or unbounded largest breakpoint
for (final bpConfig in breakpoints.reversed) {
if (bpConfig.settings.isActive(screenWidth)) {
return bpConfig.id;
}
}
// Fallback to the smallest if screenWidth is below the smallest defined minWidth.
// This assumes breakpoints are sorted by minWidth or this is the desired behavior.
return breakpoints.first.id;
}