help<T> method

T help<T>({
  1. T? mobileSmall,
  2. T? mobileSmallLandscape,
  3. T? mobileNormal,
  4. T? mobileNormalLandscape,
  5. T? mobileLarge,
  6. T? mobileLargeLandscape,
  7. T? mobileExtraLarge,
  8. T? mobileExtraLargeLandscape,
  9. T? tabletSmall,
  10. T? tabletSmallLandscape,
  11. T? tabletNormal,
  12. T? tabletNormalLandscape,
  13. T? tabletLarge,
  14. T? tabletLargeLandscape,
  15. T? tabletExtraLarge,
  16. T? tabletExtraLargeLandscape,
  17. T? desktopSmall,
  18. T? desktopSmallLandscape,
  19. T? desktopNormal,
  20. T? desktopNormalLandscape,
  21. T? desktopLarge,
  22. T? desktopLargeLandscape,
  23. T? desktopExtraLarge,
  24. T? desktopExtraLargeLandscape,
})

Implementation

T help<T>({
  T? mobileSmall,
  T? mobileSmallLandscape,
  T? mobileNormal,
  T? mobileNormalLandscape,
  T? mobileLarge,
  T? mobileLargeLandscape,
  T? mobileExtraLarge,
  T? mobileExtraLargeLandscape,
  T? tabletSmall,
  T? tabletSmallLandscape,
  T? tabletNormal,
  T? tabletNormalLandscape,
  T? tabletLarge,
  T? tabletLargeLandscape,
  T? tabletExtraLarge,
  T? tabletExtraLargeLandscape,
  T? desktopSmall,
  T? desktopSmallLandscape,
  T? desktopNormal,
  T? desktopNormalLandscape,
  T? desktopLarge,
  T? desktopLargeLandscape,
  T? desktopExtraLarge,
  T? desktopExtraLargeLandscape,
}) {
  final isPortrait = _orientation == Orientation.portrait;

  if (_printScreenInfo) _printCurrentScreenInfo(_current, _size, isPortrait);

  final portraitNodesList = [
    if (mobileSmall != null) Node(BreakPoint.mobileSmall, mobileSmall),
    if (mobileNormal != null) Node(BreakPoint.mobileNormal, mobileNormal),
    if (mobileLarge != null) Node(BreakPoint.mobileLarge, mobileLarge),
    if (mobileExtraLarge != null)
      Node(BreakPoint.mobileExtraLarge, mobileExtraLarge),
    if (tabletSmall != null) Node(BreakPoint.tabletSmall, tabletSmall),
    if (tabletNormal != null) Node(BreakPoint.tabletNormal, tabletNormal),
    if (tabletLarge != null) Node(BreakPoint.tabletLarge, tabletLarge),
    if (tabletExtraLarge != null)
      Node(BreakPoint.tabletExtraLarge, tabletExtraLarge),
    if (desktopSmall != null) Node(BreakPoint.desktopSmall, desktopSmall),
    if (desktopNormal != null) Node(BreakPoint.desktopNormal, desktopNormal),
    if (desktopLarge != null) Node(BreakPoint.desktopLarge, desktopLarge),
    if (desktopExtraLarge != null)
      Node(BreakPoint.desktopExtraLarge, desktopExtraLarge),
  ];

  final landscapeNodesList = [
    if (mobileSmallLandscape != null)
      Node(BreakPoint.mobileSmall, mobileSmallLandscape),
    if (mobileNormalLandscape != null)
      Node(BreakPoint.mobileNormal, mobileNormalLandscape),
    if (mobileLargeLandscape != null)
      Node(BreakPoint.mobileLarge, mobileLargeLandscape),
    if (mobileExtraLargeLandscape != null)
      Node(BreakPoint.mobileExtraLarge, mobileExtraLargeLandscape),
    if (tabletSmallLandscape != null)
      Node(BreakPoint.tabletSmall, tabletSmallLandscape),
    if (tabletNormalLandscape != null)
      Node(BreakPoint.tabletNormal, tabletNormalLandscape),
    if (tabletLargeLandscape != null)
      Node(BreakPoint.tabletLarge, tabletLargeLandscape),
    if (tabletExtraLargeLandscape != null)
      Node(BreakPoint.tabletExtraLarge, tabletExtraLargeLandscape),
    if (desktopSmallLandscape != null)
      Node(BreakPoint.desktopSmall, desktopSmallLandscape),
    if (desktopNormalLandscape != null)
      Node(BreakPoint.desktopNormal, desktopNormalLandscape),
    if (desktopLargeLandscape != null)
      Node(BreakPoint.desktopLarge, desktopLargeLandscape),
    if (desktopExtraLargeLandscape != null)
      Node(BreakPoint.desktopExtraLarge, desktopExtraLargeLandscape),
  ];

  final closestNode = _findClosestNode(
    _current,
    isPortrait,
    portraitNodesList,
    landscapeNodesList,
  );

  if (closestNode != null)
    return closestNode.value!;
  else
    throw Exception(
        'Screen size not specified or there is no options passed from the parameters [current: `$_current`, orientation: `$_orientation`]');
}