Android studio 如何仅为颤振中的OutlineButton创建带下划线的边框
我正在尝试创建一个按钮,该按钮将在我的图像下方显示彩色边框,但仅在底部。在OutlineButton中,它只允许我更改整个边框,而不允许更改边框的一侧。谁能帮帮我!我需要它是一个按钮,因为当用户按下图像时,我正在使用onPressed(){}执行从Colors.transparent到Colors.teal的颜色更改。谢谢 修复了它。我将其更改为一个扁平按钮,并将小部件包装在一个Material()中 这允许我创建底部边框,并将其设置为我的颜色首选项:Android studio 如何仅为颤振中的OutlineButton创建带下划线的边框,android-studio,flutter,dart,Android Studio,Flutter,Dart,我正在尝试创建一个按钮,该按钮将在我的图像下方显示彩色边框,但仅在底部。在OutlineButton中,它只允许我更改整个边框,而不允许更改边框的一侧。谁能帮帮我!我需要它是一个按钮,因为当用户按下图像时,我正在使用onPressed(){}执行从Colors.transparent到Colors.teal的颜色更改。谢谢 修复了它。我将其更改为一个扁平按钮,并将小部件包装在一个Material()中 这允许我创建底部边框,并将其设置为我的颜色首选项: bool changeColor = fa
bool changeColor = false;
Material(
shape: Border(
bottom: BorderSide(
color: changeColor ? Colors.teal : Colors.transparent, width: 3.0
)
),
child: FlatButton(
onPressed: (){
setState(() {changeColor = !changeColor;});
},
),
),
您只需使用
Border()
在FlatButton
上定义shape属性即可
FlatButton(
height: 50,
child: Text('All Posts'),
shape: Border(
bottom: BorderSide(color: Colors.black, width: 3)
),
onPressed: (){
print('You selected all posts');
},
),