Flutter 系列文章 总体目录
RaisedButton | 带阴影的按钮 |
FlatButton | 无阴影的按钮 |
OutlineButton | 带边框的按钮 |
基本属性如下:
可以通过RaisedButton.icon设置一个icon
RaisedButton.icon(
onPressed: () {},
icon: Icon(Icons.access_alarm),
label: Text('label')),
FlatButton的属性和RaisedButton一样
borderSide | 边框样式 ,BorderStyle 样式如下 |
disabledBorderColor | 禁用状态下边框颜色 |
highlightedBorderColor | 高亮状态下边框颜色 |
ButtonBar 一横排的Button布局
alignment | 布局方向,默认MainAxisAlignment.end |
mainAxisSize | 主轴大小,默认MainAxisSize.max |
children | Button集合 |
demo:
import 'package:flutter/material.dart';
class ButtonDemo extends StatelessWidget {
@override
Widget build(BuildContext context) {
// TODO: implement build
return Column(
children: [
Row(
children: [
RaisedButton(
onPressed: (){print('onPressed');},
child: Text('RaisedButton'),
),
FlatButton(
onPressed: () {},
child: Text('FlatButton'),
),
OutlineButton(
onPressed: () {},
color: Colors.red,
child: Text('OutlineButton'),
),
],
),
Row(
children: [
OutlineButton(
onPressed: () {},
child: Text('none'),
borderSide: BorderSide(color:Colors.green,width: 2.0,style: BorderStyle.none),
),
OutlineButton(
onPressed: () {},
child: Text('solid'),
borderSide: BorderSide(color:Colors.green,width: 2.0,style: BorderStyle.solid),
),
],
),
Row(
children: [
RaisedButton(
onPressed: (){print('onPressed');},
child: Text('onPressed'),
),
RaisedButton(
child: Text('not press'),
),
],
),
Row(
children: [
RaisedButton(
onPressed: (){print('onPressed');},
child: Text('normal'),
textTheme: ButtonTextTheme.normal,
),
RaisedButton(
onPressed: (){print('onPressed');},
child: Text('accent'),
textTheme: ButtonTextTheme.accent,
),
RaisedButton(
onPressed: (){print('onPressed');},
child: Text('primary'),
textTheme: ButtonTextTheme.primary,
),
],
),
Row(
children: [
RaisedButton(
child: Text('not press'),
disabledColor: Colors.red,
)
],
),
Row(
children: [
RaisedButton(
onPressed: (){print('onPressed');},
child: Text('darks'),
colorBrightness: Brightness.dark,
),
RaisedButton(
onPressed: (){print('onPressed');},
child: Text('light'),
colorBrightness: Brightness.light,
),
],
),
Row(
children: [
RaisedButton(
onPressed: (){print('onPressed');},
child: Text('elevation=10'),
elevation: 10,
),
],
),
Row(
children: [
RaisedButton(
onPressed: (){print('onPressed');},
child: Text('Border'),
shape: Border.all(),
),
],
),
Row(
children: [
RaisedButton(
onPressed: (){print('nonenonenonenonenone');},
child: Text('nonenonenonenonenone'),
clipBehavior: Clip.none,
),
RaisedButton(
onPressed: (){print('hardEdge');},
child: Text('hardEdge'),
clipBehavior: Clip.hardEdge,
),
],
),
Row(
children: [
RaisedButton(
onPressed: (){print('antiAlias');},
child: Text('antiAlias'),
clipBehavior: Clip.antiAlias,
),
RaisedButton(
onPressed: (){print('antiAliasWithSaveLayer');},
child: Text('antiAliasWithSaveLayer'),
clipBehavior: Clip.antiAliasWithSaveLayer,
),
],
),
RaisedButton.icon(
onPressed: () {},
icon: Icon(Icons.access_alarm),
label: Text('label')
),
Container(
child: ButtonBar(
children: [
RaisedButton(child: Text('ButtonBar'),),
RaisedButton(child: Text('ButtonBar'),),
RaisedButton(child: Text('ButtonBar'),),
],
),
),
],
);
}
}
如果你对Flutter还有疑问或者技术方面的疑惑,欢迎加入Flutter交流群(微信:laomengit)。
同时也欢迎关注我的Flutter公众号【老孟程序员】,公众号首发Flutter的相关内容。
Flutter地址:http://laomengit.com 里面包含160多个组件的详细用法。