RaisedButton(
child: Text('Button'),onPressed: (){
},)
RaisedButton(
onHighlightChanged: (high){
},...
)
属性 |
说明 |
textColor |
字体颜色 |
disabledTextColor |
禁用状态下字体颜色 |
color |
背景颜色 |
disabledColor |
禁用状态下背景颜色 |
highlightColor |
高亮颜色,按下时的颜色 |
splashColor |
水波纹颜色,按下松开会有水波纹效果 |
RaisedButton(
textColor: Colors.red,...
)
RaisedButton(
textTheme: ButtonTextTheme.primary,...
)
- normal:黑色或者白色字体,依赖于
ThemeData.brightness
- accent:字体颜色依赖于
ThemeData.accentColor
- primary :字体颜色依赖于
ThemeData.primaryColor
MaterialApp(
title: 'Flutter Demo',theme: ThemeData(
primaryColor: Color(0xFF42A5F5),accentColor: Colors.yellow,brightness: Brightness.light
),...
)
RaisedButton(
elevation: 5.0,highlightElevation: 5.0,disabledElevation: 5.0,...
)
RaisedButton(
shape: CircleBorder(),...
)
FlatButton(
child: Text('Button'),color: Colors.blue,onPressed: () {},)
OutlineButton(
child: Text('Button'),)
OutlineButton(
borderSide: BorderSide(color: Colors.blue,width: 2),disabledBorderColor: Colors.black,highlightedBorderColor: Colors.red,child: Text('Button'),)
var _dropValue = '语文';
_buildButton() {
return DropdownButton(
value: _dropValue,items: [
DropdownMenuItem(child: Text('语文'),value: '语文',),DropdownMenuItem(child: Text('数学'),value: '数学'),DropdownMenuItem(child: Text('英语'),value: '英语'),],onChanged: (value){
setState(() {
_dropValue = value;
});
},);
}
DropdownButton(
selectedItemBuilder: (context){
return [
Text('语文',style: TextStyle(color: Colors.red),Text('数学',Text('英语',)
];
},...
)
DropdownButton(
hint: Text('请选择'),value: null,...
)
DropdownButton(
icon: Icon(Icons.add),iconSize: 24,iconDisabledColor: Colors.red,iconEnabledColor: Colors.red,...
)
RawMaterialButton(
onPressed: (){},fillColor: Colors.blue,)
PopupMenuButton<String>(
itemBuilder: (context) {
return <PopupMenuEntry<String>>[
PopupMenuItem<String>(
value: '语文',child: Text('语文'),PopupMenuItem<String>(
value: '数学',child: Text('数学'),PopupMenuItem<String>(
value: '英语',child: Text('英语'),PopupMenuItem<String>(
value: '生物',child: Text('生物'),PopupMenuItem<String>(
value: '化学',child: Text('化学'),];
},)
PopupMenuButton<String>(
initialValue: '语文',...
)
PopupMenuButton<String>(
onSelected: (value){
print('$value');
},onCanceled: (){
print('onCanceled');
},...
)
PopupMenuButton<String>(
tooltip: 'PopupMenuButton',...
)
PopupMenuButton<String>(
elevation: 5,padding: EdgeInsets.all(5),color: Colors.red,...
)
PopupMenuButton<String>(
child: Text('学科'),...
)
PopupMenuButton<String>(
icon: Icon(Icons.add),...
)
PopupMenuButton<String>(
shape: RoundedRectangleBorder(
side: BorderSide(
color: Colors.red
),borderRadius: BorderRadius.circular(10)
),...
)
IconButton(
icon: Icon(Icons.person),iconSize: 30,)
IconButton(
tooltip: '这是一个图标按钮',icon: Icon(Icons.person),)
BackButton()
CloseButton()
ButtonBar(
children: <Widget>[
RaisedButton(),RaisedButton(),)
ButtonBar(
alignment: MainAxisAlignment.center,mainAxisSize: MainAxisSize.max,...
)
List<bool> _selecteds = [false,false,true];
ToggleButtons(
isSelected: _selecteds,children: <Widget>[
Icon(Icons.local_cafe),Icon(Icons.fastfood),Icon(Icons.cake),onPressed: (index) {
setState(() {
_selecteds[index] = !_selecteds[index];
});
},);
ToggleButtons(
color: Colors.green,selectedColor: Colors.orange,fillColor: Colors.red,...
)
ToggleButtons(
renderBorder: false,)
ToggleButtons(
borderRadius: BorderRadius.circular(30),borderColor: Colors.orange,borderWidth: 3,selectedBorderColor: Colors.deepOrange,)
ToggleButtons(
splashColor: Colors.purple,highlightColor: Colors.yellow,)
ToggleButtons(
onPressed: null,disabledColor: Colors.grey[300],disabledBorderColor: Colors.blueGrey,)
ToggleButtons(
hoverColor: Colors.cyan,)