platformCheck method

String platformCheck({
  1. required BuildContext context,
})

Implementation

String platformCheck({required BuildContext context}) {
  String platform = '';

  AdaptiveWindowType windowType = getWindowType(context);
  bool isDisplayDesktop(BuildContext context) =>
      windowType >= AdaptiveWindowType.medium;
  bool isDisplaySmallDesktop(BuildContext context) =>
      windowType <= AdaptiveWindowType.medium &&
      getWindowType(context) >= AdaptiveWindowType.small;
  bool isDisplayMobile(BuildContext context) =>
      windowType <= AdaptiveWindowType.xsmall;

  final isDesktop = isDisplayDesktop(context);
  final isTablet = isDisplaySmallDesktop(context);
  final isMobile = isDisplayMobile(context);

  if (!kIsWeb) {
    if (Platform.isAndroid) {
      platform = Platforms.android;
    } else if (Platform.isIOS) {
      platform = Platforms.iOS;
    } else if (Platform.isMacOS) {
      platform = Platforms.macOS;
    } else if (Platform.isWindows) {
      platform = Platforms.windows;
    } else if (Platform.isLinux) {
      platform = Platforms.linux;
    } else if (Platform.isFuchsia) {
      platform = Platforms.fuchsia;
    }
  } else {
    if (isDesktop) {
      platform = Platforms.webDesktop;
    } else if (isTablet) {
      platform = Platforms.webTablet;
    } else if (isMobile) {
      platform = Platforms.webMobile;
    }
  }
  return platform;
}