Flutter › Flutter Cupertino (iOS Style) Widgets
How can you build a genuinely adaptive Flutter app that automatically displays Material widgets on Android while simultaneously displaying Cupertino widgets on iOS, all from within just one single shared codebase?
IntermediateAnswer
Building a genuinely adaptive app that displays platform appropriate widgets means checking the current platform, typically using Platform.isIOS from Dart's own core library, and conditionally rendering either the Material or the corresponding Cupertino version of a specific given widget based on that determined platform, and Flutter also provides some dedicated built in adaptive widgets, such as Switch.adaptive, which automatically handle this exact same platform specific decision internally for you, without you needing to write that same explicit conditional platform check logic yourself every single time.
Platform.isIOS
? CupertinoSwitch(value: isEnabled, onChanged: onChanged)
: Switch(value: isEnabled, onChanged: onChanged);Real-world example A settings screen displays a CupertinoSwitch specifically on iOS devices and a regular Material Switch specifically on Android devices, using a simple platform check to ensure every single user genuinely sees the exact toggle control style they would already naturally expect on their own particular specific device.