help<T> method
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,
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 = _currentOrientation == Orientation.portrait;
final closestBreakPoints =
_oldLength == _currentLength && _oldOrientation == _currentOrientation
? _cachedBreakPointsList!
: _getSortedBreakPointsByClosestTo(_currentLength);
_oldLength = _currentLength;
_oldOrientation = _currentOrientation;
_cachedBreakPointsList = closestBreakPoints;
if (_printScreenInfo)
_printCurrentScreenInfo(
currentLength: _currentLength,
closestBreakPoint: closestBreakPoints.first,
size: _size,
isPortrait: isPortrait,
);
final portraitMap = {
if (mobileSmall != null) BreakPoint.mobileSmall: mobileSmall,
if (mobileNormal != null) BreakPoint.mobileNormal: mobileNormal,
if (mobileLarge != null) BreakPoint.mobileLarge: mobileLarge,
if (mobileExtraLarge != null)
BreakPoint.mobileExtraLarge: mobileExtraLarge,
if (tabletSmall != null) BreakPoint.tabletSmall: tabletSmall,
if (tabletNormal != null) BreakPoint.tabletNormal: tabletNormal,
if (tabletLarge != null) BreakPoint.tabletLarge: tabletLarge,
if (tabletExtraLarge != null)
BreakPoint.tabletExtraLarge: tabletExtraLarge,
if (desktopSmall != null) BreakPoint.desktopSmall: desktopSmall,
if (desktopNormal != null) BreakPoint.desktopNormal: desktopNormal,
if (desktopLarge != null) BreakPoint.desktopLarge: desktopLarge,
if (desktopExtraLarge != null)
BreakPoint.desktopExtraLarge: desktopExtraLarge,
};
final landscapeMap = {
if (mobileSmallLandscape != null)
BreakPoint.mobileSmall: mobileSmallLandscape,
if (mobileNormalLandscape != null)
BreakPoint.mobileNormal: mobileNormalLandscape,
if (mobileLargeLandscape != null)
BreakPoint.mobileLarge: mobileLargeLandscape,
if (mobileExtraLargeLandscape != null)
BreakPoint.mobileExtraLarge: mobileExtraLargeLandscape,
if (tabletSmallLandscape != null)
BreakPoint.tabletSmall: tabletSmallLandscape,
if (tabletNormalLandscape != null)
BreakPoint.tabletNormal: tabletNormalLandscape,
if (tabletLargeLandscape != null)
BreakPoint.tabletLarge: tabletLargeLandscape,
if (tabletExtraLargeLandscape != null)
BreakPoint.tabletExtraLarge: tabletExtraLargeLandscape,
if (desktopSmallLandscape != null)
BreakPoint.desktopSmall: desktopSmallLandscape,
if (desktopNormalLandscape != null)
BreakPoint.desktopNormal: desktopNormalLandscape,
if (desktopLargeLandscape != null)
BreakPoint.desktopLarge: desktopLargeLandscape,
if (desktopExtraLargeLandscape != null)
BreakPoint.desktopExtraLarge: desktopExtraLargeLandscape,
};
final closestItem = _findClosest(
closestBreakPoints,
isPortrait,
portraitMap,
landscapeMap,
);
if (closestItem != null)
return closestItem;
else
throw Exception(
'Screen size not specified or there is no options passed from the parameters [currentLength: `$_currentLength`, orientation: `$_currentOrientation`]');
}