TextStyle constructor Null safety

TextStyle(
  1. {Color? color,
  2. TextDecoration? decoration,
  3. Color? decorationColor,
  4. TextDecorationStyle? decorationStyle,
  5. double? decorationThickness,
  6. FontWeight? fontWeight,
  7. FontStyle? fontStyle,
  8. TextBaseline? textBaseline,
  9. String? fontFamily,
  10. List<String>? fontFamilyFallback,
  11. double? fontSize,
  12. double? letterSpacing,
  13. double? wordSpacing,
  14. double? height,
  15. TextLeadingDistribution? leadingDistribution,
  16. Locale? locale,
  17. Paint? background,
  18. Paint? foreground,
  19. List<Shadow>? shadows,
  20. List<FontFeature>? fontFeatures,
  21. List<FontVariation>? fontVariations}
)

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).
  • decorationThickness: The thickness of the decoration as a multiplier on the thickness specified by the font.
  • 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). If a fontFamilyFallback is provided and fontFamily is not, then the first font family in fontFamilyFallback will take the position of the preferred font family. When a higher priority font cannot be found or does not contain a glyph, a lower priority font will be used.
  • fontFamilyFallback: An ordered list of the names of the fonts to fallback on when a glyph cannot be found in a higher priority font. When the fontFamily is null, the first font family in this list is used as the preferred font. Internally, the 'fontFamilyis concatenated to the front of this list. When no font family is provided through 'fontFamilyFallback' (null or empty) orfontFamily`, then the platform default font will be used.
  • 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 multiplier of the font size. Omitting height will allow the line height to take the height as defined by the font, which may not be exactly the height of the fontSize.
  • leadingDistribution: When height is specified, how the extra vertical space should be distributed over and under the text. Defaults to the paragraph's TextHeightBehavior if left unspecified.
  • 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.
  • fontFeatures: The font features that should be applied to the text.
  • fontVariations: The font variations that should be applied to the text.

Implementation

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