首页 > 建站教程 > APP开发,混合APP >  Flutter笔记14:RaisedButton凸起按钮正文

Flutter笔记14:RaisedButton凸起按钮

RaisedButton凸起按钮,和前面讲的FlatButton等Flutter按钮的很多属性都差不多,它们通过一些设置,都能实现相同的效果:
class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
        title: 'RaisedButton凸起按钮',
        home: Scaffold(
          appBar: AppBar(
            title: Text('RaisedButton凸起按钮'),
          ),
          body: Center(
            child: RaisedButton(
                onPressed: () {},
                child: Text(
                  'RaisedButton凸起按钮',
                  style: TextStyle(color: Colors.black),
                ),
                //文本颜色,可以用上面的TextStyle设置,也可以在这里设置,这里的优先级没有上面的高
                textColor: Colors.white,
                //背景色
                color: Colors.green,
                //按下颜色
                colorBrightness: Brightness.dark,
                //失效背景色
                disabledColor: Colors.grey,
                //失效文本颜色
                disabledTextColor: Colors.grey,
                textTheme: ButtonTextTheme.normal,
                //点击时水波纹颜色
                splashColor: Colors.blue,
                //抗锯齿能力
                clipBehavior: Clip.antiAlias,
                padding: EdgeInsets.all(10.0),
                //边框方法1:
                // shape: Border.all(
                //   width: 2.0,
                //   color: Colors.red,
                //   style: BorderStyle.solid
                // ),
                //边框方法2:
                shape: RoundedRectangleBorder(
                    side: BorderSide(
                        width: 2.0,
                        color: Colors.red,
                        style: BorderStyle.solid),
                    borderRadius: BorderRadius.only(
                      topLeft: Radius.circular(10.0),
                      topRight: Radius.circular(10.0),
                      bottomLeft: Radius.circular(10.0),
                      bottomRight: Radius.circular(10.0),
                    ))),
          ),
        ));
  }
}