0

I am trying to add scrollbars vertically and horizontally. I have used Adaptive Scrollbar package.

return LayoutBuilder(
  builder: (context, constraints) {
    return Padding(
      padding: const EdgeInsets.all(10.0),
      child: Container(
        color: Colors.yellow,
        width: constraints.maxWidth - 20,
        height: constraints.maxHeight - 20,
        child: AdaptiveScrollbar(
          width: 20,
          controller: _verticalScrollController,
          position: ScrollbarPosition.right,
          child: SingleChildScrollView(
            controller: _verticalScrollController,
            scrollDirection: Axis.vertical,
            child: AdaptiveScrollbar(
              controller: _horizontalScrollController,
              position: ScrollbarPosition.bottom,
              child: SingleChildScrollView(
                controller: _horizontalScrollController,
                scrollDirection: Axis.horizontal,
                child: Column(
                  children: [
                    Row(
                      children: [
                        Container(
                          color: Colors.red,
                          width: 200,
                          child: Text("Test"),
                        ),
                        Container(
                          color: Colors.pink,
                          width: 200,
                          child: Text("Test"),
                        ),
                        Container(
                          color: Colors.orange,
                          width: 200,
                          child: Text("Test"),
                        ),
                        Container(
                          color: Colors.purple,
                          width: 200,
                          child: Text("Test"),
                        ),
                        Container(
                          color: Colors.black,
                          width: 200,
                          child: Text("Test"),
                        ),
                        Container(
                          color: Colors.blue,
                          width: 200,
                          child: Text("Test"),
                        ),
                        Container(
                          color: Colors.green,
                          width: 200,
                          child: Text("Test"),
                        ),
                      ],
                    ),
                    for (int a = 0; a < 100; a++)
                      Row(
                        children: [
                          Container(
                            color: Colors.red,
                            width: 200,
                            child: Text("Test"),
                          ),
                          Container(
                            color: Colors.pink,
                            width: 200,
                            child: Text("Test"),
                          ),
                          Container(
                            color: Colors.orange,
                            width: 200,
                            child: Text("Test"),
                          ),
                          Container(
                            color: Colors.purple,
                            width: 200,
                            child: Text("Test"),
                          ),
                          Container(
                            color: Colors.black,
                            width: 200,
                            child: Text("Test"),
                          ),
                          Container(
                            color: Colors.blue,
                            width: 200,
                            child: Text("Test"),
                          ),
                          Container(
                            color: Colors.green,
                            width: 200,
                            child: Text("Test"),
                          ),
                        ],
                      ),
                  ],
                ),
              ),
            ),
          ),
        ),
      ),
    );
  },
);

I want the scrollbars to be on the right and bottom, and I have also specified the position in the code, but still it shows on right and top.

Current output is shown in the screenshot below

enter image description here

I am using Adaptive Scrollbars just to make the scrollbars visible on the web.

Saad Bashir
  • 4,341
  • 8
  • 30
  • 60

1 Answers1

0

You make check this

Link to the output

LayoutBuilder(
  builder: (context, constraints) {
    return Padding(
      padding: const EdgeInsets.all(10.0),
      child: Container(
        color: Colors.yellow,
        width: constraints.maxWidth - 20,
        height: constraints.maxHeight - 20,
        child: AdaptiveScrollbar(
          width: 20,
          controller: _verticalScroll,
          position: ScrollbarPosition.right,
          child: AdaptiveScrollbar(
            controller: _horizontalScroll,
            position: ScrollbarPosition.bottom,
            child: SingleChildScrollView(
              controller: _horizontalScroll,
              scrollDirection: Axis.horizontal,
              child: SingleChildScrollView(
                controller: _verticalScroll,
                child: Column(
                  children: [
                    Row(
                      children: [
                        Container(
                          color: Colors.red,
                          width: 200,
                          child: Text("Test"),
                        ),
                        Container(
                          color: Colors.pink,
                          width: 200,
                          child: Text("Test"),
                        ),
                        Container(
                          color: Colors.orange,
                          width: 200,
                          child: Text("Test"),
                        ),
                        Container(
                          color: Colors.purple,
                          width: 200,
                          child: Text("Test"),
                        ),
                        Container(
                          color: Colors.black,
                          width: 200,
                          child: Text("Test"),
                        ),
                        Container(
                          color: Colors.blue,
                          width: 200,
                          child: Text("Test"),
                        ),
                        Container(
                          color: Colors.green,
                          width: 200,
                          child: Text("Test"),
                        ),
                      ],
                    ),
                    for (int a = 0; a < 100; a++)
                      Row(
                        children: [
                          Container(
                            color: Colors.red,
                            width: 200,
                            child: Text("Test"),
                          ),
                          Container(
                            color: Colors.pink,
                            width: 200,
                            child: Text("Test"),
                          ),
                          Container(
                            color: Colors.orange,
                            width: 200,
                            child: Text("Test"),
                          ),
                          Container(
                            color: Colors.purple,
                            width: 200,
                            child: Text("Test"),
                          ),
                          Container(
                            color: Colors.black,
                            width: 200,
                            child: Text("Test"),
                          ),
                          Container(
                            color: Colors.blue,
                            width: 200,
                            child: Text("Test"),
                          ),
                          Container(
                            color: Colors.green,
                            width: 200,
                            child: Text("Test"),
                          ),
                        ],
                      ),
                  ],
                ),
              ),
            ),
          )
        ),
      ),
    );
  },
)
Sowat Kheang
  • 668
  • 2
  • 4
  • 12