usePlatform method

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

Implementation

void usePlatform({
  Widget Function(Niku)? base,
  Widget Function(Niku)? android,
  Widget Function(Niku)? iOS,
  Widget Function(Niku)? fuchsia,
  Widget Function(Niku)? linux,
  Widget Function(Niku)? macOS,
  Widget Function(Niku)? windows,
  Widget Function(Niku)? web,
}) {
  useChild(
    (child) => Builder(
      builder: (context) {
        fallback(Widget Function(Niku)? builder) {
          if (builder != null) return builder(child);
          return child;
        }

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

            case TargetPlatform.iOS:
              return fallback(iOS);

            case TargetPlatform.fuchsia:
              return fallback(fuchsia);

            case TargetPlatform.linux:
              return fallback(linux);

            case TargetPlatform.macOS:
              return fallback(macOS);

            case TargetPlatform.windows:
              return fallback(windows);
          }
      },
    ),
  );
}