CalseeKey.icon constructor
CalseeKey.icon(
- IconData icon, {
- required KeyRole role,
- required String semanticLabel,
- String? label,
- VoidCallback? onPressed,
- VoidCallback? onLongPress,
- double sizeFactor = 0.42,
- bool haptics = true,
- Key? key,
A key showing icon, with an optional label under it.
Implementation
factory CalseeKey.icon(
IconData icon, {
required KeyRole role,
required String semanticLabel,
String? label,
VoidCallback? onPressed,
VoidCallback? onLongPress,
double sizeFactor = 0.42,
bool haptics = true,
Key? key,
}) => CalseeKey(
role: role,
semanticLabel: semanticLabel,
onPressed: onPressed,
onLongPress: onLongPress,
haptics: haptics,
artSeed: semanticLabel.hashCode & 0x7FFFFFFF,
key: key,
builder: (context, style, shortSide) {
final glyph = Icon(
icon,
color: style.label,
size: shortSide * sizeFactor,
);
if (label == null) return glyph;
// Some faces (Material 3 Expressive shapes) leave less than the
// short side for content: shrink to fit, as text labels do.
return FittedBox(
fit: BoxFit.scaleDown,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
glyph,
SizedBox(height: shortSide * 0.06),
CalseeKeyLabel(label, style: style, size: shortSide * 0.14),
],
),
);
},
);