mobile<T> method
T
mobile<T>({
- required T android(),
- required T ios(),
- 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,
);
}