如何滚动页面 [英] How to scroll page in flutter
问题描述
我的页面代码是这样的。我需要在appbar下方滚动部分。
My code for a page is like this. i need to scroll part below appbar.
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(... ),
body: new Stack(
children: <Widget>[
new Container(
decoration: BoxDecoration(
image: DecorationImage(...),
new Column(children: [
new Container(...),
new Container(...... ),
new Padding(
child: SizedBox(
child: RaisedButton(..),
),
new Divider(),
new Column(
children: <Widget>[
new Container(
child: new Row(
children: <Widget>[
new Expanded(
child: new Text( ),
),
new IconButton(
icon: IconButton(..),
onPressed: () {
_changed(true, "type");
},
),
],
),
),
visibilityPropertyType
? new Container(
margin: EdgeInsets.all(24.0),
child: new Column(
children: <Widget>[
new Row(
children: <Widget>[
new Expanded(... ),
new RaisedButton(..)
],
),
new Padding(
padding: const EdgeInsets.only(top: 10.0),
child: new Row(
mainAxisAlignment:
MainAxisAlignment.spaceEvenly,
children: <Widget>[
new Column(
children: <Widget>[
new Row(
children: <Widget>[.. ]),
new Row(
children: <Widget>[]),
new Row(
children: <Widget>[]),
new Row(
children: <Widget>[],
),
new Column(
children: <Widget>[
new Row(
children: <Widget>[],
),
],
),
],
),
),
],
))
: new Container(),
],
),
new Divider(
color: Colors.white,
)
])
],
),
);
}
我需要使身体部位可滚动。我如何实现该滚动。
如果存在任何自定义滚动方法。我已经尝试过 Scrollable
和 SingleChildScrollView
,但是不能满足我的需求。
当我使用 SinglechildScrollView
时,发生了一个错误,BoxConstraints强制将其设置为无限的高度。如果我删除LayoutBuilder,则会导致 RenderFlex底部溢出22个像素错误
I need to make body part scrollable. How can i implement that scroll.
If there is any custom scroll method existing. i have tried Scrollable
and SingleChildScrollView
but does not meet up with my needs.
When i used SinglechildScrollView
it occurs an error BoxConstraints forces an infinite height. if i removed LayoutBuilder it causes A RenderFlex overflowed by 22 pixels on the bottom
error
推荐答案
将小部件树包装在SingleChildScrollView中
Wrap your widget tree inside a SingleChildScrollView
body: SingleChildScrollView(
child: Stack(
children: <Widget>[
new Container(
decoration: BoxDecoration(
image: DecorationImage(...),
new Column(children: [
new Container(...),
new Container(...... ),
new Padding(
child: SizedBox(
child: RaisedButton(..),
),
....
...
); // Single child scroll view
请记住,SingleChildScrollView只能有一个直接小部件(就像Android中的ScrollView)
Remember, SingleChildScrollView can only have one direct widget (Just like ScrollView in Android)
这篇关于如何滚动页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!