class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( title: 'IconButton图标按钮', home: Scaffold( appBar: AppBar( title: Text('IconButton图标按钮'), ), body: Center( child: Container( decoration: BoxDecoration(color: Colors.grey), width: 200.0, height: 200.0, child: IconButton( //位置(根据父容器决定自己的位置) alignment: AlignmentDirectional.centerStart, //颜色 color: Colors.green, //大小 iconSize: 48.0, padding: EdgeInsets.all(30), //水波纹颜色 splashColor: Colors.blue, tooltip: '图标按钮', //图标 icon: Icon(Icons.print), //点击事件 onPressed: () {}), ) ), ) ); } }
Flutter笔记12:IconButton图标按钮
IconButton图标按钮,属性和方法详解(由于许多属性和FlatButton等按钮一致,就不多写了,可以参考上一节:)