10

As the title describes, I wonder if it is possible to split the pubspec.yaml file in Flutter into several files. The use case I'm thinking about is generating the imported assets declarations with an import script. But it seems like a bad idea to mix code generation and manual edits in the same file.

So I would like to generate a separate assets import file and import that into the pubspec.yaml file.

Is that possible and if so how?

Change this:

flutter:

  assets:
    - images/a_dot_burr.jpeg
    - images/a_dot_ham.jpeg

  fonts:
    - family: SomeFont
      fonts:
        -assets: fonts/SomeFont.tff

into something like

flutter:
  #import imageAssets.yaml


  #import fontsAssets.yaml
Isak dl
  • 448
  • 3
  • 13
  • 1
    should make a request to add this feature to the YAML parser – Ali Qanbari Sep 23 '19 at 08:50
  • 2
    I checked some of the source code and there isn't anything about it. it may be possible to do it using build_runner but that would require running it every time you want to update the pubspec file. – Ali Qanbari Sep 23 '19 at 08:54
  • Maybe you can try [this](https://stackoverflow.com/questions/69663055/share-pubspec-yaml-package-dependency-versions-along-multiple-local-flutter-and) – Nullable Jun 02 '23 at 03:01

1 Answers1

7

No, it is not possible.

pubspec.yaml does not support imports.

Rémi Rousselet
  • 256,336
  • 79
  • 519
  • 432