onPlatform<T> static method

T? onPlatform<T>({
  1. T android()?,
  2. T ios()?,
  3. T web()?,
  4. T desktop()?,
  5. T defaultValue()?,
})

Implementation

static T? onPlatform<T>({
  T Function()? android,
  T Function()? ios,
  T Function()? web,
  T Function()? desktop,
  T Function()? defaultValue,
}) {
  if (kIsWeb) {
    return (web ?? defaultValue)?.call();
  }

  if (Platform.isAndroid) {
    return android?.call();
  } else if (Platform.isIOS) {
    return ios?.call();
  }

  return (desktop ?? defaultValue)?.call();
}