TextStyle constructor

TextStyle({Color color, TextDecoration decoration, Color decorationColor, TextDecorationStyle decorationStyle, FontWeight fontWeight, FontStyle fontStyle, TextBaseline textBaseline, String fontFamily, double fontSize, double letterSpacing, double wordSpacing, double height, Locale locale, Paint background, Paint foreground, List<Shadow> shadows })

Creates a new TextStyle object.

  • color: The color to use when painting the text. If this is specified, foreground must be null.
  • decoration: The decorations to paint near the text (e.g., an underline).
  • decorationColor: The color in which to paint the text decorations.
  • decorationStyle: The style in which to paint the text decorations (e.g., dashed).
  • fontWeight: The typeface thickness to use when painting the text (e.g., bold).
  • fontStyle: The typeface variant to use when drawing the letters (e.g., italics).
  • fontFamily: The name of the font to use when painting the text (e.g., Roboto).
  • fontSize: The size of glyphs (in logical pixels) to use when painting the text.
  • letterSpacing: The amount of space (in logical pixels) to add between each letter.
  • wordSpacing: The amount of space (in logical pixels) to add at each sequence of white-space (i.e. between each word).
  • textBaseline: The common baseline that should be aligned between this text span and its parent text span, or, for the root text spans, with the line box.
  • height: The height of this text span, as a multiple of the font size.
  • locale: The locale used to select region-specific glyphs.
  • background: The paint drawn as a background for the text.
  • foreground: The paint used to draw the text. If this is specified, color must be null.

Implementation

TextStyle({
  Color color,
  TextDecoration decoration,
  Color decorationColor,
  TextDecorationStyle decorationStyle,
  FontWeight fontWeight,
  FontStyle fontStyle,
  TextBaseline textBaseline,
  String fontFamily,
  double fontSize,
  double letterSpacing,
  double wordSpacing,
  double height,
  Locale locale,
  Paint background,
  Paint foreground,
  List<Shadow> shadows,
}) : assert(color == null || foreground == null,
       'Cannot provide both a color and a foreground\n'
       'The color argument is just a shorthand for "foreground: new Paint()..color = color".'
     ),
     _encoded = _encodeTextStyle(
       color,
       decoration,
       decorationColor,
       decorationStyle,
       fontWeight,
       fontStyle,
       textBaseline,
       fontFamily,
       fontSize,
       letterSpacing,
       wordSpacing,
       height,
       locale,
       background,
       foreground,
       shadows,
     ),
     _fontFamily = fontFamily ?? '',
     _fontSize = fontSize,
     _letterSpacing = letterSpacing,
     _wordSpacing = wordSpacing,
     _height = height,
     _locale = locale,
     _background = background,
     _foreground = foreground,
     _shadows = shadows;