![](/img/trans.png)
[英]How can i catch exception when loading the image in the NetworkImage?
[英]How i can make NetworkImage in Container?
如何使我的NetworkImage
適合另一個Container
中的Card
?
我嘗試添加BoxFit.fitHeight
但未設置height
, width
工作正常但height
不起作用。
我在Listview.builder
中制作了一個CardView
並且我希望我的圖像height
適合我的卡片左側有一些width
,我怎樣才能使它適合另一個Card
正在工作的容器卡中的height
Container(
height: MediaQuery.of(context).size.height*.20,
child: Card(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(15),
),
elevation: 5,
child: TextButton(
onPressed: () {
Navigator.push(context, MaterialPageRoute(builder: (context) => ViewDonation(donation: donation,),));
},
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Container(
height: MediaQuery.of(context).size.height*.26,
width: MediaQuery.of(context).size.height*.26,
decoration: BoxDecoration(
borderRadius:BorderRadius.only(
bottomLeft: Radius.circular(15) ,
topLeft: Radius.circular(15) ,
bottomRight: Radius.circular(15) ,
topRight: Radius.circular(15) ,
),
/* boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.8),
spreadRadius: 2,
blurRadius: 1, // changes position of shadow
),
],*/
image: DecorationImage(
image: NetworkImage("https://emedz.net/images/doctors/20210213_163233.jpg"),
fit: BoxFit.cover,
)
),
),
SizedBox(width: MediaQuery.of(context).size.width* .04,),
Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(child: Text(donation.title,style: TextStyle( fontSize: 14, fontWeight: FontWeight.bold, color: AppColor.primary),)),
Center(child: Text(donation.contact,style: TextStyle( fontSize: 10),)),
Row(
children: [
Text('Rs. '+donation.amountRequired+'/-',style: TextStyle( fontSize: 10, color: AppColor.primary ),),
SizedBox(width: 5,),
],
),
Center(child: Text('Required till: '+donation?.dueDate??"",style: TextStyle( fontSize: 10),)),
],
),
EdgeInsets.zero,),onPressed: () {
// // Navigator.push(context, MaterialPageRoute(builder: (context) => ViewDonation(donation: donation,),));
],
),
),
),
),
我的問題是身高不適合卡
根據您的圖像配給,您可以使用下面的小部件,例如。 假設您的圖像分辨率為 1000*500,然后選擇 1/2 的配給
AspectRatio(
aspectRatio: 16 / 9,
child:NetworkImage("https://emedz.net/images/doctors/20210213_163233.jpg"),
),
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.