LoginSignup
0
0

【Flutter】Wrapの要素に等間隔のスペースを開ける

Last updated at Posted at 2024-05-10

こんにちは。
今回は、Wrapの要素に等間隔のスペースを開ける方法を紹介します。

方法

スクリーンショット 2023-08-13 20.18.51.png

Wrapの引数「alignment」にWrapAlignment.spaceEvenlyを指定します。

使用例


class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: SizedBox(
        width: double.infinity,
        child: Wrap(
          alignment: WrapAlignment.spaceEvenly, //ここです!
          children: [
            for (var i = 0; i < 3; i++)
              Container(
                color: i.isEven ? Colors.pink : Colors.purple,
                width: 100,
                height: 100,
              ),
          ],
        ),
      ),
    );
  }
}

実行例

スクリーンショット 2024-05-10 10.09.08.png

最後に

ここまで読んでいただき、ありがとうございました!
いいねしてくれたら、スキップして喜びます:heartpulse:

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0