Make scrollbar be able to chosen for faster scrolling

Viewed 86

I want to make my scrollbar be able to chosen and user can click and hold up or down for faster scrolling , but I don't know how. Can you give me somes suggestions, please?

HI i just figured out, I just need to add interactive:true to my Scrollbar widget and it's done. Btw thank you Mehran Ullah for your sharing.

2 Answers

I think the question is not completely clear. If you don't have code to show, maybe explain what you want a bit more precisely, or add an image showing what you want.

If you add a ScrollController to your scrollable Widget, you can use the animateTo function (documentation can be found here) to scroll to a specific point: Maybe this can help you achieve what you want.

Just copy-paste my code and enjoy

class MyApp extends StatelessWidget {
      @override
      Widget build(BuildContext context) {
        return MaterialApp(
            home: Scaffold(
                body: SafeArea(
                    child: Scrollbar(
                      isAlwaysShown: true,
                      showTrackOnHover: true,
                      thickness: 25,
                      hoverThickness: 34,
                      radius: Radius.circular(12),
                      
                      
                      
                      child: SingleChildScrollView(
                        child: Column(
                          children: <Widget>[
    
                            Container(
                              color: Colors.pink, // Yellow
                              height: 120.0,
                            ),
    
                            Image.network('https://flutter-examples.com/wp-content/uploads/2019/09/blossom.jpg',
                                width: 300, height: 200, fit: BoxFit.contain),
    
                            Image.network('https://flutter-examples.com/wp-content/uploads/2019/09/sample_img.png',
                                width: 200, fit: BoxFit.contain),
    
                            Container(
                              color: Colors.blue, // Yellow
                              height: 120.0,
                            ),
    
                            Text('Some Sample Text - 1', style: TextStyle(fontSize: 28)),
    
                            Container(
                              color: Colors.orange, // Yellow
                              height: 120.0,
                            ),
    
                            Image.network('https://flutter-examples.com/wp-content/uploads/2019/09/blossom.jpg',
                                width: 300, height: 200, fit: BoxFit.contain),
    
                            Text('Some Sample Text - 2', style: TextStyle(fontSize: 28)),
    
                            Text('Some Sample Text - 3', style: TextStyle(fontSize: 28)),
    
                          ],
                        ),
                      ),
                    )
                )
            )
        );
      }
    }
Related