marquee icon indicating copy to clipboard operation
marquee copied to clipboard

Scroll only when text overflows

Open ShahoodulHassan opened this issue 2 years ago • 2 comments

Hi,

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

Thanks!

ShahoodulHassan avatar Feb 04 '23 05:02 ShahoodulHassan

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

CengizhanParlak avatar Mar 12 '23 12:03 CengizhanParlak

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

MKlimentowicz avatar May 25 '24 07:05 MKlimentowicz