Flutter Align Container Widget Center of Screen Example

Center widget in flutter is used to put any given child widget in Vertically and Horizontally center of remaining space. In many applications when developer wants to show something at Center of screen then the solution is Center widget. Today we would learn about a basic concept in flutter to show any widget in Center of screen. Flutter Align Container Widget Center of Screen Android iOS Example.

Contents in this project Flutter Align Container Widget Center of Screen Example:

1. Open your project’s main.dart file and import material.dart file.

2. Create void main runApp() method and here we would call our main MyApp class.

3. Creating our main class MyApp extends Statelesswidget.

4. Creating Widget Build area -> Material App -> Scaffold Widget -> Safe Area widget . Here the Safe Area widget is used to put margin between Top Navbar and screen.

5. Now in the final step we would make the Center Widget then wrap the Container widget as its child. This will put the Container widget in Center of Screen.

6. Complete source code for main.dart file:

Screenshot:

Flutter Align Container Widget Center of Screen Example

Leave a Reply

Your email address will not be published.