Flutter Center Widget
 Posted on
 < Previous  Next > 
The Center widget in Flutter is used to center its child widget both horizontally and vertically within its parent widget.
Here's an example of how to use the Center widget:
@override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        // heightFactor: 3,
        // widthFactor: 0.8,
        child: Container(
          color: Colors.green,
          child: Text(
            'Helloo World',
            textScaleFactor: 3,
            style: TextStyle(color: Colors.white),
          ),
        ),
      ),
    );
  }
Here are some common properties of the Center widget:
child: The widget that should be centered both horizontally and vertically.
widthFactor: The factor by which to multiply the width of the child widget. For example, setting widthFactor to 2.0 would double the width of the child widget.
heightFactor: The factor by which to multiply the height of the child widget. For example, setting heightFactor to 0.5 would halve the height of the child widget.
 < Previous  Next >