Answer
Overview
is a widget that adds padding to its child to avoid intrusions from the operating system — such as the status bar, notch, home indicator, and rounded corners.textSafeArea
Why SafeArea Is Needed
On modern phones:
- Status bar (top) — time, battery, signal icons
- Notch / Dynamic Island (top) — camera cutout
- Home indicator (bottom) — swipe gesture bar on iPhones
- Navigation bar (bottom) — Android back/home/recents
Without
text
SafeAreaBasic Usage
dartScaffold( body: SafeArea( child: Column( children: [ Text('This is safely visible'), Text('Not hidden behind status bar or notch'), ], ), ), )
Control Which Sides Are Safe
dartSafeArea( top: true, // Add top padding (status bar / notch) bottom: true, // Add bottom padding (home indicator) left: false, // No left padding right: false, // No right padding child: YourWidget(), )
Minimum Padding
dart// Ensure at least 8px padding on all sides SafeArea( minimum: EdgeInsets.all(8), child: YourWidget(), )
Common Use Cases
dart// Full page layout Scaffold( body: SafeArea( child: ListView(...), ), ) // Only protect top (e.g., content extends to bottom edge intentionally) SafeArea( bottom: false, child: YourContent(), ) // Custom bottom sheet that respects home indicator SafeArea( top: false, child: Column( children: [ Text('Sheet content'), ElevatedButton(child: Text('Confirm'), onPressed: () {}), ], ), )
When NOT to Use SafeArea
| Situation | Reason |
|---|---|
| Background images that extend edge-to-edge | You want the image to fill fully |
| Maps or immersive content | Content intentionally goes edge-to-edge |
| Scaffold already handles it | text text |
Best Practice: Wrap your Scaffold's
content intextbodyfor all screens. On most screens,textSafeAreahandles the AppBar area, so you mainly needtextScaffoldfor content that goes beneath the status bar or above the home indicator.textSafeArea