detectPlatform static method

DevicePlatform detectPlatform(
  1. BuildContext context
)

Implementation

static DevicePlatform detectPlatform(BuildContext context) {
  if (kIsWeb) return DevicePlatform.web;

  final platform = Theme.of(context).platform;

  switch (platform) {
    case TargetPlatform.android:
      return DevicePlatform.android;
    case TargetPlatform.fuchsia:
      return DevicePlatform.fuchsia;
    case TargetPlatform.iOS:
      return DevicePlatform.iOS;
    case TargetPlatform.linux:
      return DevicePlatform.linux;
    case TargetPlatform.macOS:
      return DevicePlatform.macOS;
    case TargetPlatform.windows:
      return DevicePlatform.windows;
  }
}