Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter - How to scroll Container over another

I'm begginning Flutter and I'm searching to scroll ListView over a Container like below

scrollover

like image 563
pefr Avatar asked Oct 23 '25 00:10

pefr


2 Answers

You can use DraggableScrollableSheet

DraggableScrollableSheet(
  builder: (context, scrollController) {
    return SingleChildScrollView(
      controller: scrollController,
      child: Column(
        children: [],
      ),
    );
  },
)

You can follow the doc example

A complete widget


class App extends StatelessWidget {
  const App({Key? key}) : super(key: key);

  openDraggable(context) {
    showModalBottomSheet(
        isScrollControlled: true,
        shape: RoundedRectangleBorder(
            borderRadius: BorderRadius.only(
          topLeft: Radius.circular(22),
          topRight: Radius.circular(22),
        )),
        context: context,
        builder: (context) => DraggableScrollableSheet(
              maxChildSize: 1,
              initialChildSize: .4,
              expand: false,
              builder: (context, scrollController) {
                return SingleChildScrollView(
                  controller: scrollController,
                  child: Column(
                    children: [
                      for (int i = 0; i < 32; i++)
                        ListTile(
                          title: Text("item"),
                        ),
                    ],
                  ),
                );
              },
            ));
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            ElevatedButton(
              onPressed: () {
                openDraggable(context);
              },
              child: Text("open"),
            )
          ],
        ),
      ),
    );
  }
}
like image 68
Yeasin Sheikh Avatar answered Oct 24 '25 13:10

Yeasin Sheikh


Don't use DraggableScrollableSheet. instead of that widget use the sliver widget, this widget is amazing, you can use this article and this

like image 25
aminjafari-dev Avatar answered Oct 24 '25 15:10

aminjafari-dev



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!