我试图在一个页面中构建一个简单的产品页面,但它总是显示白屏,根本没有数据!
我尝试在列和相同的空白屏幕之前添加SafeArea 任何帮助!
return Column(children: <Widget>[
Expanded(
child: ListView(children: <Widget>[
CarouselSlider(
height: MediaQuery.of(context).size.height * 0.20,
items: [1, 2, 3, 4, 5].map((i) {
return Builder(builder: (BuildContext context) {
return Container(
width: MediaQuery.of(context).size.width,
margin: EdgeInsets.symmetric(horizontal: 5.0),
child: Image.asset('assets/ad.jpg', fit: BoxFit.cover));
});
}).toList()),
Container(
padding: EdgeInsets.only(top: marginFixed * 2, right: marginFixed),
alignment: Alignment(1, 0),
child: Text("الأقسام :")),
Padding(
padding: const EdgeInsets.all(8.0),
child: GridView.builder(
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2),
itemCount: 10,
itemBuilder: (BuildContext context, int index) {
return GestureDetector(
onTap: () {},
child: Card(
color: StyleCustom().red,
child: Column(children: <Widget>[
Container(
color: Colors.white,
height: MediaQuery.of(context).size.width / 2.5,
child: Image.asset('assets/ad1.png',
fit: BoxFit.fill)),
Text("عروض حصرية",
style: TextStyle(color: Colors.white))
])));
}))
]))
]);
结果:
答案 0 :(得分:0)
通过添加解决:
shrinkWrap: true,
physics: ScrollPhysics(),
在GridView内