copyWith method
TInputFieldTheme
copyWith({
- TInputSize? size,
- Widget? preWidget,
- Widget? postWidget,
- double? height,
- EdgeInsets? padding,
- double? fontSize,
- TInputDecorationType? decorationType,
- WidgetStateProperty<
Color> ? color, - WidgetStateProperty<
Color> ? backgroundColor, - WidgetStateProperty<
Color> ? borderColor, - WidgetStateProperty<
TextStyle> ? labelStyle, - WidgetStateProperty<
TextStyle> ? helperTextStyle, - WidgetStateProperty<
TextStyle> ? errorTextStyle, - WidgetStateProperty<
TextStyle> ? tagStyle, - WidgetStateProperty<
double> ? borderRadius, - WidgetStateProperty<
double> ? borderWidth, - WidgetStateProperty<
BoxDecoration> ? decoration, - 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,
WidgetStateProperty<Color>? color,
WidgetStateProperty<Color>? backgroundColor,
WidgetStateProperty<Color>? borderColor,
WidgetStateProperty<TextStyle>? labelStyle,
WidgetStateProperty<TextStyle>? helperTextStyle,
WidgetStateProperty<TextStyle>? errorTextStyle,
WidgetStateProperty<TextStyle>? tagStyle,
WidgetStateProperty<double>? borderRadius,
WidgetStateProperty<double>? borderWidth,
WidgetStateProperty<BoxDecoration>? decoration,
WidgetStateProperty<LabelBuilder>? labelBuilder,
WidgetStateProperty<HelperTextBuilder>? helperTextBuilder,
WidgetStateProperty<ErrorsBuilder>? errorsBuilder,
}) {
final newDecorationType = decorationType ?? this.decorationType;
final newBackgroundColor = backgroundColor ?? this.backgroundColor;
final newBorderColor = borderColor ?? this.borderColor;
final newBorderWidth = borderWidth ?? this.borderWidth;
final newBorderRadius = borderRadius ?? this.borderRadius;
final newLabelStyle = labelStyle ?? this.labelStyle;
final newHelperTextStyle = helperTextStyle ?? this.helperTextStyle;
final newErrorTextStyle = errorTextStyle ?? this.errorTextStyle;
final newTagStyle = tagStyle ?? this.tagStyle;
final shouldRebuildDecoration =
decorationType != null || borderWidth != null || borderRadius != null || backgroundColor != null || borderColor != null;
final shouldRebuildLabel = labelStyle != null || tagStyle != null || errorTextStyle != null || backgroundColor != null;
return TInputFieldTheme(
decorationType: newDecorationType,
backgroundColor: newBackgroundColor,
borderColor: newBorderColor,
labelStyle: newLabelStyle,
helperTextStyle: newHelperTextStyle,
errorTextStyle: newErrorTextStyle,
tagStyle: newTagStyle,
size: size ?? this.size,
color: color ?? this.color,
preWidget: preWidget ?? this.preWidget,
postWidget: postWidget ?? this.postWidget,
height: height ?? this.height,
padding: padding ?? this.padding,
fontSize: fontSize ?? this.fontSize,
borderRadius: newBorderRadius,
borderWidth: newBorderWidth,
decoration: decoration ??
(shouldRebuildDecoration
? _createDecoration(newDecorationType, newBorderWidth, newBorderRadius, newBackgroundColor, newBorderColor)
: this.decoration),
labelBuilder: labelBuilder ??
(shouldRebuildLabel ? _createLabelBuilder(newLabelStyle, newTagStyle, newErrorTextStyle, newBackgroundColor) : this.labelBuilder),
helperTextBuilder:
helperTextBuilder ?? (helperTextStyle != null ? _createHelperTextBuilder(newHelperTextStyle) : this.helperTextBuilder),
errorsBuilder: errorsBuilder ?? (errorTextStyle != null ? _createErrorsBuilder(newErrorTextStyle) : this.errorsBuilder),
);
}