-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Description
Steps to reproduce
-
Create two
TextStyleinstances with differentshadowslists. For example:final style1 = TextStyle( fontSize: 24, shadows: [ Shadow( blurRadius: 10, color: Colors.blue, offset: Offset(0, 0), ), ], ); final style2 = TextStyle( fontSize: 24, shadows: [ Shadow( blurRadius: 20, color: Colors.red, offset: Offset(5, 5), ), ], );
-
Use
TextStyle.lerp()to interpolate between the two styles with an interpolation factor (t) of your choice. For example:final interpolatedStyle = TextStyle.lerp(style1, style2, 0.5);
-
Observe that the resulting
interpolatedStyledoes not have smoothly interpolated shadow properties. Instead, it will abruptly switch between theshadowslists ofstyle1andstyle2based on the value oft. -
Vary the interpolation factor (
t) and notice that the text shadows do not gradually transition between the two styles. They will instantly change from one set of shadows to another at the midpoint of the interpolation. -
To see this behavior in action, you can use
TextStyle.lerp()within an animation or a widget that animates the interpolation factor over time, such asAnimatedDefaultTextStyleorAnimatedBuilder. Observe that the text shadows do not smoothly animate between the two styles and instead abruptly switch at the midpoint of the animation.
Expected results
When interpolating between two TextStyle instances using TextStyle.lerp(), the shadows property should be smoothly interpolated based on the provided interpolation factor (t). This can be adjusted by using ui.Shadow.listLerp() as part
Each shadow's blurRadius, color, and offset should be linearly combined from the corresponding values in the input styles.
Actual results
TextStyle.lerp() does not correctly interpolate the shadows property between two TextStyle instances.
Instead of smoothly transitioning each shadow's blurRadius, color, and offset based on the interpolation factor (t), it abruptly switches between the entire shadows lists at the midpoint of the interpolation.
This results in a visually inconsistent and jarring transition of text shadows, not meeting the expected smooth interpolation behavior.
Code sample
Screenshots or Video
No response
Logs
No response
Flutter Doctor output
N/A