buildIcon static method
Implementation
static Widget buildIcon(
BuildContext context,
String assetName,
OudsFormFieldsControlState controlTextInputState,
bool isError, {
bool tinted = true,
}) {
final inputTextForegroundModifier = OudsFormFieldsForegroundColorModifier(
context,
);
final theme = OudsTheme.of(context);
final Widget iconWidget = SvgPicture.asset(
excludeFromSemantics: true,
assetName,
fit: BoxFit.contain,
height: theme.componentsTokens(context).textInput.sizeLeadingIcon,
width: theme.componentsTokens(context).textInput.sizeLeadingIcon,
colorFilter: tinted
? ColorFilter.mode(
inputTextForegroundModifier.getIconColor(controlTextInputState),
BlendMode.srcIn,
)
: null,
);
// When untinted, the icon asset is expected to be a plain white shape
// (no embedded background), so it needs a brand-colored background to
// remain visible — matching the behavior of OudsButton and OudsLink.
if (tinted) return iconWidget;
return Container(
color: theme.colorScheme(context).surfaceBrandPrimary,
child: iconWidget,
);
}