The PrimaryScrollController is currently attached to more than one ScrollPosition

1,322

use this way , please change the structure ,it is the best practice

Scaffold(
          body: LazyLoadScrollView(
              scrollOffset: 150,
              onEndOfPage: () {
                print('ppppppppppppppppppppppppppppppppppppppppp');
              },
              child: Scrollbar(
                  child: SingleChildScrollView(
                child: ListView.builder(
                    shrinkWrap: true,
                    itemCount: 10,
                    physics: ClampingScrollPhysics(),
                    itemBuilder: (_, i) {
                      return InkWell(
                          onTap: () {},
                          child: Container(
                              height: 200,
                              child: Text("kamu " + i.toString())));
                    }),
              )))),



and adjust the scrollOffset if you want ,

the debug will be

enter image description here

Share:
1,322
Rohmatul Laily
Author by

Rohmatul Laily

Updated on January 04, 2023

Comments

  • Rohmatul Laily
    Rohmatul Laily over 1 year

    I have a flutter design using lazyscrollview https://pub.dev/packages/lazy_load_scrollview , on another page, this scroll works fine, but in this design, when scrolling, it gets an error

    "The PrimaryScrollController is currently attached to more than one ScrollPosition."

    this is my code

    LazyLoadScrollView(
            onEndOfPage: () {},
            child: Scrollbar(
                child: ListView(
              children: [
                ListView.builder(
                    shrinkWrap: true,
                    itemCount: 10,
                    physics: NeverScrollableScrollPhysics(),
                    itemBuilder: (_, i) {
                      return InkWell(
                          onTap: () {},
                          child: Container(
                              height: 200,
                              child: Text("kamu " + i.toString())));
                    }),
              ],
            )))
    
    • Jinto Joseph
      Jinto Joseph about 2 years
      what is the parent of LazyLoadScrollView, is it Scaffold
    • Rohmatul Laily
      Rohmatul Laily about 2 years
      i put LazyLoadScrollView at body scaffold
    • Jinto Joseph
      Jinto Joseph about 2 years
      ok ,why are you using Scrollbar , ListView . you can use ListView.builder as a child of LazyLoadScrollView
  • Rohmatul Laily
    Rohmatul Laily about 2 years
    without the scrollbar, scroll indicator is not showing
  • Jinto Joseph
    Jinto Joseph about 2 years
    i am edited the Answer with scrollbar
  • Jinto Joseph
    Jinto Joseph about 2 years
    you can remove SingleChildScrollView if you want , its up to your use case