小编ibr*_*pie的帖子

失败的断言宽度 > 0.0':在 FittedBox 的 Container 中放置单个图像时不正确

当我将 Image.network 放置在作为 FittedBox 子项的 Row 或 Container 中时,查看它会导致错误/崩溃。

FittedBox 实际上使用一个函数作为它的子函数,它根据图像的数量返回一个小部件。当有两个图像时,它返回一个 Row,其中每个图像作为其子级,它可以正常工作,但是当只有一个时,无论我返回一个以图像为子级的 Container 还是返回一个带有单个子级的 Row 都会发生错误是形象。

            Container(
              child: FittedBox(child: status.statusFiles()),
            ),
Run Code Online (Sandbox Code Playgroud)

状态文件:

    return Container(
        child: 
          Image.network(
            this.files[0].thumbnailUrl,
            fit: BoxFit.contain,
          ),
        );
Run Code Online (Sandbox Code Playgroud)

我希望 FittedBox 包含适合的最大尺寸的图像,但在呈现小部件时出现以下错误

I/flutter (26617): ??? EXCEPTION CAUGHT BY RENDERING LIBRARY ??????????????????????????????????????????????????????????
I/flutter (26617): The following assertion was thrown during performLayout():
I/flutter (26617): 'package:flutter/src/rendering/box.dart': Failed assertion: line 307 pos 12: 'width > 0.0': is not
I/flutter (26617): true.
...
I/flutter (26617): When the exception was thrown, this was the …
Run Code Online (Sandbox Code Playgroud)

crash android dart flutter

9
推荐指数
3
解决办法
5012
查看次数

标签 统计

android ×1

crash ×1

dart ×1

flutter ×1