【问题标题】:The getter ClipBehavior isn't defined for the class 'Stack'没有为“Stack”类定义 getter ClipBehavior
【发布时间】:2021-04-28 12:18:06
【问题描述】:

我正在尝试运行包含“堆栈”的应用程序,但它给了我一个错误:

/C:/flutter/.pub-cache/hosted/pub.dartlang.org/convex_bottom_bar-2.6.0/lib/src/stack.dart:43:25: Error: The getter 'ClipBehavior' isn't defined for the class 'Stack'.
 - 'Stack' is from 'package:convex_bottom_bar/src/stack.dart' ('/C:/flutter/.pub-cache/hosted/pub.dartlang.org/convex_bottom_bar-2.6.0/lib/src/stack.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'ClipBehavior'.
          clipBehavior: ClipBehavior,
                        ^^^^^^^^^^^^
/C:/flutter/.pub-cache/hosted/pub.dartlang.org/convex_bottom_bar-2.6.0/lib/src/stack.dart:53:21: Error: The getter 'ClipBehavior' isn't defined for the class 'Stack'.
 - 'Stack' is from 'package:convex_bottom_bar/src/stack.dart' ('/C:/flutter/.pub-cache/hosted/pub.dartlang.org/convex_bottom_bar-2.6.0/lib/src/stack.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'ClipBehavior'.
      clipBehavior: ClipBehavior,
                    ^^^^^^^^^^^^
/C:/flutter/.pub-cache/hosted/pub.dartlang.org/convex_bottom_bar-2.6.0/lib/src/stack.dart:70:25: Error: The getter 'ClipBehaviorehavior' isn't defined for the class '_RenderStack'.
 - '_RenderStack' is from 'package:convex_bottom_bar/src/stack.dart' ('/C:/flutter/.pub-cache/hosted/pub.dartlang.org/convex_botvex_bottom_bar-2.6.0/lib/src/stack.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'ClipBehavior'.
          clipBehavior: ClipBehavior,
                        ^^^^^^^^^^^^


FAILURE: Build failed with an exception.

* Where:
Script 'C:\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 904

* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'C:\flutter\bin\flutter.bat'' finished with non-zero exit value 1

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 25s
Running Gradle task 'assembleDebug'...
Running Gradle task 'assembleDebug'... Done                        26.5s
Exception: Gradle task assembleDebug failed with exit code 1

我的颤振医生一切都很好,没有错误,我的颤振 sdk 是最新版本。我队友的应用程序在她身上运行良好。请帮忙

【问题讨论】:

    标签: flutter dart gradle sdk


    【解决方案1】:

    正如错误所说,您正在使用名为 ClipBehaviour 的变量 你应该在哪里使用 Clip 类的变量(你朋友的代码可能正在工作,因为他在他的代码中定义了一个名为 ClipBehaviour 的变量,而你没有)

       Stack(
            clipBehavior: Clip.none,
            children: const <Widget>[
              SizedBox(
                width: 100.0,
                height: 100.0,
              ),
            ],
          );
     
    

    就这样看看有没有帮助

    【讨论】:

    • 它不起作用,我们都有完全相同的代码。我添加了 (clipBehavior: Clip.none,) 但仍然是同样的问题。还有什么想法吗?
    • 你有没有给你的其他类命名为 Clip?导致我认为发生这种情况的唯一其他原因是因为您已命名任何小部件或类 Clip 并且颤振认为您想要覆盖现有的 Clip 类并给您一个错误。这是我唯一能想到的。
    【解决方案2】:

    这就是诀窍。谢谢

      clipBehavior: Clip.none,
    

    【讨论】:

      猜你喜欢
      • 2021-11-22
      • 1970-01-01
      • 2020-08-08
      • 2021-06-08
      • 1970-01-01
      • 2021-07-27
      • 2020-09-02
      • 2021-07-23
      • 1970-01-01
      相关资源
      最近更新 更多