I am learning Flutter and Dart. I noticed that thepubspec.yaml
file seems to contain more than just dependency versions for third party libraries. For example.
# The following section is specific to Flutter.
flutter:
uses-material-design: true
I understand that the Dart Pub Tool defines the format for the pubspec.yaml
and it seems like frameworks like Flutter can enhance the pubspec.yaml
with extra settings raising the following questions:
pubspec.yaml
designed to be used to provide configuration flags or only dependencies?pubspec.yaml
idiomatic Dart or unique?pubspec.yaml
only parsed by the pub
tool or is it parsed at runtime as a generic application config file?pubspec.yaml
and make settings like uses-material-design: true
available at runtime? Is pubspec.yaml designed to be used to provide configuration flags or only dependencies?
Historically it also contained build settings in pure Dart projects. For example settings for compiling to JS, but that was moved out to build.yaml
. See https://github.com/dart-lang/build/blob/master/build_config/README.md
Does the way flutter use
pubspec.yaml
idiomatic Dart or unique?
It's unique to Flutter.
Does Flutter implement it's own parser for pubspec.yaml and make settings like
uses-material-design: true
available at runtime?
yes.
These settings are build-time settings though, not runtime settings.
Actually I find it rather unfortunate that this file mixes up different purposes. In early Flutter days Flutter-specific settings were in a different file, but that also caused some difficulties (don't know details - only saw it mentioned in a GitHub discussion) so they merged it with pubspec.yaml
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With