HIDI Flutter Challenge (6) Text Widet

hello_hidiยท2021๋…„ 8์›” 31์ผ
0

HIDI's Flutter Challenge

๋ชฉ๋ก ๋ณด๊ธฐ
6/12
post-thumbnail

Text Widget

> Text Widget

  • ๋‹จ์ผ ์Šคํƒ€์ผ์˜ ํ…์ŠคํŠธ ๋ฌธ์ž์—ด์„ ํ‘œ์‹œํ•˜๋Š” ์œ„์ ฏ
  • ๋ฌธ์ž์—ด์ด ์—ฌ๋Ÿฌ ์ค„์— ๊ฑธ์ณ ๋Š์–ด์ง€๊ฑฐ๋‚˜ ๋ ˆ์ด์•„์›ƒ ์ œ์•ฝ ์กฐ๊ฑด์— ๋”ฐ๋ผ ๋ชจ๋‘ ๊ฐ™์€ ์ค„์— ํ‘œ์‹œ๋  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
  • ์Šคํƒ€์ผ ์†์„ฑ์„ ์‚ฌ์šฉํ•˜์ง€ ์•Š์œผ๋ฉด DefaultTextStyle์„ ๋‘˜๋Ÿฌ์‹ธ๋Š” ๊ฐ€์žฅ ๊ฐ€๊นŒ์šด ๊ณณ์˜ ์Šคํƒ€์ผ์„ ์‚ฌ์šฉ.
  
  const Text(
  String this.data, {
    Key? key,
    this.style,
    this.strutStyle,
    this.textAlign,
    this.textDirection,
    this.locale,
    this.softWrap,
    this.overflow,
    this.textScaleFactor,
    this.maxLines,
    this.semanticsLabel,
    this.textWidthBasis,
    this.textHeightBehavior,
}) : assert(
       data != null,
       'A non-null String must be provided to a Text widget.',
     ),
     textSpan = null,
     super(key: key);
  
  

>> Text ์ฃผ์š” ์†์„ฑ

  • style : TextStyle์—์„œ ์ž์„ธํžˆ ์„ค๋ช…
  • textAlign : ํ…์ŠคํŠธ๋ฅผ ๊ฐ€๋กœ๋กœ ์–ด๋–ป๊ฒŒ ์ •๋ ฌํ• ์ง€ ์ •ํ•˜๋Š” ์†์„ฑ
  • maxLines : ํ•„์š”ํ•œ ๊ฒฝ์šฐ ์ค„ ๋ฐ”๊ฟˆ(์„ ํƒ ์‚ฌํ•ญ)์œผ๋กœ ์ง€์ •ํ•  ํ…์ŠคํŠธ์˜ ์ตœ๋Œ€ ํ–‰ ์ˆ˜
  • String this.data : ๋ณด์—ฌ์งˆ ํ…์ŠคํŠธ

> TextStyle

  • ํ…์ŠคํŠธ๋ฅผ ํฌ๋งทํ•˜๊ณ  ๊ทธ๋ฆฌ๋Š” ๋ฐฉ๋ฒ•์„ ์„ค๋ช…ํ•˜๋Š” ํ…์ŠคํŠธ ์œ„์ ฏ ์†์„ฑ
  
  const TextStyle({
    this.inherit = true,
    this.color,
    this.backgroundColor,
    this.fontSize,
    this.fontWeight,
    this.fontStyle,
    this.letterSpacing,
    this.wordSpacing,
    this.textBaseline,
    this.height,
    this.leadingDistribution,
    this.locale,
    this.foreground,
    this.background,
    this.shadows,
    this.fontFeatures,
    this.decoration,
    this.decorationColor,
    this.decorationStyle,
    this.decorationThickness,
    this.debugLabel,
    String? fontFamily,
    List? fontFamilyFallback,
    String? package,
}) : fontFamily = package == null ? fontFamily : 'packages/$package/$fontFamily',
     _fontFamilyFallback = fontFamilyFallback,
     _package = package,
     assert(inherit != null),
     assert(color == null || foreground == null, _kColorForegroundWarning),
     assert(backgroundColor == null || background == null, _kColorBackgroundWarning);
  
  

>> TextStyle ์ฃผ์š” ์†์„ฑ

  • fontSize : ํ…์ŠคํŠธ ํฌ๊ธฐ => final double? fontSize;
  • color, backgroundColor : ํ…์ŠคํŠธ ์ƒ‰, ๋ฐฐ๊ฒฝ์ƒ‰ => final Color? color; / final Color? backgroundColor;
  • fontWeight : ํ…์ŠคํŠธ๋ฅผ ๊ทธ๋ฆด ๋•Œ ์‚ฌ์šฉํ•  ์„œ์ฒด ๋‘๊ป˜ => final FontWeight? fontWeight;;
  • fontFamily : ํ…์ŠคํŠธ๋ฅผ ๊ทธ๋ฆด ๋•Œ ์‚ฌ์šฉํ•  ๊ธ€๊ผด => final String? fontFamily;
  • decoration : ํ…์ŠคํŠธ ๊ทผ์ฒ˜์— ๊ทธ๋ฆด ์žฅ์‹(์˜ˆ: ๋ฐ‘์ค„) => final TextDecoration? decoration;
profile
์•ˆ๋‡ฝํฌ๋””

0๊ฐœ์˜ ๋Œ“๊ธ€