【发布时间】:2019-06-27 03:23:55
【问题描述】:
我在网格视图中输入了几张卡片。但是滚动条不起作用。有一个黄黑色条纹框,其中包含消息“屏幕底部溢出 129 像素。
Widget build(BuildContext context) {
double screenWidth = MediaQuery.of(context).size.width;
double screenHeight = MediaQuery.of(context).size.height;
return Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
Padding(
padding: EdgeInsets.only(top: 50.0),
child : Chip(
label : Text("Topics", style: TextStyle(color : Colors.white, fontSize: 25), textAlign: TextAlign.center,),
avatar: CircleAvatar(
child: Icon(Icons.clear_all, color: Colors.white,),
backgroundColor: Colors.blue[800],
),
backgroundColor: Colors.blue[800],
),
),
GridView.extent(
padding: EdgeInsets.all(10.0),
maxCrossAxisExtent: 200.0,
shrinkWrap: true,
physics: ScrollPhysics(),
primary: true,
children: <Widget>[
Card(
child : Container(
constraints: new BoxConstraints.expand(height: 0.3*screenHeight, width: 0.395*screenWidth),
alignment: Alignment.bottomCenter,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage("background/music.jpg"),
fit: BoxFit.fitWidth
),
),
child: Stack(children: <Widget>[
Positioned(
left:0.0, bottom: 0.0,
child: Padding(
padding: EdgeInsets.only(left: 5.0, bottom: 5.0),
child: Text("#music", style: TextStyle(color: Colors.cyan[900] ,fontSize: 25.0, decorationStyle: TextDecorationStyle.wavy)),
)
),
Positioned(
right:0.0, top: 0.0,
child: IconButton(icon: Icon(Icons.favorite_border), onPressed: (){int x =0;},),
)
]
)
)
),
Card(
child : Container(
constraints: new BoxConstraints.expand(height: 0.3*screenHeight, width: 0.395*screenWidth),
alignment: Alignment.bottomCenter,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage("background/sports.jpg"),
fit: BoxFit.fitWidth
),
),
child: Stack(children: <Widget>[
Positioned(
left:0.0, bottom: 0.0,
child: Padding(
padding: EdgeInsets.only(left: 5.0, bottom: 5.0),
child: Text("#sports", style: TextStyle(color: Colors.cyan[900] ,fontSize: 25.0, decorationStyle: TextDecorationStyle.wavy)),
)
),
Positioned(
right:0.0, top: 0.0,
child: IconButton(icon: Icon(Icons.favorite_border), onPressed: (){int x =0;},),
)
]
)
)
),
Card(
child : Container(
constraints: new BoxConstraints.expand(height: 0.3*screenHeight, width: 0.395*screenWidth),
alignment: Alignment.bottomCenter,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage("background/business.jpg"),
fit: BoxFit.fitWidth
),
),
child: Stack(children: <Widget>[
Positioned(
left:0.0, bottom: 0.0,
child: Padding(
padding: EdgeInsets.only(left: 5.0, bottom: 5.0),
child: Text("#entrepreneurship", style: TextStyle(color: Colors.cyan[900] ,fontSize: 25.0, decorationStyle: TextDecorationStyle.wavy)),
)
),
Positioned(
right:0.0, top: 0.0,
child: IconButton(icon: Icon(Icons.favorite_border), onPressed: (){int x =0;},),
)
]
)
)
),
Card(
child : Container(
constraints: new BoxConstraints.expand(height: 0.3*screenHeight, width: 0.395*screenWidth),
alignment: Alignment.bottomCenter,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage("background/tech.jpg"),
fit: BoxFit.fitWidth
),
),
child: Stack(children: <Widget>[
Positioned(
left:0.0, bottom: 0.0,
child: Padding(
padding: EdgeInsets.only(left: 5.0, bottom: 5.0),
child: Text("#technology", style: TextStyle(color: Colors.cyan[900] ,fontSize: 25.0, decorationStyle: TextDecorationStyle.wavy)),
)
),
Positioned(
right:0.0, top: 0.0,
child: IconButton(icon: Icon(Icons.favorite_border), onPressed: (){int x =0;},),
)
]
)
)
),
Card(
child : Container(
constraints: new BoxConstraints.expand(height: 0.3*screenHeight, width: 0.395*screenWidth),
alignment: Alignment.bottomCenter,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage("background/health.png"),
fit: BoxFit.fitWidth
),
),
child: Stack(children: <Widget>[
Positioned(
left:0.0, bottom: 0.0,
child: Padding(
padding: EdgeInsets.only(left: 5.0, bottom: 5.0),
child: Text("#health", style: TextStyle(color: Colors.cyan[900] ,fontSize: 25.0, decorationStyle: TextDecorationStyle.wavy)),
)
),
Positioned(
right:0.0, top: 0.0,
child: IconButton(icon: Icon(Icons.favorite_border), onPressed: (){int x =0;},),
)
]
)
)
),
],
)
],
);
}
此外,错误消息是这样说的: 在调试模式下在 SM N900 上启动 lib\main.dart... 构建 build\app\outputs\apk\debug\app-debug.apk。 I /颤振(6092):══╡渲染库╞═════════════════════════════════════════════ ═══════════════════════ I/flutter ( 6092): 布局期间抛出以下消息: I/flutter (6092):一个 RenderFlex 在底部溢出了 129 个像素。 I/flutter (6092):溢出的 RenderFlex 的方向为 Axis.vertical。 I/flutter (6092): RenderFlex 溢出的边缘在渲染中用黄色和 I/flutter (6092):黑色条纹图案。这通常是由于内容对于 RenderFlex 来说太大了。 I/flutter (6092):考虑应用弹性因子(例如,使用扩展小部件)来强制 I/flutter (6092):RenderFlex 以适应可用空间,而不是按其自然大小调整大小。 I/flutter(6092):这被认为是错误情况,因为它表明有内容不能被 I/颤动(6092):见过。如果内容合法地大于可用空间,请考虑使用 I/flutter ( 6092): ClipRect 小部件在放入 flex 之前,或者使用可滚动容器而不是 Flex, I/flutter (6092):像 ListView。 I/flutter (6092):有问题的特定 RenderFlex 是: I/flutter(6092):RenderFlex#7ae00 中继边界=up1 溢出 I/flutter(6092):创建者:列←主题页面←媒体查询←布局ID-[<_scaffoldslot.body>]← I/flutter (6092): CustomMultiChildLayout ← AnimatedBuilder ← DefaultTextStyle ← AnimatedDefaultTextStyle ← I/flutter (6092): _InkFeatures-[GlobalKey#2b99c 墨迹渲染器] ← NotificationListener ← I/flutter(6092):PhysicalModel←AnimatedPhysicalModel←⋯ I/flutter (6092): parentData: offset=Offset(0.0, 81.0); id=_ScaffoldSlot.body(可以使用大小) I/flutter (6092):约束:BoxConstraints(0.0
【问题讨论】:
标签: android ios flutter mobile-application