본문 바로가기
Flutter

Flutter Text 글자 수가 너무 길어져서 OverFlow가 난다면?

by Kim JK 2022. 5. 1.
반응형

Text Widget에는 overFlow라는 속성이있다.

한번 살펴보자.


/// How overflowing text should be handled.
///
/// A [TextOverflow] can be passed to [Text] and [RichText] via their
/// [Text.overflow] and [RichText.overflow] properties respectively.
enum TextOverflow {
  /// Clip the overflowing text to fix its container.
  clip,

  /// Fade the overflowing text to transparent.
  fade,

  /// Use an ellipsis to indicate that the text has overflowed.
  ellipsis,

  /// Render overflowing text outside of its container.
  visible,
}

 

대충 이런 속성중에서 골라 쓸 수 있다.

 

Text(
  '[응애] 응애응애 응애 응애응애응애 응애응애 응응애응애응응애앵응애 (S/M/L)',
  style: TextStyle(fontSize: 14.sp),
  overflow: TextOverflow.ellipsis,
  textAlign: TextAlign.justify,
  maxLines: 3,
),

 

ellipsis 속성을 적용하면 maxLines를 넘어갈 경우 ...으로 처리가 된다.

 

참쉽죠?

반응형