1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

【Flutter】ListView.builderが動かない時の対処法

Last updated at Posted at 2024-03-06

こんにちは。
今回は、ListView.builderが動かない時の対処法を紹介します。

方法

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

ListView.Builderのプロパティに「physics: const NeverScrollableScrollPhysics()」が入っていませんか?
これを消すだけで動きます。

使用例


  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: ListView.builder(
        physics: const NeverScrollableScrollPhysics(), //これを消す!!!!
        scrollDirection: Axis.horizontal,
        itemCount: 10,
        itemBuilder: (context, index) {
          return Padding(
            padding: const EdgeInsets.all(8.0),
            child: Container(
              width: 100,
              height: 20,
              color: Colors.pink,
              child: Text('$index'),
            ),
          );
        },
      ),
    );
  }
}


実行例

listview.gif

最後に

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

1
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
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?