getBreakpoint method
Gets the current Breakpoint based on the screen width.
Uses MediaQuery to determine the screen width and returns the appropriate breakpoint based on the configured thresholds.
Example:
final breakpoint = breakpointService.getBreakpoint(context);
if (breakpoint == Breakpoint.small) {
// Show mobile layout
}
Implementation
Breakpoint getBreakpoint(BuildContext context) {
final width = MediaQuery.sizeOf(context).width;
final config = _config;
if (width < config.small) {
return Breakpoint.small;
} else if (width < config.medium) {
return Breakpoint.medium;
} else if (width < config.large) {
return Breakpoint.large;
} else if (width < config.xLarge) {
return Breakpoint.xLarge;
} else {
return Breakpoint.xxLarge;
}
}