1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
| import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { // TODO: implement build return new MaterialApp( title: 'flutter demo', home: _home(), ); } }
class _home extends StatefulWidget { @override State<StatefulWidget> createState() { return _homeState(); } }
class _homeState extends State<_home> { @override Widget build(BuildContext context) { // TODO: implement build return new Scaffold( appBar: new AppBar( title: Text("title"), centerTitle: true, ), body: new Column( children: <Widget>[ RaisedButton( child: Text("RaisedButton"), onPressed: _pressed,//onPressed点击回调 这里设置的是一个空的方法 默认是null,为null时会禁用点击事件 elevation: 2.0, //正常状态下的阴影 highlightElevation: 4.0, //按下时的阴影 disabledElevation: 0.0, // 禁用时的阴影 ), FlatButton( child: Text("FlatButton"), onPressed: _pressed, ), OutlineButton( child: Text("OutlineButton"), onPressed: _pressed, ), IconButton( icon: Icon(Icons.thumb_up), onPressed: _pressed, ), FlatButton( child: Text("自定义样式"), //child按钮中的内容 textColor: Colors.white, //文字颜色 disabledTextColor: Colors.red, //按钮禁用时的文字颜色 color: Colors.lightBlue, //背景颜色 disabledColor: Colors.grey, //按钮禁用时的背景颜色 highlightColor: Colors.amber, //按钮按下时的背景颜色 splashColor: Colors.black12, //点击时,水波动画中水波的颜色 padding: EdgeInsets.all(2.0), //内边距 colorBrightness: Brightness.dark, ////按钮主题,默认是浅色主题 shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(4.0)), //外形 onPressed: _pressed, ), ], ), ); } void _pressed() {} }
|