scrollbar with drag effect in flutter

与世无争的帅哥 提交于 2021-02-10 04:00:25

问题


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.


回答1:


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();
               },
             ),
           ),
         ),
       ),
     ),
   );
}


来源:https://stackoverflow.com/questions/61230354/scrollbar-with-drag-effect-in-flutter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!