How to implement Scroll Controller in Flutter (Scroll Widget)?

柔情痞子 提交于 2020-03-28 06:58:56

问题


I am trying to implement a Scroll Widget in Flutter but not able to implement it. I saw many tutorials but they have implemented scroll widget with ListView or Grid View. In my case, I have Register page with multiple Text Inputs and Buttons. In this case, my page is not scrolling down please help someone.

div{
   Scroll Widget on the Register page.
}

回答1:


like this

class ExampleScroll extends StatefulWidget {
  @override
  _ExampleScrollState createState() => _ExampleScrollState();
}

class _ExampleScrollState extends State<ExampleScroll> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: SingleChildScrollView(
        child: Container(),
      ),
    );
  }
}



回答2:


Please wrap with a SingleChildScrollView Widget. Like this...

class AppDashBoard extends StatelessWidget {
    @override
    Widget build(BuildContext context) {
        return SingleChildScrollView(
            child: Container(
               child: Text('It Scrollable'),
            ),
        );
    }
}



回答3:


You can use SingleChildScrollView for scrolling like this.

SingleChildScrollView(
     child:Column(...)
)



回答4:


You can use SingleChildScrollView and provide scrolling contents as its child for more you can find on the documentation

https://api.flutter.dev/flutter/widgets/SingleChildScrollView-class.html

Eg:

    SingleChildScrollView(
// scrollable contents as child
         child:Column(...)
    )


来源:https://stackoverflow.com/questions/60520371/how-to-implement-scroll-controller-in-flutter-scroll-widget

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