LoginSignup
0
0

More than 1 year has passed since last update.

Flutter スクロールバーを追加したのに表示されなかった対応

Posted at

概要

Flutterでアプリを作っていてドロワーメニュー(Drawer)にListViewを乗せていました。
そこに常時スクロールバーを表示したくて単純にListViewに対してScrollbarでラップしてみたのですが
確認すると以下のようなエラーが出たのでその対応を共有します。

エラー内容

When Scrollbar.thumbVisibility is true, the associated ScrollController must only have one ScrollPosition attached.

対応内容

どうやらScrollBarとListViewに同じコントローラーを設定しないといけないようでした。
コードは以下となります。

final scrollController = ScrollController();// これを追加

Expanded(
  child: Scrollbar(
    controller: scrollController, // これを追加
    thumbVisibility: true,
    radius: const Radius.circular(15),
    child: ListView(
      controller: scrollController,// これを追加
      children: [
       ・・・・
      ],
    ),
  ),
),
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