簡體   English   中英

我如何在容器中制作 NetworkImage?

[英]How i can make NetworkImage in Container?

如何使我的NetworkImage適合另一個Container中的Card

我嘗試添加BoxFit.fitHeight但未設置heightwidth工作正常但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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM