optionalDeviceSelector<T> function

T? optionalDeviceSelector<T>({
  1. T? mobile,
  2. T? desktop,
  3. 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}';
}