Flutter SafeArea Widget Examples – Avoid the Notch

The notch was introduce first in iPhone X, then was implemented in almost every Android phones. It comes in different shapes and sizes. Programming an app to make it suit with different notches is hard. So Google introduced SafeArea widget, which insets its child by sufficient padding to avoid intrusions by the operating system.

Th widget can do something like indenting the child by enough to avoid the status bar or a notch at the top of the screen.

class HomePage extends StatefulWidget {
  _HomePageState createState() => _HomePageState();

class _HomePageState extends State<HomePage> {
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Home'),
      backgroundColor: Colors.white,
      body: SafeArea(
          top: true,
          bottom: true,
          left: true,
          right: true,
          child: Row(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
                width: MediaQuery.of(context).size.width,
                height: 300,
                color: Colors.orange,
                child: Text('Container in SafeArea', style: TextStyle(color: Colors.white, fontSize: 26),),
  • top : Used to avoid system intrusions on top of screen like Status bar.
  • bottom : Used to avoid system intrusions on bottom of screen.
  • left : Used to avoid system intrusions on left side of screen.
  • right : Used to avoid system intrusions on right side of screen

Leave a Comment

Your email address will not be published. Required fields are marked *

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.