ticker_text 2.2.0
ticker_text: ^2.2.0 copied to clipboard
Configurable & straightforward text scroller with minimal dependencies.
ticker_text for Flutter #
Straightforward widget scroller with minimal dependencies. It scrolls its child when the child overflows, pauses at the end, and returns to the start.
Features #
- automatic scrolling when the child overflows,
- optional control with
TickerTextController, - configurable speed, pause durations, and curves,
- horizontal or vertical scrolling,
- no platform-specific dependencies.
Getting started #
Add the package to your pubspec.yaml:
dependencies:
ticker_text: ^2.2.0
Or run:
flutter pub add ticker_text
Usage #
The parent must constrain the size of the child so that it overflows for scrolling to take effect:
SizedBox(
width: 50, // constrain the width so the child overflows
child: TickerText(
// these are the default values
scrollDirection: Axis.horizontal,
speed: 20,
startPauseDuration: const Duration(seconds: 10),
endPauseDuration: const Duration(seconds: 10),
returnDuration: const Duration(milliseconds: 800),
primaryCurve: Curves.linear,
returnCurve: Curves.easeOut,
child: const Text('Very long sentence...'),
),
)
Controlling the scroll #
If no controller is provided, an internal controller starts scrolling
automatically. Pass a TickerTextController to start and stop scrolling
yourself:
final controller = TickerTextController(autoStart: false);
@override
void initState() {
super.initState();
controller.startScroll();
}
@override
void dispose() {
controller.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return SizedBox(
width: 200,
child: TickerText(
controller: controller,
child: const Text('Very long sentence...'),
),
);
}
Calling stopScroll() stops the animation and returns the content to its
starting position.
See the example for a complete runnable app.
API reference #
Detailed API documentation can be found on pub.dev.
License #
This project is MIT licensed.