Center

  • Usage

    Flutter Center widget center aligns its child widget within itself, along vertical and horizontal axes.

    Syntax

    
                      Center(
                        child: someWidget,
                      )
    
                      
    
                    
    
                    import 'package:flutter/material.dart';
     
     void main() => runApp(const MyApp());
      
     class MyApp extends StatelessWidget {
       const MyApp({Key? key}) : super(key: key);
      
       static const String _title = 'Flutter Tutorial';
      
       @override
       Widget build(BuildContext context) {
         return MaterialApp(
           title: _title,
           home: Scaffold(
             appBar: AppBar(title: const Text(_title)),
             body: const MyStatefulWidget(),
           ),
         );
       }
     }
      
     class MyStatefulWidget extends StatefulWidget {
       const MyStatefulWidget({Key? key}) : super(key: key);
      
       @override
       State<MyStatefulWidget> createState() => _MyStatefulWidgetState();
     }
      
     class _MyStatefulWidgetState extends State<MyStatefulWidget> {
       @override
       Widget build(BuildContext context) {
         return const Center(
           child: Text('Hello World', style: TextStyle(fontSize: 30),),
         );
       }
     }
                    
    Center()