[Flutter]AppBarのタイトルを右に寄せるには?

Flutter

どうも、ちょげ(@chogetarou)です。

AppBarのタイトルを右に寄せるには、どうしたらいいのでしょうか?

スポンサーリンク

方法

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Row(
            mainAxisAlignment: MainAxisAlignment.end,
            children: [Text("Title")]),
      ),
      body: Center(),
    );
  }

AppBarのタイトルを右側に寄せるには、引数「title」にRowを指定します。

そして、Rowの引数「mainAxisAlignment」に、「MainAxisAlignment.end」を指定することで、タイトルが右に寄せられます。

AppBarの引数「title」は、テキストだけでなく、ウェジェットなら何でも使うことが出来ます。

コメント

タイトルとURLをコピーしました