marquee
marquee copied to clipboard
Scroll only when text overflows
Hi,
How can we make it scroll only when the text is overflowing....?
Thanks!
You can get help from another package: AutoSizeText for this use-case.
run flutter pub add auto_size_text
and then:
import 'package:auto_size_text/auto_size_text.dart';
import 'package:marquee/marquee.dart';
return SizedBox(
height: 20,
child: AutoSizeText(
'Some text that will probably going to overflow from one of the side',
maxLines: 1,
style: context.subtitle2.copyWith(
color: Colors.black,
),
overflowReplacement: Marquee(
text: 'Some text that will probably going to overflow from one of the side',
style: context.subtitle2.copyWith(
color: Colors.black,
),
velocity: 30,
startAfter: const Duration(seconds: 1),
blankSpace: 20,
fadingEdgeStartFraction: 0.1,
fadingEdgeEndFraction: 0.1,
),
),
);
I just had the problem that the font size was dynamically adjusted to the width. If you don't need this then simply use the two properties:
AutoSizeText( ... minFontSize: <int>, maxFontSize: <int>, ... )