optionalDeviceSelector<T> function
T?
optionalDeviceSelector<T>({
- T? mobile,
- T? desktop,
- T? web,
optional deviceSelector
String result = deviceSelector(
mobile: 'hello Mobile',
desktop: 'hello Desktop',
web: 'hello Web'
);
Implementation
T? optionalDeviceSelector<T>({
T? mobile,
T? desktop,
T? web,
}) {
if (kIsWeb) return web;
if (isMobile) return mobile;
if (isDesktop) return desktop;
throw 'Unidentified device ${Platform.operatingSystem}';
}