SafeArea

  • Usage

    Without safearea

    with safearea

    Syntax

    
                          SafeArea(
                              child:
    
                     
    1) SafeArea should have child :
    2) single widget is allowed
    3) children is not allowed
    
                     // main.dart
    import 'package:flutter/material.dart';
    
    void main() {
      runApp(const MyApp());
    }
    
    class MyApp extends StatelessWidget {
      const MyApp({Key? key}) : super(key: key);
    
      @override
      Widget build(BuildContext context) {
        return const MaterialApp(
          // Remove the debug banner
          debugShowCheckedModeBanner: false,
          home: MyHomePage(),
        );
      }
    }
    
    class MyHomePage extends StatelessWidget {
      const MyHomePage({Key? key}) : super(key: key);
    
      @override
      Widget build(BuildContext context) {
        return Scaffold(
          body: SafeArea(
            child: Column(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: const [
                Text(
                  'There is no one who loves pain itself, who seeks after it and wants to have it, simply because it is pain',
                  style: TextStyle(fontSize: 16),
                ),
                Text(
                    'There is no one who loves pain itself, who seeks after it and wants to have it, simply because it is pain')
              ],
            ),
          ),
        );
      }
    }