OutlineButton BorderSide更改边框颜色不起作用

时间:2019-09-10 16:09:29

标签: flutter dart flutter-layout

Flutter小部件,我尝试通过使用BorderSide(color:Colors.blue)更改OutlineButton边框的颜色。无论设置了哪种颜色,OutlineButton始终带有灰色边框,但是可以更改宽度。如何更改OutlineButton边框线的颜色?

class OutlineButtonWidget extends StatelessWidget {

  @override
  Widget build(BuildContext context) {
    return Center(
        child: OutlineButton(
            onPressed: null,
            borderSide: BorderSide(
                width: 5.0,
                color: Colors.blue,
                style: BorderStyle.solid,
            ),
            child: Text('outline button')
            ),
        ),
    );
  }
}

2 个答案:

答案 0 :(得分:3)

Style 属性将起作用

OutlineButton(
            onPressed: (){},
            style: OutlinedButton.styleFrom(
                          side: BorderSide(
                            width: 5.0,
                            color: Colors.blue,
                            style: BorderStyle.solid,
                          ),
                        ),
            child: Text('outline button')
            ),
        ),

答案 1 :(得分:1)

您通过使用禁用了按钮

onPressed: null, 

使用

onPressed: (){},