问题
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