Flutter BlendMode“未定义吸气剂”

时间:2020-01-25 20:58:47

标签: flutter dart

background: ShaderMask(
    shaderCallback: (rect) {
      return LinearGradient(
        begin: Alignment.topCenter,
        end: TextAlignment.bottomCenter,
        colors: [Colors.black, Colors.transparent],
      ).createShader(Rect.fromLTRB(0, 0, rect.width, rect.height));
    },
    blendMode: BlendMode.dstIn,
    child: FadeInImage.assetNetwork(
      placeholder: "assets/placeholder.jpg",
      image: globals.me["avatar"].replaceAll("\\", ""),
    ),
  ),

当我调试此代码时,出现此错误:

The getter 'dstIn' isn't defined for the class 'BlendMode'.
Try importing the library that defines 'dstIn', correcting the name to the name of an existing getter, or defining a getter or field named 'dstIn'.

我找不到任何解决方案。我该如何解决?

1 个答案:

答案 0 :(得分:0)

未定义getter,因为未定义类。如果您尚未导入dart:ui(对于BlendMode),通常会出现此错误。
因此,请确保在文件顶部具有以下导入:

import 'dart:ui';

如果您在其他类中看到此错误,请找出该类(或此处的enum)所属的库并将其导入。