我想在容器周圍創建一個鋸齒狀邊框(見下圖)。有人知道怎么做嗎?鋸齒狀邊框示例
uj5u.com熱心網友回復:
有一個插件可以讓它變得簡單:dotted_border
例子:
DottedBorder(
color: Colors.black,
strokeWidth: 1,
child: FlutterLogo(size: 148),
)
uj5u.com熱心網友回復:
我找到了一個完美的解決方案。我使用 ClipPath 并添加一個 CustomClipper:
class HorizontalJaggedBorderClipper extends CustomClipper<Path> {
@override
Path getClip(Size size) {
Path path = Path();
path.lineTo(size.width, 0);
double y = 0;
double x = size.width;
double increment = size.height / 6;
double delta = size.height * 0.15;
while (y < size.height) {
y = increment;
x = (x == size.width) ? size.width - delta : size.width;
path.lineTo(x, y);
}
path.lineTo(0, size.height);
x = 0;
while (y > 0) {
x = (x == 0) ? delta : 0;
y -= increment;
path.lineTo(x, y);
}
path.close();
return path;
}
@override
bool shouldReclip(CustomClipper oldClipper) {
return oldClipper != this;
}
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/315570.html
上一篇:如何讓父母只能點擊?
下一篇:Flutterfirebase錯誤發生例外。LateError(LateInitializationError:本地“firebaseUser”尚未初始化。)
