Sub topic 16
When to adapt and when to keep one design
This chapter assumes you can build screens with MaterialApp and Scaffold, and that you have seen CupertinoApp, the .adaptive constructors and Theme.of(context).platform. Earlier chapters showed how to adapt. This chapter covers whether you should.
Adapting has a cost
Every adaptive widget has two variants. Each variant needs testing, and each one can drift from the other as the app grows. A screen with ten adaptive controls has twenty paths to maintain, and some bugs only show up on one platform.
Adapting also has a benefit. Users carry habits from their platform. A switch that looks and moves like the system switch feels trustworthy. A dialog with the expected button layout is easy to read at a glance.
The decision is a trade-off between these two. Neither "adapt everything" nor "adapt nothing" is a safe default.
Three approaches
| Approach | What it means | Strength | Weakness |
|---|---|---|---|
| One design everywhere | A single Material or custom look on all platforms | Cheapest to build, test and brand | Can feel foreign on iOS |
| Adapt selected widgets | Use `.adaptive` constructors or custom adaptive widgets for specific controls | Native feel where users notice it most | Mixed look if chosen carelessly |
| Two full designs | A Material app and a Cupertino app behind a platform check | Closest to each platform | Roughly doubles UI work |
Most apps land on the middle row. The rest of this chapter helps you pick which widgets belong in it.
What users notice most
Some differences matter more than others. Rank candidates by how often users touch them and how strongly platform habits apply.
Adapt these first
- Navigation behavior. On iOS, users swipe from the left edge to go back.
CupertinoPageRouteand the default Material route on iOS both provide this gesture, so check that your routes keep it. Breaking swipe-back is the most common complaint from iOS users of cross-platform apps. - Scrolling physics. iOS content bounces at the edges. Android content shows a glow or stretch. Flutter's default
ScrollBehavioralready picks the right one per platform, so avoid overriding it with a fixed physics unless you have a reason. - Dialogs and action sheets. Confirmation flows are short and frequent.
AlertDialog.adaptivecosts one constructor call. - Switches and loading indicators.
Switch.adaptiveandCircularProgressIndicator.adaptiveare cheap and visible. - System back and safe areas. These affect whether the app feels broken, not only whether it looks different.
Often keep one design
- Brand surfaces. A logo header, a hero illustration, a custom card style or a signature color palette identify your product. Making these differ per platform weakens the brand.
- Content-heavy screens. A chart, a map or a media player looks the same everywhere because the content is the interface.
- Custom components. If you drew a widget yourself, there is no native equivalent to match.
- Cross-platform consistency needs. Support documentation, tutorials and screenshots are simpler when every user sees the same screen. This matters for apps used by teams on mixed devices.
A decision checklist
Ask these questions for each widget or screen, in order.
- Does the platform have a strong convention here, such as a gesture, a button position or a control shape? If not, keep one design.
- Does Flutter already adapt it for you? If a
.adaptiveconstructor or a platform-aware default exists, use it. - Is the widget a brand element? If yes, keep one design.
- Will the adaptive version stay visually coherent next to its neighbors? If a Cupertino control sits among Material cards with different spacing and type, the mix may look worse than consistency.
- Can you test both variants? If not, the second variant will probably rot.
Coherence matters more than purity
A common mistake is adapting one control and leaving the rest. A Cupertino switch inside a Material list tile is fine, because the switch is a small, familiar control. A Cupertino navigation bar above a Material body, with different fonts and a different background, looks unfinished.
Adapt in units. Switch a whole dialog, a whole form row or a whole screen section, not one stray widget in a visual context that disagrees with it.
Typography is a common source of mismatch. Material text uses the TextTheme from ThemeData. Cupertino widgets read CupertinoTheme.of(context).textTheme. When you place Cupertino widgets inside MaterialApp, Flutter builds a Cupertino theme from your Material theme through MaterialBasedCupertinoThemeData, so colors carry over. Fonts and sizes may still differ from what a native iOS app uses.
Keep adaptation in one place
Where you put the decision affects how painful future changes are.
Put platform checks in a small set of widgets, such as the AdaptiveButton from earlier chapters, and have screens call those. Do not scatter if (platform == TargetPlatform.iOS) through screen code. A central set of adaptive widgets gives you three benefits:
- You can change the policy in one file. If you decide a control should stop adapting, you edit one widget.
- Tests target the adaptive widget once, instead of every screen that uses it.
- Screens read as intent ("a primary button") and not as platform logic.
A policy object can make the decision explicit. This example gathers the rule in one function that every adaptive widget reads.
import 'package:flutter/material.dart';
enum AdaptPolicy { always, iosOnly, never }
bool shouldUseCupertino(BuildContext context, AdaptPolicy policy) {
final platform = Theme.of(context).platform;
final isApple =
platform == TargetPlatform.iOS || platform == TargetPlatform.macOS;
switch (policy) {
case AdaptPolicy.always:
return isApple;
case AdaptPolicy.iosOnly:
return platform == TargetPlatform.iOS;
case AdaptPolicy.never:
return false;
}
}The names are informative. always means "follow the platform whenever there is a Cupertino variant". iosOnly leaves macOS on the Material look, which some desktop apps prefer. never turns adaptation off for one widget. This is useful for a brand-critical button that should look the same everywhere.
You do not need this much structure in a small app. A single isCupertinoPlatform helper is enough. Add the policy when you find yourself making exceptions.
Failure modes
- Half-adapted screens. A mix of native-looking and Material controls with unrelated spacing. Fix by adapting at the unit level, or by dropping adaptation from that screen.
- Platform checks with
dart:io.Platform.isIOSfails on web and cannot be overridden in tests. UseTheme.of(context).platform. - Drift between variants. A new parameter is added to the Material branch and forgotten in the Cupertino branch. Keep adaptive widgets small and test both branches.
- Features that exist on one platform only.
CupertinoActionSheethas no exact Material twin. If you adapt, decide what Android shows, such as a Material bottom sheet, before you write the iOS version. - Ignoring size and input. A tablet or a desktop window with a mouse needs layout changes that platform adaptation does not give you. Adapting by platform is separate from adapting by screen size. Treat them as two decisions.
- Accessibility regressions. Native-looking controls usually bring accessible defaults, but custom replacements may not. Check text scaling, contrast in dark mode and screen reader labels on both variants.
A worked decision
Suppose you are building a habit-tracking app with a custom green brand color, a streak chart, a settings page and a delete-confirmation flow.
| Part of the app | Decision | Reason |
|---|---|---|
| Streak chart | One design | Custom content, no native equivalent |
| Brand header and color palette | One design | Product identity |
| Settings switches | Adapt with `Switch.adaptive` | Familiar control, one line |
| Loading spinner | Adapt with `.adaptive` | Familiar control, one line |
| Delete confirmation | Adapt with `AlertDialog.adaptive` | Frequent, convention-heavy |
| Navigation and scrolling | Keep Flutter defaults | Already platform-aware |
| Date selection | Adapt with `CupertinoDatePicker` on iOS and `showDatePicker` on Android | Pickers differ strongly and users know them |
This app adapts six small, high-contact elements and leaves the identity alone. The result is a screen that feels native in the places users touch most and recognizable everywhere else.
Revisiting the decision
Your choice is not permanent. Start with one design and Flutter's built-in platform defaults. Collect feedback from real users on each platform. Add adaptation where reviews, support requests or your own testing point to friction. Because adaptation lives in a few central widgets, adding or removing it later is a small change.
Exercise
Your app uses a Material card layout with a custom orange brand style. A teammate wants to replace every control with a Cupertino version on iOS. Give two reasons to adapt only some controls, and name one control you would still adapt.
Show answer
Reasons: each adapted control adds a second variant to test and maintain, and a few Cupertino controls among Material cards with different spacing and fonts look incoherent and weaken the brand. Brand elements such as the orange palette should stay the same on both platforms. Controls worth adapting include Switch.adaptive, CircularProgressIndicator.adaptive and AlertDialog.adaptive, because they are small, familiar to iOS users and cost one constructor call each.
Exercise
A reviewer finds if (Platform.isIOS) from dart:io in three screens. Explain what is wrong and how you would restructure it.
Show answer
Platform.isIOS from dart:io does not work on web and cannot be overridden in widget tests. Repeating it in screens also scatters the adaptation policy. Replace it with Theme.of(context).platform inside one reusable adaptive widget (such as AdaptiveButton) or a helper like isCupertinoPlatform, and have the screens call that widget. Tests can then set ThemeData.platform to check both branches.