Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

scrollbar with drag effect in flutter

I need to implement scrolling bars in form. This is for web users by clicking on scrolling bar, they can navigate. Scrollbar class in flutter works for touch device, but not with mouse based input. I've tried using "draggable_scrollbar" library from pub.dev, however it only accepts ListView as child.

My code:

Widget build(BuildContext context) {
  return Scaffold(
    appBar: AppBar(
      title: Text('My form'),
    ),
    body: Padding(
      padding: const EdgeInsets.all(16.0),
      child: Scrollbar(
        child: SingleChildScrollView(
          child: Form(...),
        ),
      ),
    ),
  );
}

Thanks in advance.

like image 733
Sharma Rahul Avatar asked Oct 27 '25 23:10

Sharma Rahul


1 Answers

Hope this can work for you.

Widget build(BuildContext context) {
  return Scaffold(
     appBar: AppBar(
       title: Text('My form'),
     ),
     body: Padding(
       padding: const EdgeInsets.all(16.0),
       child: Scrollbar(
         child: SingleChildScrollView(
           child: DraggableScrollbar.rrect(
             controller: myScrollController,
             child: ListView.builder(
               controller: myScrollController,
               itemCount: 1,
               itemBuilder: (context, index) {
                 return Form();
               },
             ),
           ),
         ),
       ),
     ),
   );
}
like image 116
Sanket Vekariya Avatar answered Oct 29 '25 17:10

Sanket Vekariya



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!