ReinBentdal / styled_widget

Simplifying widget style in Flutter.
https://pub.dev/packages/styled_widget
MIT License
1.27k stars 103 forks source link

Error with animated text when maxLines specified #67

Closed f69 closed 3 years ago

f69 commented 3 years ago

When trying to animate text with maxLines specified, e.g.:

Styled.text(text, maxLines: 10, animate: true)
  .fontSize(size)
  .textColor(color)
  .animate(slideDuration, slideCurve)

you get an error:

Cannot lerp between "10" and "10".

The type int returned a double after multiplication with a double value. See "Types with special considerations" at https://api.flutter.dev/flutter/animation/Tween-class.html for more information.

To lerp int values, consider IntTween or StepTween instead.

The relevant error-causing widget was: 
  FeatureItem file:///feature_page.dart:130:9
When the exception was thrown, this was the stack: 
#0      Tween.lerp.<anonymous closure> (package:flutter/src/animation/tween.dart:286:9)
#1      Tween.lerp (package:flutter/src/animation/tween.dart:303:6)
#2      Tween.transform (package:flutter/src/animation/tween.dart:325:12)
#3      Animatable.evaluate (package:flutter/src/animation/tween.dart:53:46)
#4      _AnimatedTextState.build (package:styled_widget/src/animated_text.dart:190:30)
...
====================================================================================================

You should change all occurrences of Tween\<int> to IntTween in animated_text.dart.

f69 commented 3 years ago

@ReinBentdal, what kind of help do you mean by adding "help wanted" tag? As I've mentioned in my post, all that you need is to change all occurrences of Tween in animated_text.dart (totally 3) to IntTween - I've used this approach locally.

ReinBentdal commented 3 years ago

Didn't see that. I will take your word for the fix to work, don't have time to verify. Since you have implemented the fix locally, why no pull request?

f69 commented 3 years ago

Since you have implemented the fix locally, why no pull request?

Sorry for that. Promise next time :)