Flutter 3.41 is live! Check out theFlutter 3.41 blog post!
Flutter pubspec options
Describes the Flutter-only fields in the pubspec file.
This page is primarily aimed at folks who write Flutter apps. If you write packages or plugins, (perhaps you want to create a federated plugin), you should check out theDeveloping packages and plugins page.
Overview
# Every Flutter project includes apubspec.yaml file, often referred to asthe pubspec. A basic pubspec is generated when you create a new Flutter project. It's located at the top of the project tree and contains metadata about the project that the Dart and Flutter tooling needs to know. The pubspec is written inYAML, which is human readable, but be aware thatwhite space (tabs v spaces) matters.
The pubspec specifies dependencies that the project requires, such as:
- Particular packages and their versions
- Fonts
- Images
- Developer packages (like testing or mocking packages)
- Particular constraints on the version of the Flutter SDK
Fields common to both Dart and Flutter projects are described inthe pubspec file ondart.dev. This page listsFlutter-specific fields and packages that are only valid for a Flutter project.
Example
# When you create a new project with theflutter create command (or by using the equivalent button in your IDE), it creates a pubspec for a basic Flutter app.
The first time you build your project, it also creates apubspec.lock file that contains specific versions of the included packages. This ensures that you get the same version the next time the project is built.
Here is an example of a Flutter project pubspec file. The Flutter-only fields and packages are highlighted.
name:<project name>description:A new Flutter project.publish_to:noneversion:1.0.0+1environment:sdk:^3.10.0dependencies:flutter:# Required for every Flutter projectsdk:flutter# Required for every Flutter projectflutter_localizations:# Required to enable localizationsdk:flutter# Required to enable localizationcupertino_icons:^1.0.8# Only required if you use Cupertino (iOS style) iconsdev_dependencies:flutter_test:sdk:flutter# Required for a Flutter project that includes testsflutter_lints:^6.0.0# Contains a set of recommended lints for Flutter codeflutter:uses-material-design:true# Required if you use the Material icon fontgenerate:true# Enables generation of localized strings from arb filesconfig:# App-specific configuration flags that mirror `flutter config`enable-swift-package-manager:trueassets:# Lists assets, such as image files-images/a_dot_burr.png-images/a_dot_ham.pnglicenses:# Lists additional license files to be bundled with the app-assets/my_license.txtfonts:# Required if your app uses custom fonts-family:Schylerfonts:-asset:fonts/Schyler-Regular.ttf-asset:fonts/Schyler-Italic.ttfstyle:italic-family:Trajan Profonts:-asset:fonts/TrajanPro.ttf-asset:fonts/TrajanPro_Bold.ttfweight:700Fields
#Flutter-specific and Dart-specific fields can be added to the Flutter pubspec. To learn more about Flutter-specific fields, see the following sections. To learn more about Dart-specific fields, seeDart's pubspec supported fields.
The pubspec can have additional auto-generated Flutter fields that are not listed here.
assets field
# A list of asset paths that your app uses. These assets are bundled with your application. Common types of assets include static data (for example,JSON), configuration files, icons, and images (JPEG,WebP,GIF, animatedWebP/GIF,PNG,BMP, andWBMP).
Besides listing the images that are included in the app package, an image asset can also refer to one or more resolution-specific "variants". For more information, see theresolution aware section of theAssets and images page. For information on adding assets from package dependencies, see theasset images in package dependencies section in the same page.
Theasset field has this structure:
flutter:assets:-[path_to_file | path_to_directory ][flavor_path_field | platform_path_field ][...]# path_to_file structure-path/to/directory/file# path_to_directory structure-path/to/directory/# flavor_path_field strucure-path:path/to/directoryflavors:-flavor_name# platform_path_field structure-path:path/to/fileplatforms:-platform_nameSubfields ofassets:
path_to_file: A string that represents the path to a file.path_to_directory: A string that represents the path to a directory.flavor_path_field: A path field and its flavor subfields.platform_path_field: A path field and its platform subfields.path: The path to an asset file or directory.flavors: A list of flutter flavors to use with assets at a specific path. To learn more about flavors, seeSet up flavors for iOS and macOS andSet up flavors for Android.platforms: A list of platforms to use with assets at a specific path. Valid values areandroid,ios,web,linux,macos, andwindows.
You can pass in a path to a file:
flutter:assets:-assets/images/my_image_a.png-assets/images/my_image_b.pngYou can pass in a path to a directory:
flutter:assets:-assets/images/-assets/icons/You can pass in a path to a directory for specific flavors:
flutter:assets:-path:assets/flavor_a_and_b/imagesflavors:-flavor_a-flavor_b-path:assets/flavor_c/imagesflavors:-flavor_cYou can pass in a path to a file for specific platforms:
flutter:assets:-path:assets/web_worker.jsplatforms:-web-path:assets/desktop_icon.pngplatforms:-windows-linux-macosconfig field
# A map of keys to flags (true orfalse) that influences how theflutter CLI is executed.
NOTE: This feature is only available as of#167953 on the
mainchannel.
The available keys mirror those available influtter config --list.
flutter:config:cli-animations:falseenable-swift-package-manager:trueUseflutter config --help for a description of each flag.
Flags are only read from the currentapplication package, and have no effect in the context of a package or dependency.
default-flavor field
#Assign a default Flutter flavor for an app. When used, you don't need to include the name of this flavor in Flutter launch command.
flutter:default-flavor:flavor_name In the following example, an Android Flutter app has a flavor calledstaging andproduction. Theproduction flavor is the default flavor. When that flavor is run, you don't need to include it in the launch command.
flutter:default-flavor:production// Use this command to run the default flavor (production).flutter run// Use this command to run non-default flavors (staging).flutter run --flavor stagingTo learn how to create Flutter flavors, seeSet up Flutter flavors for Android andSet up Flutter flavors for iOS and macOS.
deferred-components field
#Defer initial the download size of an Android app. Most often used with large applications, modularized applications, and applications with on-demand features.
Thedeferred-components field has this structure:
flutter:deferred-components:name:component_namelibraries:-string_expression[...]assets:-string_expression[...][...]Deferred component subfields:
name: The unique identifier for a specific deferred component.libraries: A list of Dart libraries that are part of the deferred component.assets: A list of asset paths that are associated with the deferred component.
Example:
flutter:deferred-components:-name:box_componentlibraries:-package:testdeferredcomponents/box.dart-name:gallery_featurelibraries:-package:testdeferredcomponents/gallery_feature.dartassets:-assets/gallery_images/gallery_feature.pngTo learn more about how you can use deferred components with a Flutter Android app, seeDeferred components for Android.
disable-swift-package-manager field
#Disable the use of the Swift Package Manager (SPM) so that it no longer manages dependencies in your iOS and macOS Flutter projects.
flutter:disable-swift-package-manager:trueNOTE: As of#168433 on the
mainchannel, this property has moved to theconfigsection:pubspec.yamlyamlflutter:config:enable-swift-package-manager:false
flutter field
#A field that contains Flutter-specific settings for your app.
flutter:[flutter_field][...]fonts field
#Configure and include custom fonts in your Flutter application.
For examples of using fonts see theUse a custom font andExport fonts from a package recipes in the Flutter cookbook.
Thefonts field has this structure:
flutter:fonts:-{font_family_field | font_asset_field }[...]# font_family_field structure-family:font_namefonts:-font_asset_field[...]# font_asset_field structure-asset:path/to/directory/font_nameweight:int_expression# Optionalstyle:string_expression# OptionalSubfields offonts:
family: Optional. The font family name. Can have multiple font assets.asset: The font to use.weight: Optional. The weight of the font. This can be100,200,300,400,500,600,700,800or900.style: Optional. The style of the font. This can beitalic.
Use a font that is not part of a font family:
flutter:fonts:-asset:fonts/Roboto-Regular.ttfweight:900# Optionalstyle:italic# OptionalUse a font family:
flutter:fonts:-family:Roboto# Optionalfonts:-asset:fonts/Roboto-Regular.ttf-asset:fonts/Roboto-Bold.ttfweight:700# Optionalstyle:italic# OptionalAlternatively, if you have a font that requires no family, weight or style requirements, you can declare it as a simple asset:
flutter:assets:-fonts/Roboto-Regular.ttfgenerate field
# Handles localization tasks. This field can appear as a subfield offlutter andmaterial.
Enable general localization:
flutter:generate:truelicenses field
# A list of additional license file paths that should be bundled with your application. These files are typically found within your project'sassets directory.
Thelicenses field has this structure:
flutter:licenses:-[path_to_file]plugin field
#Configure settings specifically for Flutter plugins.
Theplugin field has this structure:
flutter:plugin:platforms:android:# Optionalpackage:com.example.my_pluginpluginClass:MyPlugindartPluginClass:MyPluginClassNameffiPlugin:truedefault_package:my_plugin_namefileName:my_file.dartios:# OptionalpluginClass:MyPlugindartPluginClass:MyPluginClassNameffiPlugin:truedefault_package:my_plugin_namefileName:my_file.dartsharedDarwinSource:truemacos:# OptionalpluginClass:MyPlugindartPluginClass:MyPluginClassNameffiPlugin:truedefault_package:my_plugin_namefileName:my_file.dartsharedDarwinSource:truewindows:# OptionalpluginClass:MyPlugindartPluginClass:MyPluginClassNameffiPlugin:truedefault_package:my_plugin_namefileName:my_file.dartlinux:# OptionalpluginClass:MyPlugindartPluginClass:MyPluginClassNameffiPlugin:truedefault_package:my_plugin_namefileName:my_file.dartweb:# OptionalffiPlugin:truedefault_package:my_plugin_namefileName:my_file.dartimplements:# Optional-example_platform_interfaceSubfields ofplugin:
platforms: A list of platforms that will have configuration settings.package: The Android package name of the plugin. This can be used with the Android platform and is required.pluginClass: The name of the plugin class. Optional ifdartPluginClassis used for the same platform. This can be used with the Android, iOS, Linux macOS, and Windows platforms.default_package: Optional. The package that should be used as the default implementation of a platform interface. Only applicable to federated plugins, where the plugin's implementation is split into multiple platform-specific packages.dartPluginClass: Optional. The Dart class that serves as the entry point for a Flutter plugin. This can be used with the Android, iOS, Linux macOS, and Windows platforms.sharedDarwinSource: Optional. Indicates that the plugin shares native code between iOS and macOS. This can be used with the iOS and macOS platforms.fileName: Optional. The file that contains the plugin class.ffiPlugin: Optional. True if the plugin uses a Foreign Function Interface (FFI).implements: Optional. The platform interfaces that a Flutter plugin implements.
To learn more about plugins, seeDeveloping packages & plugins.
shaders field
# GLSL Shaders with theFRAG extension, must be declared in the shaders section of your project'spubspec.yaml file. The Flutter command-line tool compiles the shader to its appropriate backend format, and generates its necessary runtime metadata. The compiled shader is then included in the application just like an asset.
Theshaders field has this structure:
flutter:shaders:-{path_to_file | path_to_directory }[...]# path_to_file structure-assets/shaders/file# path_to_directory structure-assets/shaders/Add specific shaders:
flutter:shaders:-assets/shaders/shader_a.frag-assets/shaders/shader_b.fragAdd a directory of shaders:
flutter:shaders:-assets/shaders/ Alternatively, you can add your shader directory to theassets field:
flutter:assets:-assets/shaders/my_shader.fraguses-material-design field
#Use Material Design components in your Flutter app.
flutter:uses-material-design:truePackages
# The following Flutter-specific packages can be added to the pubspec. If you add a package, runflutter pub get in your terminal to install the package.
flutter package
# A package that represents the Flutter SDK itself and can be added to thedependencies field. Use this if your project relies on the Flutter SDK, not a regular package from pub.dev.
dependencies:flutter:sdk:flutterflutter_localizations package
# A package that represents the Flutter SDK itself and can be added to thedependencies field. Use this to enable the localization ofARB files. Often used with theintl package.
dependencies:flutter_localizations:sdk:flutterintl:anyflutter_test package
# A package that represents the Flutter SDK itself and can be added to thedependencies field. Use this if you have unit, widget, or integration tests for your Flutter app.
dependencies:flutter_test:sdk:flutterflutter_lints package
# A package that that provides a set of recommended lints for Flutter projects. This package can be added to thedev_dependency field in the pubspec.
dev_dependencies:flutter_lints:^6.0.0cupertino_icons
# A package that provides a set of Apple's Cupertino icons for use in Flutter applications. This package can be added to thedependency field in the pubspec.
dependencies:cupertino_icons:^1.0.0More information
#For more information on packages, plugins, and pubspec files, see the following:
- Creating packages on dart.dev
- Glossary of package terms on dart.dev
- Package dependencies on dart.dev
- Using packages
- What not to commit on dart.dev
Unless stated otherwise, the documentation on this site reflects Flutter 3.38.6. Page last updated on 2026-02-09.View source orreport an issue.