【问题标题】:Flutter BlendMode 'the getter isn't defined'Flutter BlendMode'未定义吸气剂'
【发布时间】:2020-01-25 20:58:47
【问题描述】:
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'.

我找不到任何解决方案。我该如何解决这个问题?

【问题讨论】:

    标签: flutter dart


    【解决方案1】:

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

    import 'dart:ui';
    

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

    【讨论】:

    • 与我遇到的问题不完全相同,但是您对需要手动导入库的解释帮助了我。谢谢!
    猜你喜欢
    • 2021-02-27
    • 2017-10-18
    • 2021-03-04
    • 2021-11-05
    • 2018-11-16
    • 1970-01-01
    • 2018-04-05
    • 2021-08-22
    • 2017-04-19
    相关资源
    最近更新 更多