Mid*_*laj 7 dart flutter flutter-layout
在listview中添加gridview时如何解决flutter布局中的滚动问题。
在android studio java中我们使用NestedScrollView来解决这类问题
flutter的解决方案是什么?
我需要使用自定义视图和网格视图继续滚动列表视图,不会出现任何问题。
现在 gridview 只允许滚动 gridview
如果我滚动网格视图然后顶部 imageview 不滚动。如何解决这个问题?
body:
ListView(
children: <Widget>[
new Image.network("https://www.gizbot.com/img/2013/11/23-weekend-deals-top-10-latest-smartphones.jpg"),
Container(
height: 300.0,
child: GridView.count(
crossAxisCount: 3,
childAspectRatio: .6,
children: _list.map((p) => ProductManagment(p)).toList(),
),
)
],
)
Run Code Online (Sandbox Code Playgroud)
ListView您应该使用如下所示的 Column Widget而不是使用。
body:
Column(
children: <Widget>[
Container (
height: 150.0, // Set as you want
child: Image.network("https://www.gizbot.com/img/2013/11/23-weekend-deals-top-10-latest-smartphones.jpg")),
Container(
height: 300.0,
child: GridView.count(
crossAxisCount: 3,
childAspectRatio: .6,
children: _list.map((p) => ProductManagment(p)).toList(),
),
)
],
)
Because of `GridView` itself has scroll effect.
Run Code Online (Sandbox Code Playgroud)
编辑:
Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Container(
child: ListView(
children: <Widget>[
Column(
children: <Widget>[
Container(
height: 200,
child: Image.network(
"https://www.gizbot.com/img/2013/11/23-weekend-deals-top-10-latest-smartphones.jpg"),
),
ConstrainedBox(
constraints: BoxConstraints(
minHeight: 80, // Set as you want or you can remove it also.
maxHeight: double.infinity,
),
child: Container(
child: GridView.count(
crossAxisCount: 3,
shrinkWrap: true,
scrollDirection: Axis.vertical,
physics: NeverScrollableScrollPhysics(),
childAspectRatio: .6,
children: _list.map((p) => ProductManagment(p)).toList(),
),
),
)
],
),
],
),
));
Run Code Online (Sandbox Code Playgroud)
您必须ConstrainedBox与 setmaxHeight: double.infinity和 GridView.countset一起使用shrinkWrap: true,。并删除容器高度 300。
另外如果你想改变
Container(
height: 200,
child: Image.network(
"https://www.gizbot.com/img/2013/11/23-weekend-deals-top-10-latest-smartphones.jpg"),
),
Run Code Online (Sandbox Code Playgroud)
只是
Image.network("https://www.gizbot.com/img/2013/11/23-weekend-deals-top-10-latest-smartphones.jpg")
Run Code Online (Sandbox Code Playgroud)
比你可以改变它。
| 归档时间: |
|
| 查看次数: |
6660 次 |
| 最近记录: |