Skip to main content

Base TextStyle Utility for Flutter

This utility provides styling system for basic text styles in Flutter using Mix.


Overview

The baseTextStyle function provides a consistent way to generate text styles across your Flutter app, relying on typography definitions from your mix_tokens.dart file.


Parameters

  • fontSize (String, required): Key referencing a font size in Tokens.textSizes. Defaults to 16 if the key is missing.
  • fontWeight (FontWeight, required): The desired font weight.
  • color (Color, required): The text color.
  • maxLines (int, required): Maximum number of text lines.
  • uppercase (bool, optional, default: false): Whether the text should be displayed in uppercase.

Default Values

  • UpperCase: false

Usage Example

Import this file and use baseTextStyle to build your text styles:

final style = baseTextStyle(
fontSize: 'md', // Use a semantic key defined in your tokens
fontWeight: FontWeight.bold,
color: Colors.black,
maxLines: 2,
uppercase: true,
);

You can then use this style in your widgets according to the mix package's conventions.


Dependencies


Notes

  • All styles inherit from baseStyle with flexible and expanded properties
  • Header height adjusts automatically based on screen width
  • Card style includes background color option
  • Default style provides basic container properties
  • Ensure Tokens.textSizes and Tokens.fontFamilyPrimary are available in your mix_tokens.dart file.