Skip to content

Generate for Fonts

This feature is introduced in Spider v4.2.0

Spider now supports code generation for fonts specified in pubspec.yaml. It will generate a class with font family names as const strings.

# global config
fonts: true
This generates font family names in FontFamily class in fonts.dart file.

If you want to change it, you can do so like this:

# global config

fonts:
  class_name: MyFonts
  file_name: custom_fonts

After this, just run spider build command and it will generate code for font families.

Example output

class FontFamily {
  FontFamily._();

  static const String roboto = 'Roboto';
  static const String openSans = 'Open Sans';
}

Specify --fonts-only flag to your build command to generate/re-generate only fonts.

spider build --fonts-only