usePlatform method

void usePlatform(
  1. BuildContext context, {
  2. T android(
    1. T
    )?,
  3. T iOS(
    1. T
    )?,
  4. T fuchsia(
    1. T
    )?,
  5. T linux(
    1. T
    )?,
  6. T macOS(
    1. T
    )?,
  7. T windows(
    1. T
    )?,
  8. T web(
    1. T
    )?,
})

Implementation

void usePlatform(
  BuildContext context, {
  T Function(T)? android,
  T Function(T)? iOS,
  T Function(T)? fuchsia,
  T Function(T)? linux,
  T Function(T)? macOS,
  T Function(T)? windows,
  T Function(T)? web,
}) {
  fallback(T Function(T)? builder) {
    if (builder != null) builder(self);
  }

  if (kIsWeb)
    fallback(web);
  else
    switch (Theme.of(context).platform) {
      case TargetPlatform.android:
        fallback(android);
        break;

      case TargetPlatform.iOS:
        fallback(iOS);
        break;

      case TargetPlatform.fuchsia:
        fallback(fuchsia);
        break;

      case TargetPlatform.linux:
        fallback(linux);
        break;

      case TargetPlatform.macOS:
        fallback(macOS);
        break;

      case TargetPlatform.windows:
        fallback(windows);
        break;
    }
}