Câu hỏi phỏng vấn Flutter
Câu hỏi

When to use main Axis Alignment and cross Axis Alignment?

Câu trả lời

In Flutter, mainAxisAlignment and crossAxisAlignment are used to control the alignment of child widgets within a Row or Column widget. The main axis is the axis along which the children are laid out, while the cross axis is perpendicular to the main axis.

When to use mainAxisAlignment:

  • Use mainAxisAlignment to align the children along the main axis of a Row or Column.
  • For a Row, mainAxisAlignment aligns the children horizontally.
  • For a Column, mainAxisAlignment aligns the children vertically.
  • Common values for mainAxisAlignment include start, end, center, spaceBetween, spaceAround, and spaceEvenly.

When to use crossAxisAlignment:

  • Use crossAxisAlignment to align the children along the cross axis of a Row or Column.
  • For a Row, crossAxisAlignment aligns the children vertically.
  • For a Column, crossAxisAlignment aligns the children horizontally.
  • Common values for crossAxisAlignment include start, end, center, stretch, and baseline.

Here are some examples of when to use mainAxisAlignment and crossAxisAlignment:

  • If you have a Row with multiple children and want to align them vertically in the center, use `crossAxisAlignment: Cross...
entry

entry

Gợi ý câu hỏi phỏng vấn

senior

What is the difference between double.INFINITY and MediaQuery ?

middle

What are some pros of Flutter?

middle

What are Null-aware operators?

Bình luận

Chưa có bình luận nào

Chưa có bình luận nào