HardwareCapabilities.current constructor

HardwareCapabilities.current()

Returns a conservative capability snapshot for the current Flutter target.

Implementation

factory HardwareCapabilities.current() {
  if (kIsWeb) {
    return const HardwareCapabilities(
      platform: 'web',
      isWeb: true,
      isDesktop: false,
      isMobile: false,
      camera: false,
      audio: false,
      bluetooth: false,
      location: false,
      biometrics: false,
      sensors: false,
      haptics: false,
      storage: true,
      health: false,
      nativeCameraPreview: false,
    );
  }

  return switch (defaultTargetPlatform) {
    TargetPlatform.android || TargetPlatform.iOS => HardwareCapabilities(
        platform: defaultTargetPlatform.name,
        isWeb: false,
        isDesktop: false,
        isMobile: true,
        camera: true,
        audio: true,
        bluetooth: true,
        location: true,
        biometrics: true,
        sensors: true,
        haptics: true,
        storage: true,
        health: true,
        nativeCameraPreview: true,
      ),
    TargetPlatform.macOS ||
    TargetPlatform.windows ||
    TargetPlatform.linux =>
      HardwareCapabilities(
        platform: defaultTargetPlatform.name,
        isWeb: false,
        isDesktop: true,
        isMobile: false,
        camera: false,
        audio: false,
        bluetooth: false,
        location: false,
        biometrics: false,
        sensors: false,
        haptics: false,
        storage: true,
        health: false,
        nativeCameraPreview: false,
      ),
    TargetPlatform.fuchsia => const HardwareCapabilities(
        platform: 'fuchsia',
        isWeb: false,
        isDesktop: false,
        isMobile: false,
        camera: false,
        audio: false,
        bluetooth: false,
        location: false,
        biometrics: false,
        sensors: false,
        haptics: false,
        storage: true,
        health: false,
        nativeCameraPreview: false,
      ),
  };
}