valueBasedOnBreakPoint static method

dynamic valueBasedOnBreakPoint({
  1. required BuildContext context,
  2. required Map<BSBreakPointLabels, dynamic> map,
})

returns the value in the map based on the current breakpoint. if there is a missing breakpoint in the map null may be returned map example: { BSBreakPointLabels.xxl: "1", BSBreakPointLabels.xl: "2", BSBreakPointLabels.lg: "3", BSBreakPointLabels.md: "4", BSBreakPointLabels.sm: "5", BSBreakPointLabels.none: "6", }

Implementation

static dynamic valueBasedOnBreakPoint({
  required BuildContext context,
  required Map<BSBreakPointLabels, dynamic> map,
}) {
  // get the current container from the passed context
  BSContainerInheritance bsContainerInheritance = _checkIfInContext(
    context: context,
  );

  // return null if the passed map doesn't have a value for the current breakpoint
  if (!map.containsKey(bsContainerInheritance.currentBSBreakPointLabel)) {
    return null;
  }

  // return the value for the current breakpoint
  return map[bsContainerInheritance.currentBSBreakPointLabel];
}