currentBreakpoint property
String
get
currentBreakpoint
Returns the name of the current active custom breakpoint Returns the largest breakpoint name that the screen width satisfies Returns 'unknown' if no custom breakpoints are defined or matched
Implementation
String get currentBreakpoint {
final customBreakpoints =
ResponsiveMediaBreakpointConfig.customBreakpoints;
if (customBreakpoints.isEmpty) {
return 'unknown';
}
// Sort breakpoints by value in descending order
final sortedBreakpoints = customBreakpoints.entries.toList()
..sort((a, b) => b.value.compareTo(a.value));
// Return the first (largest) breakpoint that the screen width satisfies
for (var entry in sortedBreakpoints) {
if (screenWidth >= entry.value) {
return entry.key;
}
}
return 'unknown';
}