diff --git a/lib/marquee.dart b/lib/marquee.dart index f35261b..7eba221 100644 --- a/lib/marquee.dart +++ b/lib/marquee.dart @@ -39,7 +39,9 @@ class _IntegralCurve extends Curve { values[1.0] = integral; // Normalize. - for (final double t in values.keys) values[t] = values[t]! / integral; + for (final double t in values.keys) { + values[t] = values[t]! / integral; + } return _IntegralCurve._(original, integral, values); } @@ -48,7 +50,12 @@ class _IntegralCurve extends Curve { /// curve. double transform(double t) { if (t < 0) return 0.0; - for (final key in _values.keys) if (key > t) return _values[key]!; + for (final key in _values.keys) { + if (key > t) { + return _values[key]!; + } + } + return 1.0; } } @@ -94,7 +101,7 @@ class Marquee extends StatefulWidget { super.key, required this.text, this.style, - this.textScaleFactor, + this.textScaleFactor = 1.0, this.textDirection = TextDirection.ltr, this.scrollAxis = Axis.horizontal, this.crossAxisAlignment = CrossAxisAlignment.center, @@ -145,7 +152,8 @@ class Marquee extends StatefulWidget { "isn't invented yet.", ), this.accelerationCurve = _IntegralCurve(accelerationCurve), - this.decelerationCurve = _IntegralCurve(decelerationCurve); + this.decelerationCurve = _IntegralCurve(decelerationCurve), + this.textScaler = TextScaler.linear(textScaleFactor); /// The text to be displayed. /// @@ -188,7 +196,8 @@ class Marquee extends StatefulWidget { /// See also: /// /// * [text] to provide the text itself. - final double? textScaleFactor; + final double textScaleFactor; + final TextScaler textScaler; /// The text direction of the text to be displayed. /// @@ -687,7 +696,10 @@ class _MarqueeState extends State with SingleTickerProviderStateMixin { final constraints = BoxConstraints(maxWidth: double.infinity); - final richTextWidget = Text.rich(span).build(context) as RichText; + final richTextWidget = Text.rich( + span, + textScaler: TextScaler.linear(widget.textScaleFactor), + ).build(context) as RichText; final renderObject = richTextWidget.createRenderObject(context); renderObject.layout(constraints); @@ -730,8 +742,11 @@ class _MarqueeState extends State with SingleTickerProviderStateMixin { physics: NeverScrollableScrollPhysics(), itemBuilder: (_, i) { final text = i.isEven - ? Text(widget.text, - style: widget.style, textScaleFactor: widget.textScaleFactor) + ? Text( + widget.text, + style: widget.style, + textScaler: widget.textScaler, + ) : _buildBlankSpace(); return alignment == null ? text diff --git a/pubspec.yaml b/pubspec.yaml index 62f10f6..da794af 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -6,11 +6,11 @@ version: 2.2.3 repository: https://github.com/MarcelGarus/marquee environment: - flutter: '>=3.0.0' + flutter: '>=3.12.0' sdk: '>=2.17.0 <3.0.0' dependencies: - fading_edge_scrollview: ^3.0.0 + fading_edge_scrollview: ^4.0.0 flutter: sdk: flutter