0

I'm trying a simple dashboard using Flutter web. In this whole project, I have not used any ScrollController, but I'm getting the error for ScrollPosition whenever I'm using the scroll wheel.

════════ Exception caught by animation library ═════════════════════════════════
The provided ScrollController is currently attached to more than one ScrollPosition.
════════════════════════════════════════════════════════════════════════════════

but this is not causing any problem in the UI.
Any suggestions will be helpful, Thank you.

2
  • can you add further code? Commented Mar 1, 2022 at 8:37
  • Can you share your code as well? It seems like you are giving the same ScrollController to two different UIs and if their viewport is different, then your app might crash. Commented Mar 1, 2022 at 8:37

1 Answer 1

1

I found the solution. This was caused by the ListView. I was using 3 columns, out of 3 One was ListView inside Drawer. And another 2 ware inside a SingleChildView. This was causing the issue. I added a ScrollController to the ListView and it was solved.

something like this

return Drawer(
      child: ListView(
        controller: ScrollController(initialScrollOffset: 0),
        children: [
          DrawerListTile(
            title: "Dashboard",
            svgSrc: "assets/icons/menu_dashbord.svg",
            press: () {},
          ),
          DrawerListTile(
            title: "Transaction",
            svgSrc: "assets/icons/menu_tran.svg",
            press: () {},
          ),
          DrawerListTile(
            title: "Store",
            svgSrc: "assets/icons/menu_store.svg",
            press: () {},
          ),
          DrawerListTile(
            title: "Profile",
            svgSrc: "assets/icons/menu_profile.svg",
            press: () {},
          ),
          DrawerListTile(
            title: "Settings",
            svgSrc: "assets/icons/menu_setting.svg",
            press: () {},
          ),
        ],
      ),
    );

The main reason for the error is have more than one ScrollView (so ListView, SingleChildScrollView, CustomScrollView, etc.) with the scrollDirection vertical and no scrollController in one route.

https://github.com/flutter/flutter/issues/93862

by making primary: false inside "SingleChildScrollView" also worked

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.