【问题标题】:The argument type 'Image' can't be assigned to the parameter type 'ImageProvider<Object>'参数类型 \'Image\' 不能分配给参数类型 \'ImageProvider<Object>\'
【发布时间】:2022-08-18 18:31:23
【问题描述】:

我尝试了将 image.net work 放在它工作的孩子中的容器,但我需要自定义图像的边框。我应该如何解决它?

Expanded(
                                            child: Align(
                                              alignment: Alignment.center,
                                              child: Container(
                                                height: 45, //height, //155,
                                                width: 45, //width, //155,
                                                decoration: BoxDecoration(
                                                  color:
                                                      const Color(0xff7c94b6),
                                                  image: DecorationImage(
                                                    image: Image.network(state
                                                        .offerConfirm
                                                        .ownImage[index]),
                                                    fit: BoxFit.cover,
                                                  ),
                                                  borderRadius:
                                                      BorderRadius.circular(12),
                                                ),
                                              ),
                                            ),
                                            flex: 3,
                                          ),

    标签: flutter dart flutter-image


    【解决方案1】:

    将图像装饰更改为:

    decoration: BoxDecoration(
          image: DecorationImage(image: NetworkImage("urlImage"),
          fit: BoxFit.cover)
        ),
    
    

    完整代码:

    Expanded(
                                                child: Align(
                                                  alignment: Alignment.center,
                                                  child: Container(
                                                    height: 45, //height, //155,
                                                    width: 45, //width, //155,
                                                    decoration: BoxDecoration(
                                                      color:
                                                          const Color(0xff7c94b6),
                                                      image: DecorationImage(
                                                        image: NetworkImage(state
                                                            .offerConfirm
                                                            .ownImage[index])
                                                        fit: BoxFit.cover,
                                                      ),
                                                      borderRadius:
                                                          BorderRadius.circular(12),
                                                    ),
                                                  ),
                                                ),
                                                flex: 3,
                                              ),
    

    【讨论】:

    • 你能把答案标记为正确吗?并进行投票,以便其他人可以使用它。
    • 当然,兄弟,我必须等待大约 10 分钟才能获得标记。
    猜你喜欢
    • 2021-06-08
    • 2023-02-10
    • 2022-08-19
    • 2021-11-20
    • 2023-02-18
    • 2020-01-23
    • 1970-01-01
    • 2021-09-30
    • 2021-12-24
    相关资源
    最近更新 更多