如何在 FloatingActionButton 上制作边框?
How to make border on FloatingActionButton?
我的问题是我想在我的浮动操作按钮周围做边框。我试着把它放进容器里,然后这样做,但这不是我想要的。
decoration: BoxDecoration(
border: Border.all(
color: Colors.brown, width: 5, style: BorderStyle.solid)),
margin: const EdgeInsets.fromLTRB(0, 0, 0, 55),
width: 80,
height: 80,
child: FloatingActionButton(
focusColor: Colors.white54,
backgroundColor: Colors.white,
onPressed: () {},
child: const Icon(
Icons.add,
color: Colors.black,
size: 50,
),
),
),
我有这个:
我想要这个:
只需使用shape: BoxShape.circle,
Container(
decoration: BoxDecoration(
shape: BoxShape.circle,
border: Border.all(
color: Colors.brown, width: 5, style: BorderStyle.solid)),
margin: const EdgeInsets.fromLTRB(0, 0, 0, 55),
width: 80,
height: 80,
child: FloatingActionButton(
focusColor: Colors.white54,
backgroundColor: Colors.white,
onPressed: () {},
child: const Icon(
Icons.add,
color: Colors.black,
size: 50,
),
),
)
输出:
试试下面的代码
Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(
80,
),
border: Border.all(
color: Colors.green,
width: 5,
style: BorderStyle.solid,
),
),
margin: const EdgeInsets.fromLTRB(0, 0, 0, 55),
width: 80,
height: 80,
child: FloatingActionButton(
focusColor: Colors.white54,
backgroundColor: Colors.white,
onPressed: () {},
child: const Icon(
Icons.add,
color: Colors.black,
size: 50,
),
),
),
结果屏幕->
在 FloatingActionButton 小部件中,您有 property
命名为 shape
,使用它可以实现您想要的结果。
FloatingActionButton(
backgroundColor: Colors.white,
onPressed: (){},
child: Icon(Icons.add,color: Colors.black,size: 30,),
shape: RoundedRectangleBorder(side: BorderSide(width: 3,color: Colors.brown),borderRadius: BorderRadius.circular(100)),
)
我的问题是我想在我的浮动操作按钮周围做边框。我试着把它放进容器里,然后这样做,但这不是我想要的。
decoration: BoxDecoration(
border: Border.all(
color: Colors.brown, width: 5, style: BorderStyle.solid)),
margin: const EdgeInsets.fromLTRB(0, 0, 0, 55),
width: 80,
height: 80,
child: FloatingActionButton(
focusColor: Colors.white54,
backgroundColor: Colors.white,
onPressed: () {},
child: const Icon(
Icons.add,
color: Colors.black,
size: 50,
),
),
),
我有这个:
我想要这个:
只需使用shape: BoxShape.circle,
Container(
decoration: BoxDecoration(
shape: BoxShape.circle,
border: Border.all(
color: Colors.brown, width: 5, style: BorderStyle.solid)),
margin: const EdgeInsets.fromLTRB(0, 0, 0, 55),
width: 80,
height: 80,
child: FloatingActionButton(
focusColor: Colors.white54,
backgroundColor: Colors.white,
onPressed: () {},
child: const Icon(
Icons.add,
color: Colors.black,
size: 50,
),
),
)
输出:
试试下面的代码
Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(
80,
),
border: Border.all(
color: Colors.green,
width: 5,
style: BorderStyle.solid,
),
),
margin: const EdgeInsets.fromLTRB(0, 0, 0, 55),
width: 80,
height: 80,
child: FloatingActionButton(
focusColor: Colors.white54,
backgroundColor: Colors.white,
onPressed: () {},
child: const Icon(
Icons.add,
color: Colors.black,
size: 50,
),
),
),
结果屏幕->
在 FloatingActionButton 小部件中,您有 property
命名为 shape
,使用它可以实现您想要的结果。
FloatingActionButton(
backgroundColor: Colors.white,
onPressed: (){},
child: Icon(Icons.add,color: Colors.black,size: 30,),
shape: RoundedRectangleBorder(side: BorderSide(width: 3,color: Colors.brown),borderRadius: BorderRadius.circular(100)),
)