Chrome Extension

Center Row widget children vertically and horizontally Flutter

To center all widgets that exist inside a Row widget, you can use crossAxisAlignment and mainAxisAlignment properties of Row widget.
Row(
    crossAxisAlignment: CrossAxisAlignment.center,
    mainAxisAlignment: MainAxisAlignment.center,
    children: [
        Text("text 1"),
        Text("text 2"),
    ]
)
Best JSON Validator, JSON Tree Viewer, JSON Beautifier at same place. Check how cool is the tool

Center Row widget Children vertically

You can use the crossAxisAlignment property to center Row children vertically.

Row(
    crossAxisAlignment: CrossAxisAlignment.center,
    children: [
        Text("text 1"),
        Text("text 2"),
    ]
)

Center Row widget Children horizontally

You can use the MainAxisAlignment property to center Row children horizontally.

Row(
    mainAxisAlignment: MainAxisAlignment.center,
    children: [
        Text("text 1"),
        Text("text 2"),
    ]
)
Was this helpful?
0 Comments
Join Devsheet Ask a Question