Help us understand the problem. What is going on with this article?

FlutterのRowで高さが小さい方のビューをボトムに揃える

More than 1 year has passed since last update.

Rowで複数のビューを配置するときにデフォルトの状態だとそれぞれのビューの高さが異なる場合、
大きいビューを基準にしてその中央に揃う形でビューが配置されます。

こんな感じ↓

しかしこの小さいビューを大きいビューの上や下に整列させたいこともあります。
そんなときはRowのcrossAxisAlignmentプロパティを指定します。
crossAxisAlignmentはRowが水平方向に要素が並ぶのに対して交差する方向、つまり垂直方向のalignを指定することができます。

例えば以下のようにCrossAxisAlignment.endを指定すると垂直方向のend、つまりボトムで整列させることができます。

  Widget build(BuildContext context) {
    return MaterialApp(
      home: Align(
        alignment: Alignment.center,
        child: Row(
          crossAxisAlignment: CrossAxisAlignment.end,
          children: <Widget>[
            Container(
              color: Colors.blue,
              width: 200.0,
              height: 200.0,
            ),
            Container(
              color: Colors.red,
              width: 50.0,
              height: 50.0,
            )
          ],
        ),
      ),
    );
  }

結果↓

Why do not you register as a user and use Qiita more conveniently?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away