buildDefaultIcon method
Widget
buildDefaultIcon(
- BuildContext context,
- TDCheckboxGroupState? groupState,
- bool isSelected
override
默认的checkBox icon
Implementation
@override
Widget buildDefaultIcon(
BuildContext context, TDCheckboxGroupState? groupState, bool isSelected) {
if (cardMode == true) {
return Container();
}
TDRadioStyle? style;
if (groupState is TDRadioGroupState) {
style = (groupState.widget as TDRadioGroup).radioCheckStyle;
}
style = style ?? radioStyle;
var size = 24.0;
final theme = TDTheme.of(context);
// 由于镂空圆没有现成icon,因而自己画一个`
if (style == TDRadioStyle.hollowCircle) {
return SizedBox(
width: size,
height: size,
child: CustomPaint(
painter: HollowCircle(!enable
? (isSelected ? theme.brandDisabledColor : theme.grayColor4)
: isSelected
? theme.brandNormalColor
: theme.grayColor4),
),
);
}
IconData? iconData;
switch (style) {
case TDRadioStyle.check:
iconData = isSelected ? TDIcons.check : null;
break;
case TDRadioStyle.square:
iconData =
isSelected ? TDIcons.check_rectangle_filled : TDIcons.rectangle;
break;
default:
iconData = isSelected ? TDIcons.check_circle_filled : TDIcons.circle;
break;
}
if (iconData != null) {
return Icon(iconData,
size: size,
color: !enable
? (isSelected ? theme.brandDisabledColor : theme.grayColor4)
: isSelected
? theme.brandNormalColor
: theme.grayColor4);
} else {
return SizedBox(
width: size,
height: size,
);
}
}