有条件地将参数传递给图像

时间:2020-10-23 13:14:20

标签: flutter dart

此代码不起作用

// Uint8List imageBinary

final imageWidget = FadeInImagePlaceholder(
    image: imageBinary == null ? AssetImage('blank.png') : MemoryImage(imageBinary),
    // ...

引发此错误:

The argument type 'Object' can't be assigned to the parameter type 'ImageProvider<Object>'.

但是

但是此代码有效:

// Uint8List imageBinary

final imageWidget = FadeInImagePlaceholder(
    image: MemoryImage(imageBinary),
    // ...

此代码也适用:

// Uint8List imageBinary

final imageWidget = FadeInImagePlaceholder(
    image: AssetImage('blank.png'),
    // ...

为什么?

0 个答案:

没有答案