Siddhesh Nayak
Siddhesh Nayak

Reputation: 103

how to only scroll the children inside scrollview that has another scrollview

I have ListView and the children that has pdf document wrap inside singleChildScrollView want to only scroll the singleChildScrollView and not the listView after expansion

Below is my code

Column(
  children: <Widget>[
    Container(
      margin: EdgeInsets.only(right: 15, top: 10),
      width: size.width,
      child: Text("Title should be Pinned",
        textAlign: TextAlign.end,
      ),
    ),
    SizedBox(
      height: 20,
    ),
    Theme(
      data: ThemeData(
        accentColor: Colors.black,
        primaryColor: Colors.white24,
      ),
      child: Expanded(
        child: ListView.builder(
          itemCount: data.length,
          itemBuilder: (context, i) => ExpansionTile(
            title: Center(
              child: Text(
                "After Expansion this should be pinned and only children should be scrollable"
              ),
            ),
            children: [
              Container(
                child: SingleChildScrollView( //should be scrollable on expanded and not the title of ExpansionTile
                  child: SfPdfViewer.network(
                    '$url',
                  ),
                ),
              ),
            ],
          ),
        ),
      ),
    )
  ],
),

Upvotes: 0

Views: 2129

Answers (2)

Khawaja Furqan
Khawaja Furqan

Reputation: 100

warp your widget in a container and give it a height use the following parameters inside the scroll widget

shrinkwrap: false, primary: true

Upvotes: 1

Tasnuva Tavasum oshin
Tasnuva Tavasum oshin

Reputation: 4750

physics:  NeverScrollableScrollPhysics():

Add This Line to Your Widget then it will work

Upvotes: 0

Related Questions