responsiveFunction method

dynamic responsiveFunction({
  1. required Function forUnInitialDevices,
  2. Function? forPortraitMobileScreen,
  3. Function? forLandscapeMobileScreen,
  4. Function? forPortraitTabletScreen,
  5. Function? forLandscapeTabletScreen,
  6. Function? forDesktopScreen,
  7. Function? forTVScreen,
})

Use to return different function depending on screen type.

Implementation

responsiveFunction(
    {required Function forUnInitialDevices,
    Function? forPortraitMobileScreen,
    Function? forLandscapeMobileScreen,
    Function? forPortraitTabletScreen,
    Function? forLandscapeTabletScreen,
    Function? forDesktopScreen,
    Function? forTVScreen}) {
  if (_responsiveHandler._screenType == ScreenType.phone)
    return (_responsiveHandler._deviceInfo.orientation == Orientation.portrait
            ? forPortraitMobileScreen
            : forLandscapeMobileScreen) ??
        forUnInitialDevices;
  else if (_responsiveHandler._screenType == ScreenType.tabletOrIpad)
    return (_responsiveHandler._deviceInfo.orientation == Orientation.portrait
            ? forPortraitTabletScreen
            : forLandscapeTabletScreen) ??
        forUnInitialDevices;
  else if (_responsiveHandler._screenType == ScreenType.desktop ||
      _responsiveHandler._screenType == ScreenType.website)
    return forDesktopScreen ?? forUnInitialDevices;
  else
    return forTVScreen ?? forUnInitialDevices;
}