mobile<T> method

T mobile<T>({
  1. required T android(),
  2. required T ios(),
  3. T desktop()?,
})

Calls the action for mobile platforms (Android or iOS), with optional desktop fallback. When desktop is provided, it runs on Linux/Windows instead of throwing.

Implementation

T mobile<T>({
  required T Function() android,
  required T Function() ios,
  T Function()? desktop,
}) {
  T error() => throw UnsupportedError('Unsupported platform');

  return safe(
    android: android,
    ios: ios,
    web: error,
    macos: error,
    desktop: desktop ?? error,
  );
}