buildDecoration method

BoxDecoration buildDecoration(
  1. TInputContext ctx
)

Implementation

BoxDecoration buildDecoration(TInputContext ctx) {
  if (decorationBuilder != null) {
    return decorationBuilder!(ctx);
  }

  final resolvedBorderColor = _resolve(borderColor, ctx.states);
  final resolvedBackgroundColor = _resolve(backgroundColor, ctx.states);
  final resolvedColor = _resolve(color, ctx.states);

  final currentBorderColor = resolvedBorderColor ??
      switch (ctx.states) {
        _ when ctx.isDisabled => ctx.colors.outlineVariant,
        _ when ctx.isError => ctx.colors.error,
        _ when ctx.isFocused => resolvedColor ?? ctx.colors.primary,
        _ => resolvedColor ?? ctx.colors.outline,
      };

  final currentBackgroundColor = resolvedBackgroundColor ?? (ctx.isDisabled ? ctx.colors.surfaceDim.withAlpha(50) : ctx.colors.surface);

  return BoxDecoration(
    border: buildBorder(ctx, currentBorderColor),
    borderRadius: BorderRadius.circular(borderRadius ?? 6.0),
    color: currentBackgroundColor,
    boxShadow: buildBoxShadow(ctx, currentBorderColor),
  );
}