MarqueeR는 사용자 상호작용과 프로그래밍 제어를 지원하는 부드럽고 다중 방향으로 스크롤되는 텍스트를 가능하게 하는 사용자 정의 가능한 Flutter 위젯입니다. 제한된 공간에 긴 텍스트 콘텐츠를 표시하는 데 이상적이며, 유연한 애니메이션 옵션과 플랫폼 간 반응성 있는 동작을 제공합니다. 이 위젯은 직관적이고 매우 구성 가능하여 개발자가 스크롤 속도, 방향 및 상호작용 처리를 조정할 수 있습니다. Android, iOS, Web, macOS, Windows, Linux에서 원활하게 작동하므로 동적 텍스트 표시가 필요한 크로스플랫폼 애플리케이션에 적합합니다.
사용 사례
긴 제목 또는 알림 표시
애니메이션 배너 만들기
스크롤 자막 구현
동적 텍스트 요소로 UI 개선
접근성 있는 텍스트 캐러셀 만들기
주요 기능
다중 방향 스크롤링(왼쪽, 오른쪽, 위, 아래)
스크롤 상태에 대한 프로그래밍 제어
사용자 상호작용 지원(터치, 드래그)
사용자 정의 가능한 스크롤 속도 및 지연
기기 간 반응형 디자인
부드러운 애니메이션 전환
적합한 대상
크로스 플랫폼 앱을 개발하는 개발자
동적 텍스트 효과가 필요한 UI 디자이너
접근 가능한 스크롤 콘텐츠가 필요한 앱
텍스트 표시에 제한된 공간을 가진 프로젝트
인터랙티브 대시보드 및 키오스크
고려 사항
매우 긴 텍스트와 함께 성능에 영향을 미칠 수 있습니다
가독성을 위해 스크롤 속도를 신중하게 조정해야 합니다
텍스트 콘텐츠에 한정됨(이미지나 위젯 제외)
정적 또는 스크롤되지 않는 텍스트에는 적합하지 않습니다
짧은에서 중간 길이의 문자열에 가장 적합
원본 README
연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.
The Marqueer package is a versatile Flutter widget designed to create smooth and customizable marquee effects. Whether you're building a news ticker, scrolling advertisements, or any animated content display, Marqueer offers flexibility, performance, and user interaction controls.
With support for infinite scrolling, dynamic item generation, and highly customizable animation behavior, Marqueer ensures an engaging and fluid user experience.
Package Features
Directional Scrolling: Scroll content in any direction—right-to-left, left-to-right, top-to-bottom, or bottom-to-top.
Infinite or Finite Scrolling: Display unlimited content or stop after a specific item count.
Customizable Speed: Control scroll speed with a pps (pixels per second) parameter.
Interactive Control: Pause and resume scrolling based on user interactions.
Dynamic Content: Use the builder constructor for generating items dynamically.
Responsive: Automatically adapts to screen size changes and other layout updates.
Stable Animation: Animation continues smoothly even when parent widget rebuilds via setState. Only restarts when pps, direction, or infinity parameters change.
Updated Infinity Behavior
infinity: When true, the widget creates an endless loop by either:
Duplicating the content after the original list ends and continuing seamlessly.
Reversing the animation direction when the list ends.
By adjusting the infinity parameter, you can control how the marquee behaves at its boundaries, ensuring a smooth experience regardless of content length.
Constructor Parameters
Core Parameters
direction: Defines the scroll direction. Options include:
rtl (Right-to-Left)
ltr (Left-to-Right)
ttb (Top-to-Bottom)
btt (Bottom-to-Top)
pps: Pixels per second, controlling the speed of the scroll animation. For instance, pps: 15.0 means 15 pixels are scrolled every second.
infinity: A bool determining how the scroll behaves after reaching the end of the list. When enabled, it either duplicates the content or reverses the animation.
autoStart: A bool controlling whether the marquee starts automatically when the widget is built.
Interactivity
interaction: If true, pauses the animation on user touch.
restartAfterInteraction: Automatically restarts scrolling after user interaction if enabled.
restartAfterInteractionDuration: Specifies the delay before restarting, e.g., Duration(seconds: 3).
Content Customization
separatorBuilder: Adds a separator widget between items in the marquee.
padding: Adds padding around the scrolling content.
Callbacks
onStarted: Triggered when the animation starts.
onStopped: Triggered when the animation stops.
onInteraction: Called when a user interacts with the marquee.
onChangeItemInViewPort: Invoked when a new item enters the viewport.
Advanced Control
controller: An optional MarqueerController to programmatically control the marquee (e.g., start, stop, change direction, or animate to position).
edgeDuration: Adds a delay when the marquee reaches the edges, useful in finite scrolling scenarios.
clipBehavior: Controls how the content is clipped. Default is Clip.hardEdge.
intrinsicCrossAxisSize: Auto-sizes the cross axis based on child widget. No need for SizedBox wrapper. Default is false.
Controller Methods
start(): Starts the marquee animation
stop(): Stops the marquee animation
forward(): Starts forward animation (left to right or bottom to top)
backward(): Starts backward animation (right to left or top to bottom)
animateTo(position, duration, curve): Animates to a specific scroll position
interactionEnabled(enabled): Enables or disables user interaction
recalculateIntrinsicSize(): Recalculates intrinsic size when child content changes
isAnimating: Returns the animation status (requires single attached widget)
scrollablePointerIgnoring
The scrollablePointerIgnoring parameter is a boolean that resolves gesture-related issues caused by Flutter's default IgnorePointer behavior within Scrollable widgets. When set to true, it ensures that the IgnorePointer behavior in nested scrollable elements is bypassed, allowing gestures to propagate correctly.
Why Use This?
Flutter's Scrollable widget applies an IgnorePointer by default to prevent unintended interactions during animations. However, this can interfere with custom gestures or user interactions in certain scenarios. Enabling scrollablePointerIgnoring ensures smooth and predictable gesture handling.
Default Behavior
false: The default IgnorePointer behavior remains active.
true: Disables the default IgnorePointer behavior, allowing gestures to work as expected.
final controller = MarqueerController();
/// controller.start()/// controller.stop()/// controller.forward()/// controller.backward()/// controller.animateTo(position, duration: duration, curve: curve)/// controller.interactionEnabled(false)SizedBox(
height: 30,
child: Marqueer(
pps: 100,
/// optional
controller: controller,
/// optional
direction: .rtl,
/// optional
restartAfterInteractionDuration: constDuration(seconds: 6),
/// optional
restartAfterInteraction: false,
/// optional
onChangeItemInViewPort: (index) {
print('item index: $index');
},
onInteraction: () {
print('on interaction callback');
},
onStarted: () {
print('on started callback');
},
onStopped: () {
print('on stopped callback');
},
child: constText(
'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer pretium massa mollis lorem blandit imperdiet. Nulla mattis vitae mauris vel condimentum. Nam posuere, augue vitae lobortis consequat, odio ante condimentum est, at maximus augue purus id metus. Curabitur condimentum aliquet ante at aliquet. Quisque vel massa congue, bibendum leo sodales, malesuada ante. Maecenas sed tortor quis ipsum dictum sollicitudin.',
),
),
);