copyWith method
TInputFieldTheme
copyWith({
- TInputSize? size,
- Widget? preWidget,
- Widget? postWidget,
- double? height,
- EdgeInsets? padding,
- double? fontSize,
- TInputDecorationType? decorationType,
- TLabelPosition? labelPosition,
- WidgetStateProperty<
Color> ? color, - WidgetStateProperty<
Color> ? backgroundColor, - WidgetStateProperty<
Color> ? borderColor, - WidgetStateProperty<
TextStyle> ? labelStyle, - WidgetStateProperty<
TextStyle> ? helperTextStyle, - WidgetStateProperty<
TextStyle> ? errorTextStyle, - WidgetStateProperty<
TextStyle> ? tagStyle, - WidgetStateProperty<
TextStyle> ? hintStyle, - WidgetStateProperty<
double> ? borderRadius, - WidgetStateProperty<
double> ? borderWidth, - WidgetStateProperty<
LabelBuilder> ? labelBuilder, - WidgetStateProperty<
HelperTextBuilder> ? helperTextBuilder, - WidgetStateProperty<
ErrorsBuilder> ? errorsBuilder,
Implementation
TInputFieldTheme copyWith({
TInputSize? size,
Widget? preWidget,
Widget? postWidget,
double? height,
EdgeInsets? padding,
double? fontSize,
TInputDecorationType? decorationType,
TLabelPosition? labelPosition,
WidgetStateProperty<Color>? color,
WidgetStateProperty<Color>? backgroundColor,
WidgetStateProperty<Color>? borderColor,
WidgetStateProperty<TextStyle>? labelStyle,
WidgetStateProperty<TextStyle>? helperTextStyle,
WidgetStateProperty<TextStyle>? errorTextStyle,
WidgetStateProperty<TextStyle>? tagStyle,
WidgetStateProperty<TextStyle>? hintStyle,
WidgetStateProperty<double>? borderRadius,
WidgetStateProperty<double>? borderWidth,
WidgetStateProperty<LabelBuilder>? labelBuilder,
WidgetStateProperty<HelperTextBuilder>? helperTextBuilder,
WidgetStateProperty<ErrorsBuilder>? errorsBuilder,
}) {
final newBackgroundColor = backgroundColor ?? this.backgroundColor;
final newLabelStyle = labelStyle ?? this.labelStyle;
final newHelperTextStyle = helperTextStyle ?? this.helperTextStyle;
final newErrorTextStyle = errorTextStyle ?? this.errorTextStyle;
final newTagStyle = tagStyle ?? this.tagStyle;
final newPadding = padding ?? this.padding ?? size?.padding ?? fieldPadding;
final shouldRebuildLabel = labelStyle != null || tagStyle != null || errorTextStyle != null || backgroundColor != null;
return TInputFieldTheme(
decorationType: decorationType ?? this.decorationType,
labelPosition: labelPosition ?? this.labelPosition,
backgroundColor: newBackgroundColor,
borderColor: borderColor ?? this.borderColor,
labelStyle: newLabelStyle,
helperTextStyle: newHelperTextStyle,
errorTextStyle: newErrorTextStyle,
tagStyle: newTagStyle,
hintStyle: hintStyle ?? this.hintStyle,
size: size ?? this.size,
color: color ?? this.color,
preWidget: preWidget ?? this.preWidget,
postWidget: postWidget ?? this.postWidget,
height: height ?? this.height,
padding: newPadding,
fontSize: fontSize ?? this.fontSize,
borderRadius: borderRadius ?? this.borderRadius,
borderWidth: borderWidth ?? this.borderWidth,
labelBuilder: labelBuilder ??
(shouldRebuildLabel ? _buildLabelBuilder(newLabelStyle, newTagStyle, newErrorTextStyle, newBackgroundColor) : this.labelBuilder),
helperTextBuilder:
helperTextBuilder ?? (helperTextStyle != null ? _buildHelperTextBuilder(newHelperTextStyle, newPadding) : this.helperTextBuilder),
errorsBuilder: errorsBuilder ?? (errorTextStyle != null ? _buildErrorsBuilder(newErrorTextStyle, newPadding) : this.errorsBuilder),
);
}