class MyApp extends StatelessWidget { const MyApp({Key key}) : super(key: key); @override Widget build(BuildContext context) { return MaterialApp( title: 'Icon组件', home: Scaffold( appBar: AppBar( title: Text('Icon组件'), ), body: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ //普通图标 Icon( Icons.favorite, size: 30.0, color: Colors.red, ), //图片图标 ImageIcon( AssetImage('assets/images/digg.png'), //这里的颜色会智能修改png图片所呈现的颜色,不设置color,则png是什么颜色,图标就是什么颜色 color: Colors.blue, size: 48.0, ), //图标按钮 IconButton(icon: Icon(Icons.print), onPressed: () => print('点击')), ], ), ), ), ); } }
部分素材资源来源网站,本站提供免费下载,如有侵权请联系站长马上删除!