![](/img/trans.png)
[英]How can i color half of my CircleAvatar with one color, and aother half with another in flutter
[英]Flutter How can i clip half of my circle on border?
我有一個帶邊框的容器。 我想加一個半圈,讓它看起來像剪下來的優惠券。 但我不能按我的意願剪輯我的圈子。 我希望我的圈子在邊界上,所以它看起來像優惠券。 但我不知道我該怎么做。
它是我想要的:
這是我現在所做的:
如果我可以剪輯那個圓圈,它會像我想要的那樣,但我不知道我該怎么做。 它是我的那個小部件的代碼:
Container(
height: 168,
width: double.infinity,
decoration: BoxDecoration(
border: Border.all(
color: ColorService.purple,
),
borderRadius: BorderRadius.circular(8),
),
child: Row(
children: [
Expanded(
flex: 5,
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(8),
bottomLeft: Radius.circular(8),
),
color: Colors.amberAccent,
),
),
),
Container(
width: 20,
child: Column(
children: [
Container(
transform: Matrix4.translationValues(0, -10, 0),
width: 20,
height: 20,
decoration: BoxDecoration(
color: Colors.white,
border: Border.all(
color: ColorService.purple,
),
shape: BoxShape.circle,
),
),
Spacer(),
Container(
transform: Matrix4.translationValues(0, 10, 0),
width: 20,
height: 20,
decoration: BoxDecoration(
color: Colors.white,
border: Border.all(
color: ColorService.purple,
),
shape: BoxShape.circle,
),
),
],
),
),
Expanded(
flex: 3,
child: Container(
color: Colors.blueAccent,
),
)
],
),
);
感謝所有幫助!
您可以在頂部容器上包含clipBehavior
,默認為Clip.none
Container(
height: 168,
width: double.infinity,
clipBehavior: Clip.hardEdge, //this
decoration: BoxDecoration(
border: Border.all(
color: Colors.purple,
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.