简介
用于应用栏图标的颜色,不透明度和大小。
- 图标主题Icon和ImageIcon的依赖
基本用法
- 通常,这与backgroundColor,brightness,textTheme一起设置。默认为ThemeData.primaryIconTheme。
实例演示
import 'package:flutter/material.dart';
class IconThemeDemo extends StatelessWidget {
final Color curColor;
IconThemeDemo({Key key, this.curColor}) : super();
@override
Widget build(BuildContext context) {
return AppBar(
actions: <Widget>[
IconTheme(
data: IconThemeData(color: curColor, opacity: 3.0),
child: Container(
padding: EdgeInsets.all(20.0),
child: Icon(Icons.equalizer),
),
),
],
);
}
}
class IconThemeDemo2 extends StatelessWidget {
final Color curColor;
final double curSize;
IconThemeDemo2({Key key, this.curColor, this.curSize}) : super();
@override
Widget build(BuildContext context) {
return AppBar(
actions: <Widget>[
IconTheme(
data: IconThemeData(color: curColor, opacity: 3.0),
child: Row(
children: <Widget>[
Icon(
Icons.favorite_border,
size: curSize,
),
Padding(
padding: const EdgeInsets.all(20.0),
child: Text('喜欢'),
),
],
)),
],
);
}
}