Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

draggable scrollbar on form flutter

Tags:

flutter

dart

I'm trying to place a draggable scrollbar on my flutter Form, so the web users can click and drag to the screen bottom. The flutter Scrollbar class is fine for touchscreen devices, for mouses is not!

I've tried using draggable_scrollbar, however it only accepts ListView as child.

Here is my current code structure:

    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(...),
            ),
          ),
        ),
      );
    }
like image 550
WellingtonD Avatar asked Jan 25 '23 06:01

WellingtonD


1 Answers

In Draggable Scrollbar you can try using ListView.builder with only 1 item which is your form, as shown below.

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 63
Mohamed Abdou Avatar answered Feb 02 '23 21:02

Mohamed Abdou