Flutter:ClipPath()小部件中的断言失败错误

时间:2020-08-03 13:10:15

标签: flutter flutter-layout flutter-web

我遇到此错误。

Assertion failed: org-dartlang-sdk:///flutter_web_sdk/lib/_engine/engine/surface/path/path_ref.dart:831:12
isValid
is not true

The relevant error-causing widget was
    ClipPath

我正在使用的依赖项是:flutter_custom_clippers: ^1.1.1

每当我重新启动或进行热刷新时,UI都会正确构建,但是几秒钟后,我会在调试控制台中收到此错误。

以下是我的小部件结构。

ClipPath(
      clipper: WaveClipperTwo(flip: true, reverse: true),
      child: Container(
        padding: EdgeInsets.all(10),
        width: double.infinity,
        height: 350,
        color: Colors.black87,
        child: ...
        )
);

如何解决此错误。

1 个答案:

答案 0 :(得分:1)

我不知道实际发生了什么,但是我将ClipPath()包裹在一个容器中,并将其高度设置为与其中的容器相同,即350

Container{
height: 350,
child: ClipPath(
      clipper: WaveClipperTwo(flip: true, reverse: true),
      child: Container(
        padding: EdgeInsets.all(10),
        width: double.infinity,
        height: 350,
        color: Colors.black87,
        child: ...
        )
    ),
);

然后我没有任何错误。

如果您知道要告诉我,我仍然不知道该错误是什么:)