copyWith method

TInputFieldTheme copyWith({
  1. TInputSize? size,
  2. Widget? preWidget,
  3. Widget? postWidget,
  4. double? height,
  5. EdgeInsets? padding,
  6. double? fontSize,
  7. TInputDecorationType? decorationType,
  8. TLabelPosition? labelPosition,
  9. WidgetStateProperty<Color>? color,
  10. WidgetStateProperty<Color>? backgroundColor,
  11. WidgetStateProperty<Color>? borderColor,
  12. WidgetStateProperty<TextStyle>? labelStyle,
  13. WidgetStateProperty<TextStyle>? helperTextStyle,
  14. WidgetStateProperty<TextStyle>? errorTextStyle,
  15. WidgetStateProperty<TextStyle>? tagStyle,
  16. WidgetStateProperty<TextStyle>? hintStyle,
  17. WidgetStateProperty<double>? borderRadius,
  18. WidgetStateProperty<double>? borderWidth,
  19. WidgetStateProperty<LabelBuilder>? labelBuilder,
  20. WidgetStateProperty<HelperTextBuilder>? helperTextBuilder,
  21. 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),
  );
}