flutter 图像大小未减小

bq9c1y66  于 2023-02-13  发布在  Flutter
关注(0)|答案(1)|浏览(153)

这是它现在的样子。我想改变图像widthheight我该怎么做?

下面是我的代码:

class TabsFreelancerContainer extends StatelessWidget {
  final String image, tittle;

  const TabsFreelancerContainer({Key? key, required this.image, required this.tittle}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Column(
      mainAxisAlignment: MainAxisAlignment.center,
      children: [
        Container(
          height: Dimensions.height50,
          width: Dimensions.width50,
          decoration: BoxDecoration(
            boxShadow: <BoxShadow>[
              BoxShadow(
                color: Colors.black.withOpacity(0.5),
                blurRadius: Dimensions.radius10,
                offset: const Offset(0.0, 5),
              )
            ],
            borderRadius: BorderRadius.circular(Dimensions.radius10),
            color: Colors.white,
          ),
          child: CachedNetworkImage(
            imageUrl: image,
            fit: BoxFit.contain,
            placeholder: (context, url) => const Center(child: CircularProgressIndicator()),
            errorWidget: (context, url, error) => const Icon(Icons.error),
          ),
        ),
        SizedBox(
          height: 5.h,
        ),
        Expanded(child: SmallText(text: tittle, color: Colors.black, size: Dimensions.font13))
      ],
    );
  }
}

我向她展示了这些TabsFreelancerContainer

Row(
                    mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                    children: widget.list
                        .map(
                          (e) => InkWell(
                            onTap: () {
                              categoryDetailService.offSet = 1;
                              (categoryDetailService.data ?? []).clear();
                              categoryDetailService.fetchData(context, e.id.toString());
                            },
                            child: Padding(
                              padding: EdgeInsets.all(Dimensions.height10 - 2),
                              child: Tab(
                                height: Dimensions.height70 + 5,
                                child: TabsFreelancerContainer(
                                  image: e.photo,
                                  tittle: Get.put(AppController()).isEnglish() ? e.enName : e.arName,
                                ),
                              ),
                            ),
                          ),
                        )
                        .toList(),
                  ),
vx6bjr1n

vx6bjr1n1#

您可以向Container添加填充,以便它可以基于填充值更改Widget的高度和宽度:

Container(
height: Dimensions.height50,
width: Dimensions.width50,
padding: EdgeInsects.all(10),
…

相关问题