flutter - RenderIndexedSemantics 对象在布局期间被赋予了无限大小。当我使用脚手架楔形
问题描述
当我在容器小部件中使用 Scaffold 时,会发生此错误 RenderIndexedSemantics 对象在布局期间被赋予了无限大小。这可能意味着它是一个试图尽可能大的渲染对象,但它被放在另一个渲染对象中,允许其子级选择自己的大小。提供无界高度约束的最近祖先是:RenderIndexedSemantics#c08ed relayoutBoundary=up16 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE ...需要合成... parentData: index=0; layoutOffset=0.0(可以使用size)...约束:BoxConstraints(w=296.0,0.0<=h<=Infinity)...语义边界...size:Size(296.0,Infinity)...index:0应用于 RenderIndexedSemantics 的约束是: BoxConstraints(w=296.0, 0.0<=h<=Infinity) 它给出的确切大小是:
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
import '../catalog.dart';
import '../theme.dart';
import 'HomeExtended_Page.dart';
class modelLlist extends StatelessWidget {
@override
Widget build(BuildContext context) {
return ListView.builder(
shrinkWrap: true,
itemCount: Model.product.length,
itemBuilder: (context,index){
final catalog=Model.product[index];
return InkWell(
onTap: ()=>Navigator.push(context, MaterialPageRoute(builder: (context) =>HomeExtend(catalog:catalog),
),
),
child: catlogitem(catalog:catalog));
});
}
}
class catlogitem extends StatelessWidget {
@override
final item catalog;
const catlogitem({Key? key, required this.catalog}) :
assert(catalog!=null),
super(key: key);
Widget build(BuildContext context) {
return Scaffold(
body: Container(
height: 130,
child: Card(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10),
),
color: Colors.white,
elevation: 0,
child: Row(
children: [
Hero(
tag: Key(catalog.id),
child: catalogimage(image:catalog.imageurl)),
SizedBox(
width: 10 ,
),
Column(
crossAxisAlignment: CrossAxisAlignment.baseline,
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
textBaseline: TextBaseline.alphabetic,
children: [
Text(catalog.name,style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w800,
),
),
/*SizedBox(
height: 10 ,
),*/
//Padding(padding: EdgeInsets.only(top: 8.0),),
Text(catalog.dec,style: TextStyle(
fontSize: 10,
),
),
ButtonBar(
alignment: MainAxisAlignment.spaceBetween,
buttonPadding: EdgeInsets.zero,
children: [
Text("\$"+catalog.price.toString(),style: GoogleFonts.bebasNeue(
textStyle:TextStyle(
fontWeight: FontWeight.bold,
fontSize: 15,
),),),
SizedBox(
width: 80,
),
ElevatedButton(onPressed: (){},
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all(MyTheme.black),
shape: MaterialStateProperty.all(StadiumBorder(),
),
),
child: Text("Buy"),
),
],
)
],
)
],
),
),
),
);
}
}
class catalogimage extends StatelessWidget {
final String image;
const catalogimage({Key? key, required this.image}) : assert(image!=null),super(key: key);
@override
Widget build(BuildContext context) {
return Container(
padding: EdgeInsets.symmetric(horizontal: 0.0),
height:80,
width: 80,
decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(16.0)),
),
child: new Image.asset(image),
);
}
}
解决方案
推荐阅读
- vue.js - 在 VueJs 应用程序中实现表情符号
- asp.net-mvc - ASP.NET MVC 大文件上传到 REST API
- vba - 计算不同大小范围内的行和列
- java - java 编译器是否理解 if 语句中给出的条件?
- java - BuilderExample 类型的方法 builder() 未定义
- r - 使用复选框以闪亮的方式显示数据子集
- sql - 从表名和值是参数 SQL 的查询中检索信息
- python - 如何设置激活环境的jupyter实验室路径
- javascript - node-red 循环遍历全局变量
- javascript - asp.net mvc 如何将视图模型和输入文本传递给控制器?