Export fonts from a package - Flutter

Viewed 138

Page URL: [https://flutter.dev/docs/cookbook/design/package-fonts.html][1]

Page source: [https://github.com/flutter/website/tree/master/src/docs/cookbook/design/package-fonts.md][1]

Description of issue:

I've been trying to replicate the project Export fonts from a package from the Flutter.dev cookbook page. But I'm getting lost in the instructions. The instructions indicate that :

To export a font from a package, you need to import the font files into the lib folder of the package project.

The instructions also say that (I quote)

assume you’ve got a Flutter library called awesome_package with fonts living in a lib/fonts folder.

And the awesome_package package/library folder structure is defined as follow

awesome_package/
  lib/
    awesome_package.dart
    fonts/
      Raleway-Regular.ttf
      Raleway-Italic.ttf

My question is : How do I create the awesome_package. Do I necessarily need to publish the package on the pub.dev ?

Please help me out

1 Answers

How do I create the awesome_package.

See more about Flutter packages and plugins

Do I necessarily need to publish the package on the pub.dev ?

No, you can use the package locally.

If you just want to use differents fonts, don't create a package for this, use this package google_fonts

Or you can use your own font

Docs

flutter:
  fonts:
    - family: font_name
      fonts:
        - asset: fonts/font_name1.ttf
        - asset: fonts/font_name1.ttf
Related