search ESC

Searching…

No results for "".

Type at least 2 characters to search.

Docs
You are viewing an older version (0.0.5). Go to the latest.

Font Family Customization

Customize the body and display fonts of your application through WindTheme, backed by the Google Fonts library.

WindTheme.setBodyFontString('Roboto');
WindTheme.setDisplayFontString('Lobster');

Default Font

When you start a new application with wind, the default font family is Inter, a versatile sans-serif face. You can replace it with any font supported by Google Fonts to match your design.

Customizing Fonts

WindTheme configures two fonts: the body font for general text content and the display font for large, prominent text such as headings.

Body Font

The body font is the primary font used for general text content.

// Set the body font
WindTheme.setBodyFontString('Roboto');

After this call, all text styled with the body font defaults to Roboto.

// Retrieve the current body font
String currentBodyFont = WindTheme.getBodyFontString();
print('Current body font: $currentBodyFont'); // Output: 'Roboto'

Display Font

The display font is typically used for large, prominent text such as headings or titles.

// Set the display font
WindTheme.setDisplayFontString('Lobster');

If no display font is set, getDisplayFontString falls back to the body font.

// Retrieve the current display font
String currentDisplayFont = WindTheme.getDisplayFontString();
print('Current display font: $currentDisplayFont'); // Output: 'Lobster'

Binding Fonts to the Flutter Theme

To apply the configured fonts globally, bind them to Flutter's ThemeData through WindTheme.toThemeData, which integrates the font settings with Flutter's theme system. You can also pass bodyFontString and displayFontString directly to toThemeData to override the configured fonts for a single build.

MaterialApp(
  theme: WindTheme.toThemeData(
    bodyFontString: 'Roboto',
    displayFontString: 'Lobster',
  ),
);

For full guidance on applying fonts at the theme level, see Binding the Flutter Theme.