问题描述
我的页面代码是这样的.我需要滚动应用栏下方的部分.
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,它会导致 A 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)
这篇关于如何在颤动中滚动页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!