deviceSelector<T> function

T deviceSelector<T>({
  1. required T mobile,
  2. required T desktop,
  3. required T web,
})

deviceSelector

String result = deviceSelector(
  mobile: 'hello Mobile',
  desktop: 'hello Desktop',
  web: 'hello Web'
);

Implementation

T deviceSelector<T>({
  required T mobile,
  required T desktop,
  required T web,
}) {
  if (kIsWeb) return web;

  if (isMobile) return mobile;

  if (isDesktop) return desktop;

  throw 'Unidentified device ${Platform.operatingSystem}';
}