Sub topic 1
Material and Cupertino: two design languages, one framework
Flutter uses one widget framework to build interfaces for Android, iOS, macOS, web, and desktop. The framework does not force every app to use one visual style. Instead, it provides design libraries with different conventions.
Material is Google's design language. It commonly uses floating buttons, filled buttons, cards, navigation drawers, and visual elevation. Cupertino is Apple's design language. It commonly uses compact controls, navigation bars, grouped settings, swipe-back navigation, and interaction patterns familiar to iOS users.
A design language includes more than colors. It describes how controls look, how they respond to touch, how screens are organized, and which actions feel familiar.
Prerequisites
This chapter assumes basic Dart syntax, Flutter widgets, StatelessWidget, StatefulWidget, setState, MaterialApp, and Scaffold. You should also know that a widget tree describes the elements Flutter lays out and paints.
One framework, different conventions
Material and Cupertino widgets use the same Flutter fundamentals:
- Widgets describe the interface.
BuildContextconnects a widget to its position in the tree.Navigatormanages routes.Statechanges cause widgets to rebuild.- Flutter renders the result through the same rendering pipeline.
The difference is the behavior and appearance supplied by each library.
| Concern | Material | Cupertino |
|---|---|---|
| App shell | `MaterialApp` | `CupertinoApp` |
| Main screen structure | `Scaffold` | `CupertinoPageScaffold` |
| Typical button | `FilledButton` | `CupertinoButton` |
| Common navigation pattern | App bar, drawer, bottom navigation | Navigation bar, tab scaffold, swipe-back |
| Visual emphasis | Elevation, surfaces, filled controls | Typography, spacing, grouped controls |
The widget names communicate the intended design language. A FilledButton does not automatically become an iOS button when the app runs on an iPhone. If you want a Cupertino appearance, choose Cupertino widgets or use an adaptive API.
Choosing a design strategy
You can choose among three broad strategies:
- Use Material everywhere. This gives the application a consistent identity and reduces implementation work.
- Use Cupertino everywhere. This can make an iOS-focused application feel native to Apple platforms.
- Adapt selected parts of the interface. For example, use platform-specific switches and dialogs while keeping the same content and screen structure.
Adaptation has a cost. Two visual variants require more testing, more design decisions, and sometimes different interaction logic. Use it when the platform convention affects usability or user expectations, not merely because the device has a different operating system.
import 'package:flutter/material.dart';
void main() {
runApp(
MaterialApp(
home: Scaffold(
appBar: AppBar(title: const Text('Shared Flutter idea')),
body: Center(
child: FilledButton(
onPressed: null,
child: const Text('Continue'),
),
),
),
),
);
}This example uses Material widgets. The same screen could express the same intent with Cupertino widgets, but the control shape, spacing, typography, and interaction details would follow Apple's conventions.
A useful mental model
Think of your application as two layers. The product layer defines the task, data, labels, and navigation goals. The design-language layer defines how those goals appear and behave on a platform.
Keep business logic independent from the visual choice where possible. A notification setting should have the same meaning on every platform, even if its switch and surrounding row differ.
Exercise
Why does running a Material widget on iOS not automatically give it a Cupertino appearance?
Show answer
Flutter widgets keep the behavior and appearance defined by their widget library. Platform adaptation must be requested with Cupertino widgets, adaptive constructors, or a custom platform-aware widget.