onPlatform<T> static method
T?
onPlatform<T>({
- T android()?,
- T ios()?,
- T web()?,
- T desktop()?,
- 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();
}