selector 0.2.5 copy "selector: ^0.2.5" to clipboard
selector: ^0.2.5 copied to clipboard

outdated

Multi type supported platform selector to write functional programming.

Selector #

Multi type support Platform Selector

Basic selector #

  • with if
String result = '';
if (Platform.isAndroid) result = 'hello Android';
if (Platform.isIOS) result = 'hello iOS';
if (Platform.isFuchsia) result = 'hello  Fuchsia';
if (Platform.isLinux) result = 'hello  Linux';
if (Platform.isMacOS) result = 'hello MacOS';
if (Platform.isWindows) result = 'hello  Windows';
  • with selector
String result = selector(
      android: 'hello Android',
      ios: 'hello iOS',
      fuchsia: 'hello Fuchsia',
      linux: 'hello Linux',
      mac: 'hello MacOS',
      windows: 'hello Windows',
);

Device selector #

  • with if
String result = '';
if (Platform.isAndroid || Platform.isIOS || Platform.isFuchsia)
  result = 'hello Mobile';
if (Platform.isLinux || Platform.isMacOS || Platform.isWindows)
  result = 'hello Desktop';
if (kIsWeb) result = 'hello Web';
  • with deviceSelector
String result = deviceSelector(
      mobile: 'hello Mobile',
      desktop: 'hello Desktop',
      web: 'hello Web',
);

OrElse selector #

  • with if
String admobKey;
if (Platform.isAndroid) admobKey = 'android-key';
else admobKey = 'iOS-key';
  • with selector
String admobKey = androidOrElse('android-key', 'iOS-key');

Query #

print('isDesktop: $isDesktop')
print('isMobile: $isMobile')
21
likes
0
points
41
downloads

Publisher

unverified uploader

Weekly Downloads

Multi type supported platform selector to write functional programming.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter

More

Packages that depend on selector