value property
T
get
value
Implementation
T get value {
final currentBreakpoint =
RespQueryHelper(context: context).currentBreakpoint;
/// Create a map with all of the brakpoints values
final allValues = <String, T?>{if (others != null) ...others!};
if (xs != null) {
allValues['xs'] = xs;
}
if (sm != null) {
allValues['sm'] = sm;
}
if (md != null) {
allValues['md'] = md;
}
if (lg != null) {
allValues['lg'] = lg;
}
if (xl != null) {
allValues['xl'] = xl;
}
if (xxl != null) {
allValues['xxl'] = xxl;
}
for (final breakpoint
in RespBreakPointsHelper.getAllBreakpoints(context).reversed) {
/// Look for any breakpoints that are lesser than or equal to the
/// current breakpoint
if (breakpoint.value > currentBreakpoint.value) {
continue;
}
/// If there is a value specified for the breakpoint, then use that value and stop the loop
if (allValues.containsKey(breakpoint.name)) {
return allValues[breakpoint.name]!;
}
}
/// No value suitable for the current breakpoint found
throw Exception(
'Cannot find value for the current breakpoint. Current Breakpoint (Name: ${currentBreakpoint.name}, Value: ${currentBreakpoint.value})');
}