Center is introduced

Center is a centered display of the child component. It inherits from Align, and since Align is centered by default, Center will be as large as possible if its size is not limited.

The sample code

Many of the effects in this article are not screenshots. Download the source code to run the project source code address, or view the video tutorial address through the video tutorial

When to use Center?

Use Center when we need to Center child components.

Properties and description of the Center

field attribute describe
widthFactor double The width of the coefficient of
heightFactor double High coefficient of
child Widget Child components

Center used

import 'package:flutter/material.dart';

class CenterExample extends StatefulWidget {
  @override
  _CenterExampleState createState() => _CenterExampleState();
}

class _CenterExampleState extends State<CenterExample> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("AlignExample"),
      ),
      body: Center(
        child: Text("Jimi"),),); }}Copy the code

Results show

The end

Now that we have covered all of the container components of Flutter, we will continue to cover the basic components of Flutter.