【发布时间】:2021-05-31 12:46:15
【问题描述】:
有人可以帮我解决 Flutter 中的这个 ClipPath 吗?
我无法制作底部边框。
另外,我怎样才能让它作为 Row 孩子可见?
我注意到它可以在 Container 中使用,但是当我将 Container(或 Flexible)拖到 Row 中或没有小部件时它不起作用。
更新
这是 ClipPath 不可见时的返回
Scaffold(
body: SafeArea(
child: Row(
children: [
Flexible(
child: ClipPath(
clipper: AuthClipPath(),
child: Container(
height: size.height * .75,
decoration: BoxDecoration(gradient: gradient),
child: authForm(),
),
),
)
],
),
),
)
这是 ClipPath 可见时的返回
Scaffold(
body: SafeArea(
child: Container(
child: ClipPath(
clipper: AuthClipPath(),
child: Container(
height: size.height * .75,
decoration: BoxDecoration(gradient: gradient),
child: authForm(),
),
),
)
)
这是来自 ClipPath 的剪辑器类
class AuthClipPath extends CustomClipper<Path> {
@override
Path getClip(Size size) {
Path path = Path();
path.lineTo(0.0, size.height - 30);
Offset firstControlPoint = Offset(size.width / 4, size.height);
Offset firstPoint = Offset(size.width / 2, size.height);
path.quadraticBezierTo(firstControlPoint.dx, firstControlPoint.dy,
firstPoint.dx, firstPoint.dy);
Offset secondControlPoint = Offset(size.width / 4 * 3, size.height);
Offset secondPoint = Offset(size.width, size.height - 30);
path.quadraticBezierTo(secondControlPoint.dx, secondControlPoint.dy,
secondPoint.dx, secondPoint.dy);
path.lineTo(size.width, 0.0);
path.close();
return path;
}
@override
bool shouldReclip(CustomClipper<Path> oldClipper) => false;
}
灵活的小部件与可见性无关。
谢谢!
【问题讨论】:
-
你能分享一下它是如何工作的代码吗?
-
我添加了返回码,当它工作时,当它不工作时。如果提供整个文件会有所帮助,请说,我将创建一个 Git Repo,但我认为这无关紧要,因为这是我必须进行的唯一更改才能使 ClipPath 可见。感谢您查看代码!