getCurrentPlatform function

PlatformType getCurrentPlatform()

Gets the current running platform.

Implementation

PlatformType getCurrentPlatform() {
  if (kIsWeb) {
    // Determine JS vs WASM if needed. Flutter Web currently compiles to JS or WASM.
    // As a generalized check:
    return PlatformType
        .js; // Expand based on specific WASM detection if necessary.
  }

  switch (defaultTargetPlatform) {
    case TargetPlatform.android:
      return PlatformType.android;
    case TargetPlatform.iOS:
      return PlatformType.ios;
    case TargetPlatform.macOS:
    case TargetPlatform.windows:
    case TargetPlatform.linux:
      return PlatformType.jvm; // Used as the desktop/backend equivalent
    default:
      return PlatformType.jvm;
  }
}