resolveBreakpoint method
Resolves the appropriate breakpoint for the current screen width based on MediaQuery.
If the screen width falls between two breakpoints, it returns the current. If it exceeds all breakpoints, the last one is returned.
Implementation
T resolveBreakpoint(BuildContext context) {
final width = MediaQuery.sizeOf(context).width;
for (var i = 0; i < breakpoints.length; i++) {
final current = breakpoints[i];
final next = i + 1 < breakpoints.length ? breakpoints[i + 1] : null;
if (next != null &&
current.breakpoint <= width &&
next.breakpoint > width) {
return current;
}
}
// Return the last breakpoint if none matched (usually the largest one).
return breakpoints.last;
}