简介
保存chip主题的颜色,形状和文本样式
- 使用它配置chipTheme widget,或者为Theme widget小部件设置 ThemeData.chipTheme。
基本用法
- 创建ChipThemeData最简单的方法是使用copyWith您从得到一个ChipTheme.of,或创建一个全新的一个具有 ChipThemeData..fromDefaults
实例演示
import 'package:flutter/material.dart';
class ChipThemeDemo extends StatefulWidget {
_ChipThemeDemoState createState() => _ChipThemeDemoState();
}
class _ChipThemeDemoState extends State<ChipThemeDemo> {
Color _color = Colors.red;
@override
Widget build(BuildContext context) {
return ChipTheme(
data: ChipThemeData.fromDefaults(
// brightness: Brightness.dark,
labelStyle: TextStyle(fontSize: 15.0),
primaryColor: Colors.red,secondaryColor: Colors.red.shade800),
child: ChoiceChip(
padding: EdgeInsets.only(left: 100.0,right: 100.0,top: 10.0,bottom: 10.0),
label: Text('down'),
onSelected: (bool value) {
setState(() {
_color = value ? Colors.black : Colors.red;
});
},
selected: _color == Colors.black,
),
);
}
}