lerp method
Linearly interpolates between this TextFieldSpec and another TextFieldSpec based on the given parameter t.
The parameter t represents the interpolation factor, typically ranging from 0.0 to 1.0.
When t is 0.0, the current TextFieldSpec is returned. When t is 1.0, the other TextFieldSpec is returned.
For values of t between 0.0 and 1.0, an interpolated TextFieldSpec is returned.
If other is null, this method returns the current TextFieldSpec instance.
The interpolation is performed on each property of the TextFieldSpec using the appropriate interpolation method:
MixHelpers.lerpTextStylefor style and hintTextStyle and floatingLabelStyle.MixHelpers.lerpStrutStylefor strutStyle.MixHelpers.lerpDoublefor cursorWidth and cursorHeight and floatingLabelHeight.- Radius.lerp for cursorRadius.
- Color.lerp for cursorColor and backgroundCursorColor and selectionColor and autocorrectionTextRectColor.
- Offset.lerp for cursorOffset.
- EdgeInsets.lerp for scrollPadding.
FlexBoxSpec.lerpfor outerContainer and container.TextSpec.lerpfor helperText.IconSpec.lerpfor icon. For textAlign and textHeightBehavior and textWidthBasis and paintCursorAboveText and selectionHeightStyle and selectionWidthStyle and clipBehavior and keyboardAppearance and cursorOpacityAnimates and floatingLabel andanimatedandmodifiers, the interpolation is performed using a step function. Iftis less than 0.5, the value from the current TextFieldSpec is used. Otherwise, the value from theotherTextFieldSpec is used.
This method is typically used in animations to smoothly transition between different TextFieldSpec configurations.
Implementation
/// For [textAlign] and [textHeightBehavior] and [textWidthBasis] and [paintCursorAboveText] and [selectionHeightStyle] and [selectionWidthStyle] and [clipBehavior] and [keyboardAppearance] and [cursorOpacityAnimates] and [floatingLabel] and [animated] and [modifiers], the interpolation is performed using a step function.
/// If [t] is less than 0.5, the value from the current [TextFieldSpec] is used. Otherwise, the value
/// from the [other] [TextFieldSpec] is used.
///
/// This method is typically used in animations to smoothly transition between
/// different [TextFieldSpec] configurations.
@override
TextFieldSpec lerp(TextFieldSpec? other, double t) {
if (other == null) return _$this;
return TextFieldSpec(
style: MixHelpers.lerpTextStyle(_$this.style, other.style, t)!,
textAlign: t < 0.5 ? _$this.textAlign : other.textAlign,
strutStyle:
MixHelpers.lerpStrutStyle(_$this.strutStyle, other.strutStyle, t),
textHeightBehavior:
t < 0.5 ? _$this.textHeightBehavior : other.textHeightBehavior,
textWidthBasis: t < 0.5 ? _$this.textWidthBasis : other.textWidthBasis,
cursorWidth:
MixHelpers.lerpDouble(_$this.cursorWidth, other.cursorWidth, t)!,
cursorHeight:
MixHelpers.lerpDouble(_$this.cursorHeight, other.cursorHeight, t),
cursorRadius: Radius.lerp(_$this.cursorRadius, other.cursorRadius, t),
cursorColor: Color.lerp(_$this.cursorColor, other.cursorColor, t)!,
cursorOffset: Offset.lerp(_$this.cursorOffset, other.cursorOffset, t)!,
paintCursorAboveText:
t < 0.5 ? _$this.paintCursorAboveText : other.paintCursorAboveText,
backgroundCursorColor: Color.lerp(
_$this.backgroundCursorColor, other.backgroundCursorColor, t)!,
selectionColor:
Color.lerp(_$this.selectionColor, other.selectionColor, t),
selectionHeightStyle:
t < 0.5 ? _$this.selectionHeightStyle : other.selectionHeightStyle,
selectionWidthStyle:
t < 0.5 ? _$this.selectionWidthStyle : other.selectionWidthStyle,
scrollPadding:
EdgeInsets.lerp(_$this.scrollPadding, other.scrollPadding, t)!,
clipBehavior: t < 0.5 ? _$this.clipBehavior : other.clipBehavior,
keyboardAppearance:
t < 0.5 ? _$this.keyboardAppearance : other.keyboardAppearance,
autocorrectionTextRectColor: Color.lerp(
_$this.autocorrectionTextRectColor,
other.autocorrectionTextRectColor,
t),
cursorOpacityAnimates:
t < 0.5 ? _$this.cursorOpacityAnimates : other.cursorOpacityAnimates,
outerContainer: _$this.outerContainer.lerp(other.outerContainer, t),
container: _$this.container.lerp(other.container, t),
hintTextStyle: MixHelpers.lerpTextStyle(
_$this.hintTextStyle, other.hintTextStyle, t),
helperText: _$this.helperText.lerp(other.helperText, t),
icon: _$this.icon.lerp(other.icon, t),
floatingLabel: t < 0.5 ? _$this.floatingLabel : other.floatingLabel,
floatingLabelHeight: MixHelpers.lerpDouble(
_$this.floatingLabelHeight, other.floatingLabelHeight, t)!,
floatingLabelStyle: MixHelpers.lerpTextStyle(
_$this.floatingLabelStyle, other.floatingLabelStyle, t),
animated: t < 0.5 ? _$this.animated : other.animated,
modifiers: other.modifiers,
);
}