scrollbar with drag effect in flutter

1,152

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();
               },
             ),
           ),
         ),
       ),
     ),
   );
}
Share:
1,152
Sharma Rahul
Author by

Sharma Rahul

Android Developer

Updated on December 19, 2022

Comments

  • Sharma Rahul
    Sharma Rahul over 1 year

    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.