Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dependency refresh and static analysis fixes #94

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 23 additions & 8 deletions lib/marquee.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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;
}
}
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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.
///
Expand Down Expand Up @@ -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.
///
Expand Down Expand Up @@ -687,7 +696,10 @@ class _MarqueeState extends State<Marquee> 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);

Expand Down Expand Up @@ -730,8 +742,11 @@ class _MarqueeState extends State<Marquee> 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
Expand Down
4 changes: 2 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down