The Center
widget is to create a widget that centers its child.
The default constructor creates a widget that centers its child.
Center(
child: //
),
It contains many input parameters which can be configured to change its behavior and appearance.
The child
parameter is to add the widget below Center
widget in the tree.
This code snippet shows how to configure Center
widget with different parameters.
Center(
child: Text(
'Hello World!',
textDirection: TextDirection.ltr,
),
),
This example shows how to center a text.
import 'package:flutter/material.dart';
void main() {
runApp(
Center(
child: Text(
'Hello World!',
textDirection: TextDirection.ltr,
),
),
);
}