MarcelGarus / marquee

A Flutter widget that scrolls text infinitely. Provides many customizations including custom scroll directions and velocities, pausing after every round and specifying custom durations and curves for accelerating and decelerating.
MIT License
274 stars 113 forks source link

Scroll only when text overflows #87

Open ShahoodulHassan opened 1 year ago

ShahoodulHassan commented 1 year ago

Hi,

How can we make it scroll only when the text is overflowing....?

Thanks!

CengizhanParlak commented 1 year ago

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,
    ),
  ),
);
MKlimentowicz commented 1 month ago

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>, ... )