CINXE.COM
The pubspec file | Dart
<!doctype html><html lang="en"><head><meta charset="utf-8"><meta http-equiv="x-ua-compatible" content="ie=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><script>!function(e,t,a,n){e[n]=e[n]||[],e[n].push({"gtm.start":(new Date).getTime(),event:"gtm.js"});var g=t.getElementsByTagName(a)[0],m=t.createElement(a);m.async=!0,m.src="https://www.googletagmanager.com/gtm.js?id=GTM-5VSZM5J",g.parentNode.insertBefore(m,g)}(window,document,"script","dataLayer")</script><meta name="description" content="Reference guide for the fields in pubspec.yaml."><title>The pubspec file | Dart</title><link rel="icon" sizes="64x64" href="/assets/img/logo/dart-64.png" eleventy:ignore><link href="/assets/img/touch-icon-iphone.png" rel="apple-touch-icon" eleventy:ignore><link href="/assets/img/touch-icon-ipad.png" rel="apple-touch-icon" sizes="152x152" eleventy:ignore><link href="/assets/img/touch-icon-iphone-retina.png" rel="apple-touch-icon" sizes="180x180" eleventy:ignore><link href="/assets/img/touch-icon-ipad-retina.png" rel="apple-touch-icon" sizes="167x167" eleventy:ignore><meta name="twitter:card" content="summary"><meta name="twitter:site" content="@dart_lang"><meta name="twitter:title" content="The pubspec file"><meta name="twitter:description" content="Reference guide for the fields in pubspec.yaml."><meta property="og:title" content="The pubspec file"><meta property="og:description" content="Reference guide for the fields in pubspec.yaml."><meta property="og:url" content="/tools/pub/pubspec/"><meta property="og:image" content="/assets/img/logo/dart-logo-for-shares.png?2" eleventy:ignore><link rel="preconnect" href="https://fonts.googleapis.com"><link rel="preconnect" href="https://fonts.gstatic.com" crossorigin><link href="https://fonts.googleapis.com/css2?family=Google+Sans:wght@400;500;700&display=swap" rel="stylesheet"><link href="https://fonts.googleapis.com/css2?family=Google+Sans+Display:wght@400&display=swap" rel="stylesheet"><link href="https://fonts.googleapis.com/css2?family=Google+Sans+Mono:wght@400;500;700&display=swap" rel="stylesheet"><link href="https://fonts.googleapis.com/css2?family=Google+Sans+Text:wght@400;500;700&display=swap" rel="stylesheet"><link href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@24,400,0,0" rel="stylesheet"><link rel="stylesheet" href="/assets/css/main.css"><script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.0/jquery.min.js" integrity="sha512-3gJwYpMe3QewGELv8k/BX9vcqhryRdzRMxVfq6ngyWXwo03GFEzjsUm8Q7RZcHPHksttq7/GFoxjCVUjkjvPdw==" crossorigin="anonymous" referrerpolicy="no-referrer"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/4.6.2/js/bootstrap.min.js" integrity="sha384-+sLIOodYLS7CIrQpBjl+C7nPvqq+FbNUBDunl/OZv93DB7Ln/533i8e/mZXLi/P+" crossorigin="anonymous" referrerpolicy="no-referrer"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/js-cookie/3.0.5/js.cookie.min.js" integrity="sha512-nlp9/l96/EpjYBx7EP7pGASVXNe80hGhYAUrjeXnu/fyF5Py0/RXav4BBNs7n5Hx1WFhOEOWSAVjGeC3oKxDVQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script><script src="/assets/js/os-tabs.js"></script><script src="/assets/js/utilities.js"></script><script src="/assets/js/main.js"></script><script>!function(e,a,t,n,c,o,s){e.GoogleAnalyticsObject=c,e[c]=e[c]||function(){(e[c].q=e[c].q||[]).push(arguments)},e[c].l=1*new Date,o=a.createElement(t),s=a.getElementsByTagName(t)[0],o.async=1,o.src="//www.google-analytics.com/analytics.js",s.parentNode.insertBefore(o,s)}(window,document,"script",0,"ga"),ga("create","UA-26406144-4","auto"),ga("send","pageview")</script></head><body class="default.html show_banner"><a id="skip" href="#site-content-title">Skip to main content</a><section id="cookie-notice"><div class="container"><p>dart.dev uses cookies from Google to deliver and enhance the quality of its services and to analyze traffic. <a href="https://policies.google.com/technologies/cookies" target="_blank" rel="noopener">Learn more</a>.</p><button id="cookie-consent" class="btn btn-primary">OK, got it</button></div></section><noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-5VSZM5J" height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript><header id="page-header" class="site-header"><nav id="mainnav" class="site-header"><div id="menu-toggle"><i class="material-symbols">menu</i></div><a href="/" class="brand" title="Dart"><img src="/assets/img/logo/logo-white-text.svg" alt="Dart"></a><ul class="navbar"><li><a href="/overview" class="nav-link">Overview</a></li><li class="mainnav__get-started"><a href="/guides" class="nav-link active"><span>Docs</span></a></li><li><a href="/community" class="nav-link">Community</a></li><li><a href="/#try-dart" class="nav-link">Try Dart</a></li><li><a href="/get-dart" class="nav-link">Get Dart</a></li><li class="searchfield"><form action="/search" class="site-header__search form-inline" id="cse-search-box"><input type="hidden" name="cx" value="011220921317074318178:_yy-tmb5t_i"> <input type="hidden" name="ie" value="UTF-8"> <input type="hidden" name="hl" value="en"> <input class="site-header__searchfield form-control search-field" type="search" name="q" id="search-main" autocomplete="off" placeholder="Search" aria-label="Search"></form></li></ul></nav></header><div class="banner"><p class="banner__text">Announcing Dart 3.5 and an updated Dart roadmap! <a href="https://medium.com/dartlang/dart-3-5-6ca36259fa2f" target="_blank">Learn more</a></p></div><div id="sidenav"><form action="/search/" class="site-header__search form-inline"><input class="site-header__searchfield form-control search-field" type="search" name="q" id="search-side" autocomplete="off" placeholder="Search" aria-label="Search"></form><div class="site-sidebar"><ul class="navbar-nav"><li class="nav-item"><a href="/overview" class="nav-link">Overview</a></li><li class="nav-item"><a href="/community" class="nav-link">Community</a></li><li class="nav-item"><a href="https://dartpad.dev" class="nav-link">Try Dart</a></li><li class="nav-item"><a href="/get-dart" class="nav-link">Get Dart</a></li><li class="nav-item"><a href="/guides" class="nav-link">Docs</a></li><li aria-hidden="true"><div class="sidebar-primary-divider"></div></li></ul><ul class="nav flex-column"><li class="nav-item"><a class="nav-link collapsed collapsible" data-toggle="collapse" href="#sidenav-1" role="button" aria-expanded="false" aria-controls="sidenav-1">Language</a><ul class="nav flex-column flex-nowrap collapse" id="sidenav-1"><li class="nav-item"><a class="nav-link" href="/language">Introduction</a></li><li class="nav-item"><a class="nav-link collapsible collapsed" data-toggle="collapse" data-target="#sidenav-1-2" href="#sidenav-1-2" role="button" aria-expanded="false" aria-controls="sidenav-1-2">Syntax basics</a><ul class="nav flex-column flex-nowrap collapse" id="sidenav-1-2"><li class="nav-item"><a class="nav-link" href="/language/variables">Variables</a></li><li class="nav-item"><a class="nav-link" href="/language/operators">Operators</a></li><li class="nav-item"><a class="nav-link" href="/language/comments">Comments</a></li><li class="nav-item"><a class="nav-link" href="/language/metadata">Metadata</a></li><li class="nav-item"><a class="nav-link" href="/language/libraries">Libraries & imports</a></li><li class="nav-item"><a class="nav-link" href="/language/keywords">Keywords</a></li></ul></li><li class="nav-item"><a class="nav-link collapsible collapsed" data-toggle="collapse" data-target="#sidenav-1-3" href="#sidenav-1-3" role="button" aria-expanded="false" aria-controls="sidenav-1-3">Types</a><ul class="nav flex-column flex-nowrap collapse" id="sidenav-1-3"><li class="nav-item"><a class="nav-link" href="/language/built-in-types">Built-in types</a></li><li class="nav-item"><a class="nav-link" href="/language/records">Records</a></li><li class="nav-item"><a class="nav-link" href="/language/collections">Collections</a></li><li class="nav-item"><a class="nav-link" href="/language/generics">Generics</a></li><li class="nav-item"><a class="nav-link" href="/language/typedefs">Typedefs</a></li><li class="nav-item"><a class="nav-link" href="/language/type-system">Type system</a></li></ul></li><li class="nav-item"><a class="nav-link collapsible collapsed" data-toggle="collapse" data-target="#sidenav-1-4" href="#sidenav-1-4" role="button" aria-expanded="false" aria-controls="sidenav-1-4">Patterns</a><ul class="nav flex-column flex-nowrap collapse" id="sidenav-1-4"><li class="nav-item"><a class="nav-link" href="/language/patterns">Overview & usage</a></li><li class="nav-item"><a class="nav-link" href="/language/pattern-types">Pattern types</a></li><li class="nav-item"><a class="nav-link" href="https://codelabs.developers.google.com/codelabs/dart-patterns-records" target="_blank" rel="noopener">Applied tutorial</a></li></ul></li><li class="nav-item"><a class="nav-link" href="/language/functions">Functions</a></li><li class="nav-item"><a class="nav-link collapsible collapsed" data-toggle="collapse" data-target="#sidenav-1-6" href="#sidenav-1-6" role="button" aria-expanded="false" aria-controls="sidenav-1-6">Control flow</a><ul class="nav flex-column flex-nowrap collapse" id="sidenav-1-6"><li class="nav-item"><a class="nav-link" href="/language/loops">Loops</a></li><li class="nav-item"><a class="nav-link" href="/language/branches">Branches</a></li><li class="nav-item"><a class="nav-link" href="/language/error-handling">Error handling</a></li></ul></li><li class="nav-item"><a class="nav-link collapsible collapsed" data-toggle="collapse" data-target="#sidenav-1-7" href="#sidenav-1-7" role="button" aria-expanded="false" aria-controls="sidenav-1-7">Classes & objects</a><ul class="nav flex-column flex-nowrap collapse" id="sidenav-1-7"><li class="nav-item"><a class="nav-link" href="/language/classes">Classes</a></li><li class="nav-item"><a class="nav-link" href="/language/constructors">Constructors</a></li><li class="nav-item"><a class="nav-link" href="/language/methods">Methods</a></li><li class="nav-item"><a class="nav-link" href="/language/extend">Extend a class</a></li><li class="nav-item"><a class="nav-link" href="/language/mixins">Mixins</a></li><li class="nav-item"><a class="nav-link" href="/language/enums">Enums</a></li><li class="nav-item"><a class="nav-link" href="/language/extension-methods">Extension methods</a></li><li class="nav-item"><a class="nav-link" href="/language/extension-types">Extension types</a></li><li class="nav-item"><a class="nav-link" href="/language/callable-objects">Callable objects</a></li></ul></li><li class="nav-item"><a class="nav-link collapsible collapsed" data-toggle="collapse" data-target="#sidenav-1-8" href="#sidenav-1-8" role="button" aria-expanded="false" aria-controls="sidenav-1-8">Class modifiers</a><ul class="nav flex-column flex-nowrap collapse" id="sidenav-1-8"><li class="nav-item"><a class="nav-link" href="/language/class-modifiers">Overview & usage</a></li><li class="nav-item"><a class="nav-link" href="/language/class-modifiers-for-apis">Class modifiers for API maintainers</a></li><li class="nav-item"><a class="nav-link" href="/language/modifier-reference">Reference</a></li></ul></li><li class="nav-item"><a class="nav-link collapsible collapsed" data-toggle="collapse" data-target="#sidenav-1-9" href="#sidenav-1-9" role="button" aria-expanded="false" aria-controls="sidenav-1-9">Concurrency</a><ul class="nav flex-column flex-nowrap collapse" id="sidenav-1-9"><li class="nav-item"><a class="nav-link" href="/language/concurrency">Overview</a></li><li class="nav-item"><a class="nav-link" href="/language/async">Asynchronous support</a></li><li class="nav-item"><a class="nav-link" href="/language/isolates">Isolates</a></li></ul></li><li class="nav-item"><a class="nav-link collapsible collapsed" data-toggle="collapse" data-target="#sidenav-1-10" href="#sidenav-1-10" role="button" aria-expanded="false" aria-controls="sidenav-1-10">Null safety</a><ul class="nav flex-column flex-nowrap collapse" id="sidenav-1-10"><li class="nav-item"><a class="nav-link" href="/null-safety">Sound null safety</a></li><li class="nav-item"><a class="nav-link" href="/null-safety/migration-guide">Migrating to null safety</a></li><li class="nav-item"><a class="nav-link" href="/null-safety/understanding-null-safety">Understanding null safety</a></li><li class="nav-item"><a class="nav-link" href="/null-safety/unsound-null-safety">Unsound null safety</a></li><li class="nav-item"><a class="nav-link" href="/null-safety/faq">FAQ</a></li></ul></li></ul></li><li class="nav-item"><a class="nav-link collapsed collapsible" data-toggle="collapse" href="#sidenav-2" role="button" aria-expanded="false" aria-controls="sidenav-2">Core libraries</a><ul class="nav flex-column flex-nowrap collapse" id="sidenav-2"><li class="nav-item"><a class="nav-link" href="/libraries">Overview</a></li><li class="nav-item"><a class="nav-link" href="/libraries/dart-core">dart:core</a></li><li class="nav-item"><a class="nav-link" href="/libraries/dart-async">dart:async</a></li><li class="nav-item"><a class="nav-link" href="/libraries/dart-math">dart:math</a></li><li class="nav-item"><a class="nav-link" href="/libraries/dart-convert">dart:convert</a></li><li class="nav-item"><a class="nav-link" href="/libraries/dart-io">dart:io</a></li><li class="nav-item"><a class="nav-link" href="/libraries/dart-html">dart:html</a></li><div class="dropdown-divider"></div><li class="nav-item"><a class="nav-link" href="/libraries/collections/iterables">Iterable collections</a></li><li class="nav-item"><a class="nav-link collapsible collapsed" data-toggle="collapse" data-target="#sidenav-2-10" href="#sidenav-2-10" role="button" aria-expanded="false" aria-controls="sidenav-2-10">Asynchronous programming</a><ul class="nav flex-column flex-nowrap collapse" id="sidenav-2-10"><li class="nav-item"><a class="nav-link" href="/libraries/async/async-await">Tutorial</a></li><li class="nav-item"><a class="nav-link" href="/libraries/async/futures-error-handling">Futures and error handling</a></li><li class="nav-item"><a class="nav-link" href="/libraries/async/using-streams">Using streams</a></li><li class="nav-item"><a class="nav-link" href="/libraries/async/creating-streams">Creating streams</a></li></ul></li></ul></li><li class="nav-item"><a class="nav-link collapsed collapsible" data-toggle="collapse" href="#sidenav-3" role="button" aria-expanded="false" aria-controls="sidenav-3">Effective Dart</a><ul class="nav flex-column flex-nowrap collapse" id="sidenav-3"><li class="nav-item"><a class="nav-link" href="/effective-dart">Overview</a></li><li class="nav-item"><a class="nav-link" href="/effective-dart/style">Style</a></li><li class="nav-item"><a class="nav-link" href="/effective-dart/documentation">Documentation</a></li><li class="nav-item"><a class="nav-link" href="/effective-dart/usage">Usage</a></li><li class="nav-item"><a class="nav-link" href="/effective-dart/design">Design</a></li></ul></li><li class="nav-item"><a class="nav-link active collapsible" data-toggle="collapse" href="#sidenav-4" role="button" aria-expanded="true" aria-controls="sidenav-4">Packages</a><ul class="nav flex-column flex-nowrap collapse show" id="sidenav-4"><li class="nav-item"><a class="nav-link" href="/tools/pub/packages">How to use packages</a></li><li class="nav-item"><a class="nav-link" href="/resources/useful-packages">Commonly used packages</a></li><li class="nav-item"><a class="nav-link" href="/guides/libraries/create-packages">Creating packages</a></li><li class="nav-item"><a class="nav-link" href="/tools/pub/publishing">Publishing packages</a></li><li class="nav-item"><a class="nav-link" href="/tools/pub/writing-package-pages">Writing package pages</a></li><li class="nav-item"><a class="nav-link active collapsible" data-toggle="collapse" data-target="#sidenav-4-6" href="#sidenav-4-6" role="button" aria-expanded="true" aria-controls="sidenav-4-6">Package reference</a><ul class="nav flex-column flex-nowrap collapse show" id="sidenav-4-6"><li class="nav-item"><a class="nav-link" href="/tools/pub/dependencies">Dependencies</a></li><li class="nav-item"><a class="nav-link" href="/tools/pub/glossary">Glossary</a></li><li class="nav-item"><a class="nav-link" href="/tools/pub/package-layout">Package layout conventions</a></li><li class="nav-item"><a class="nav-link" href="/tools/pub/environment-variables">Pub environment variables</a></li><li class="nav-item"><a class="nav-link active" href="/tools/pub/pubspec">Pubspec file</a></li><li class="nav-item"><a class="nav-link" href="/tools/pub/troubleshoot">Troubleshooting pub</a></li><li class="nav-item"><a class="nav-link" href="/tools/pub/verified-publishers">Verified publishers</a></li><li class="nav-item"><a class="nav-link" href="/tools/pub/security-advisories">Security advisories</a></li><li class="nav-item"><a class="nav-link" href="/tools/pub/versioning">Versioning</a></li><li class="nav-item"><a class="nav-link" href="/tools/pub/custom-package-repositories">Custom package repositories</a></li></ul></li><li class="nav-item"><a class="nav-link" href="/guides/libraries/private-files">What not to commit</a></li></ul></li><li class="nav-item"><a class="nav-link collapsed collapsible" data-toggle="collapse" href="#sidenav-5" role="button" aria-expanded="false" aria-controls="sidenav-5">Development</a><ul class="nav flex-column flex-nowrap collapse" id="sidenav-5"><li class="nav-item"><a class="nav-link" href="/guides/json">JSON</a></li><li class="nav-item"><a class="nav-link" href="/guides/language/numbers">Number representation</a></li><li class="nav-item"><a class="nav-link" href="/resources/google-apis">Google APIs</a></li><li class="nav-item"><a class="nav-link" href="/multiplatform-apps">Multi-platform apps</a></li><li class="nav-item"><a class="nav-link collapsible collapsed" data-toggle="collapse" data-target="#sidenav-5-5" href="#sidenav-5-5" role="button" aria-expanded="false" aria-controls="sidenav-5-5">Command-line & server apps</a><ul class="nav flex-column flex-nowrap collapse" id="sidenav-5-5"><li class="nav-item"><a class="nav-link" href="/server">Overview</a></li><li class="nav-item"><a class="nav-link" href="/tutorials/server/get-started">Get started</a></li><li class="nav-item"><a class="nav-link" href="/tutorials/server/cmdline">Write command-line apps</a></li><li class="nav-item"><a class="nav-link" href="/tutorials/server/fetch-data">Fetch data from the internet</a></li><li class="nav-item"><a class="nav-link" href="/tutorials/server/httpserver">Write HTTP servers</a></li><li class="nav-item"><a class="nav-link" href="/server/libraries">Libraries & packages</a></li><li class="nav-item"><a class="nav-link" href="/server/google-cloud">Google Cloud</a></li></ul></li><li class="nav-item"><a class="nav-link collapsible collapsed" data-toggle="collapse" data-target="#sidenav-5-6" href="#sidenav-5-6" role="button" aria-expanded="false" aria-controls="sidenav-5-6">Web apps</a><ul class="nav flex-column flex-nowrap collapse" id="sidenav-5-6"><li class="nav-item"><a class="nav-link" href="/web">Overview</a></li><li class="nav-item"><a class="nav-link" href="/web/get-started">Get started</a></li><li class="nav-item"><a class="nav-link" href="/web/deployment">Deployment</a></li><li class="nav-item"><a class="nav-link" href="/web/libraries">Libraries & packages</a></li><li class="nav-item"><a class="nav-link" href="/web/wasm">Wasm compilation</a></li></ul></li><li class="nav-item"><a class="nav-link" href="/guides/environment-declarations">Environment declarations</a></li></ul></li><li class="nav-item"><a class="nav-link collapsed collapsible" data-toggle="collapse" href="#sidenav-6" role="button" aria-expanded="false" aria-controls="sidenav-6">Interoperability</a><ul class="nav flex-column flex-nowrap collapse" id="sidenav-6"><li class="nav-item"><a class="nav-link" href="/interop/c-interop">C interop</a></li><li class="nav-item"><a class="nav-link" href="/interop/objective-c-interop">Objective-C & Swift interop</a></li><li class="nav-item"><a class="nav-link" href="/interop/java-interop">Java & Kotlin interop</a></li><li class="nav-item"><a class="nav-link collapsible collapsed" data-toggle="collapse" data-target="#sidenav-6-4" href="#sidenav-6-4" role="button" aria-expanded="false" aria-controls="sidenav-6-4">JavaScript interop</a><ul class="nav flex-column flex-nowrap collapse" id="sidenav-6-4"><li class="nav-item"><a class="nav-link" href="/interop/js-interop">Overview</a></li><li class="nav-item"><a class="nav-link" href="/interop/js-interop/usage">Usage</a></li><li class="nav-item"><a class="nav-link" href="/interop/js-interop/js-types">JS types</a></li><li class="nav-item"><a class="nav-link" href="/interop/js-interop/tutorials">Tutorials</a></li><li class="nav-item"><a class="nav-link" href="/interop/js-interop/past-js-interop">Past JS interop</a></li><div class="dropdown-divider"></div><li class="nav-item"><a class="nav-link" href="/interop/js-interop/package-web">Web interop</a></li></ul></li></ul></li><li class="nav-item"><a class="nav-link collapsed collapsible" data-toggle="collapse" href="#sidenav-7" role="button" aria-expanded="false" aria-controls="sidenav-7">Tools & techniques</a><ul class="nav flex-column flex-nowrap collapse" id="sidenav-7"><li class="nav-item"><a class="nav-link" href="/tools">Overview</a></li><li class="nav-item"><a class="nav-link collapsible collapsed" data-toggle="collapse" data-target="#sidenav-7-2" href="#sidenav-7-2" role="button" aria-expanded="false" aria-controls="sidenav-7-2">Editors & debuggers</a><ul class="nav flex-column flex-nowrap collapse" id="sidenav-7-2"><li class="nav-item"><a class="nav-link" href="/tools/jetbrains-plugin">IntelliJ & Android Studio</a></li><li class="nav-item"><a class="nav-link" href="/tools/vs-code">VS Code</a></li><li class="nav-item"><a class="nav-link" href="/tools/dart-devtools">Dart DevTools</a></li><li class="nav-item"><a class="nav-link collapsible collapsed" data-toggle="collapse" data-target="#sidenav-7-2-4" href="#sidenav-7-2-4" role="button" aria-expanded="false" aria-controls="sidenav-7-2-4">DartPad</a><ul class="nav flex-column flex-nowrap collapse" id="sidenav-7-2-4"><li class="nav-item"><a class="nav-link" href="/tools/dartpad">Overview</a></li><li class="nav-item"><a class="nav-link" href="/tools/dartpad/troubleshoot">Troubleshooting DartPad</a></li></ul></li></ul></li><li class="nav-item"><a class="nav-link collapsible collapsed" data-toggle="collapse" data-target="#sidenav-7-3" href="#sidenav-7-3" role="button" aria-expanded="false" aria-controls="sidenav-7-3">Command-line tools</a><ul class="nav flex-column flex-nowrap collapse" id="sidenav-7-3"><li class="nav-item"><a class="nav-link collapsible" data-toggle="collapse" data-target="#sidenav-7-3-1" href="#sidenav-7-3-1" role="button" aria-expanded="true" aria-controls="sidenav-7-3-1">Dart SDK</a><ul class="nav flex-column flex-nowrap collapse show" id="sidenav-7-3-1"><li class="nav-item"><a class="nav-link" href="/tools/sdk">Overview</a></li><li class="nav-item"><a class="nav-link" href="/tools/dart-tool">dart</a></li><li class="nav-item"><a class="nav-link" href="/tools/dart-analyze">dart analyze</a></li><li class="nav-item"><a class="nav-link" href="/tools/dart-compile">dart compile</a></li><li class="nav-item"><a class="nav-link" href="/tools/dart-create">dart create</a></li><li class="nav-item"><a class="nav-link" href="/tools/dart-doc">dart doc</a></li><li class="nav-item"><a class="nav-link" href="/tools/dart-fix">dart fix</a></li><li class="nav-item"><a class="nav-link" href="/tools/dart-format">dart format</a></li><li class="nav-item"><a class="nav-link" href="/tools/dart-info">dart info</a></li><li class="nav-item"><a class="nav-link" href="/tools/pub/cmd">dart pub</a></li><li class="nav-item"><a class="nav-link" href="/tools/dart-run">dart run</a></li><li class="nav-item"><a class="nav-link" href="/tools/dart-test">dart test</a></li><li class="nav-item"><a class="nav-link" href="/tools/dartaotruntime">dartaotruntime</a></li><li class="nav-item"><a class="nav-link" href="/tools/experiment-flags">Experiment flags</a></li></ul></li><li class="nav-item"><a class="nav-link collapsible" data-toggle="collapse" data-target="#sidenav-7-3-2" href="#sidenav-7-3-2" role="button" aria-expanded="true" aria-controls="sidenav-7-3-2">Other command-line tools</a><ul class="nav flex-column flex-nowrap collapse show" id="sidenav-7-3-2"><li class="nav-item"><a class="nav-link" href="/tools/build_runner">build_runner</a></li><li class="nav-item"><a class="nav-link" href="/tools/webdev">webdev</a></li></ul></li></ul></li><li class="nav-item"><a class="nav-link collapsible collapsed" data-toggle="collapse" data-target="#sidenav-7-4" href="#sidenav-7-4" role="button" aria-expanded="false" aria-controls="sidenav-7-4">Static analysis</a><ul class="nav flex-column flex-nowrap collapse" id="sidenav-7-4"><li class="nav-item"><a class="nav-link" href="/tools/analysis">Customizing static analysis</a></li><li class="nav-item"><a class="nav-link" href="/guides/language/sound-problems">Fixing common type problems</a></li><li class="nav-item"><a class="nav-link" href="/tools/non-promotion-reasons">Fixing type promotion failures</a></li><li class="nav-item"><a class="nav-link" href="/tools/linter-rules">Linter rules</a></li><li class="nav-item"><a class="nav-link" href="/tools/diagnostic-messages">Diagnostic messages</a></li></ul></li><li class="nav-item"><a class="nav-link collapsible collapsed" data-toggle="collapse" data-target="#sidenav-7-5" href="#sidenav-7-5" role="button" aria-expanded="false" aria-controls="sidenav-7-5">Testing & optimization</a><ul class="nav flex-column flex-nowrap collapse" id="sidenav-7-5"><li class="nav-item"><a class="nav-link" href="/guides/testing">Testing</a></li><li class="nav-item"><a class="nav-link" href="/web/debugging">Debugging web apps</a></li></ul></li></ul></li><li aria-hidden="true"><div class="sidebar-primary-divider"></div></li><li class="nav-item"><a class="nav-link collapsed collapsible" data-toggle="collapse" href="#sidenav-9" role="button" aria-expanded="false" aria-controls="sidenav-9">Resources</a><ul class="nav flex-column flex-nowrap collapse" id="sidenav-9"><li class="nav-item"><a class="nav-link" href="/resources/dart-cheatsheet">Language cheatsheet</a></li><li class="nav-item"><a class="nav-link" href="/resources/breaking-changes">Breaking changes</a></li><li class="nav-item"><a class="nav-link" href="/guides/language/evolution">Language evolution</a></li><li class="nav-item"><a class="nav-link" href="/guides/language/spec">Language specification</a></li><li class="nav-item"><a class="nav-link" href="/resources/dart-3-migration">Dart 3 migration guide</a></li><li class="nav-item"><a class="nav-link collapsible collapsed" data-toggle="collapse" data-target="#sidenav-9-6" href="#sidenav-9-6" role="button" aria-expanded="false" aria-controls="sidenav-9-6">Coming from ...</a><ul class="nav flex-column flex-nowrap collapse" id="sidenav-9-6"><li class="nav-item"><a class="nav-link" href="/resources/coming-from/js-to-dart">JavaScript to Dart</a></li><li class="nav-item"><a class="nav-link" href="/resources/coming-from/swift-to-dart">Swift to Dart</a></li></ul></li><div class="dropdown-divider"></div><li class="nav-item"><a class="nav-link" href="/resources/faq">FAQ</a></li><li class="nav-item"><a class="nav-link" href="/resources/glossary">Glossary</a></li><li class="nav-item"><a class="nav-link" href="/resources/books">Books</a></li><li class="nav-item"><a class="nav-link" href="/resources/videos">Videos</a></li><li class="nav-item"><a class="nav-link" href="/tutorials">Tutorials</a></li></ul></li><li class="nav-item"><a class="nav-link collapsible" data-toggle="collapse" href="#sidenav-10" role="button" aria-expanded="true" aria-controls="sidenav-10">Related sites</a><ul class="nav flex-column flex-nowrap collapse show" id="sidenav-10"><li class="nav-item"><a class="nav-link" href="https://api.dart.dev" target="_blank" rel="noopener">API reference</a></li><li class="nav-item"><a class="nav-link" href="https://medium.com/dartlang" target="_blank" rel="noopener">Blog</a></li><li class="nav-item"><a class="nav-link" href="https://dartpad.dev" target="_blank" rel="noopener">DartPad (online editor)</a></li><li class="nav-item"><a class="nav-link" href="https://flutter.dev" target="_blank" rel="noopener">Flutter</a></li><li class="nav-item"><a class="nav-link" href="https://pub.dev" target="_blank" rel="noopener">Package site</a></li></ul></li></ul></div></div><main id="page-content"><div id="site-toc--side" class="site-toc"><header class="site-toc__title">Contents</header><ul class="section-nav"><li class="toc-entry nav-item"><a class="nav-link" href="#supported-fields">Supported fields</a></li><li class="toc-entry nav-item"><a class="nav-link" href="#example">Example</a></li><li class="toc-entry nav-item"><a class="nav-link" href="#details">Details</a><ul class="nav"><li class="toc-entry nav-item"><a class="nav-link" href="#name">Name</a></li><li class="toc-entry nav-item"><a class="nav-link" href="#version">Version</a></li><li class="toc-entry nav-item"><a class="nav-link" href="#description">Description</a></li><li class="toc-entry nav-item"><a class="nav-link" href="#homepage">Homepage</a></li><li class="toc-entry nav-item"><a class="nav-link" href="#repository">Repository</a></li><li class="toc-entry nav-item"><a class="nav-link" href="#issue-tracker">Issue tracker</a></li><li class="toc-entry nav-item"><a class="nav-link" href="#documentation">Documentation</a></li><li class="toc-entry nav-item"><a class="nav-link" href="#dependencies">Dependencies</a></li><li class="toc-entry nav-item"><a class="nav-link" href="#executables">Executables</a></li><li class="toc-entry nav-item"><a class="nav-link" href="#platforms">Platforms</a></li><li class="toc-entry nav-item"><a class="nav-link" href="#publish_to">Publish_<wbr>to</a></li><li class="toc-entry nav-item"><a class="nav-link" href="#funding">Funding</a></li><li class="toc-entry nav-item"><a class="nav-link" href="#false_secrets">False_<wbr>secrets</a></li><li class="toc-entry nav-item"><a class="nav-link" href="#screenshots">Screenshots</a></li><li class="toc-entry nav-item"><a class="nav-link" href="#topics">Topics</a></li><li class="toc-entry nav-item"><a class="nav-link" href="#ignored_advisories">Ignored_<wbr>advisories</a></li><li class="toc-entry nav-item"><a class="nav-link" href="#sdk-constraints">SDK constraints</a></li></ul></li></ul></div><article><div class="content"><div id="site-content-title"><h1>The pubspec file</h1></div><div id="site-toc--inline" class="site-toc toc-collapsible toc-collapsed"><header class="site-toc__title">Contents <span class="site-toc--inline__toggle toc-toggle-down"><i class="material-symbols">keyboard_arrow_down</i></span> <span class="site-toc--inline__toggle toc-toggle-up"><i class="material-symbols">keyboard_arrow_up</i></span></header><ul class="section-nav"><li class="toc-entry"><a href="#supported-fields">Supported fields</a></li><li class="toc-entry"><a href="#example">Example</a></li><li class="toc-entry"><a href="#details">Details</a><ul><li class="toc-entry"><a href="#name">Name</a></li><li class="toc-entry"><a href="#version">Version</a></li><li class="toc-entry"><a href="#description">Description</a></li><li class="toc-entry"><a href="#homepage">Homepage</a></li><li class="toc-entry"><a href="#repository">Repository</a></li><li class="toc-entry"><a href="#issue-tracker">Issue tracker</a></li><li class="toc-entry"><a href="#documentation">Documentation</a></li><li class="toc-entry"><a href="#dependencies">Dependencies</a></li><li class="toc-entry"><a href="#executables">Executables</a></li><li class="toc-entry"><a href="#platforms">Platforms</a></li><li class="toc-entry"><a href="#publish_to">Publish_to</a></li><li class="toc-entry"><a href="#funding">Funding</a></li><li class="toc-entry"><a href="#false_secrets">False_secrets</a></li><li class="toc-entry"><a href="#screenshots">Screenshots</a></li><li class="toc-entry"><a href="#topics">Topics</a></li><li class="toc-entry"><a href="#ignored_advisories">Ignored_advisories</a></li><li class="toc-entry"><a href="#sdk-constraints">SDK constraints</a></li></ul></li></ul><span class="site-toc--inline__toggle toc-toggle-more-items"><i class="material-symbols">more_horiz</i></span></div><p>Every <a href="/tools/pub/packages">pub package</a> needs some metadata so it can specify its <a href="/tools/pub/glossary#dependency">dependencies</a>. Pub packages that are shared with others also need to provide some other information so users can discover them. All of this metadata goes in the package's <em>pubspec:</em> a file named <code>pubspec.yaml</code> that's written in the <a href="https://yaml.org/">YAML</a> language.</p><div class="header-wrapper"><h2 id="supported-fields">Supported fields</h2><a class="heading-link" href="#supported-fields" aria-label="Link to 'Supported fields' section">#</a></div><p>A pubspec can have the following fields:</p><dl><dt><code>name</code></dt><dd>Required for every package. <a href="#name"><em>Learn more.</em></a></dd><dt><code>version</code></dt><dd>Required for packages that are hosted on the pub.dev site. <a href="#version"><em>Learn more.</em></a></dd><dt><code>description</code></dt><dd>Required for packages that are hosted on the pub.dev site. <a href="#description"><em>Learn more.</em></a></dd><dt><code>homepage</code></dt><dd>Optional. URL pointing to the package's homepage (or source code repository). <a href="#homepage"><em>Learn more.</em></a></dd><dt><code>repository</code></dt><dd>Optional. URL pointing to the package's source code repository. <a href="#repository"><em>Learn more.</em></a></dd><dt><code>issue_tracker</code></dt><dd>Optional. URL pointing to an issue tracker for the package. <a href="#issue-tracker"><em>Learn more.</em></a></dd><dt><code>documentation</code></dt><dd>Optional. URL pointing to documentation for the package. <a href="#documentation"><em>Learn more.</em></a></dd><dt><code>dependencies</code></dt><dd>Can be omitted if your package has no dependencies. <a href="#dependencies"><em>Learn more.</em></a></dd><dt><code>dev_dependencies</code></dt><dd>Can be omitted if your package has no dev dependencies. <a href="#dependencies"><em>Learn more.</em></a></dd><dt><code>dependency_overrides</code></dt><dd>Can be omitted if you do not need to override any dependencies. <a href="#dependencies"><em>Learn more.</em></a></dd><dt><code>environment</code></dt><dd>Required as of Dart 2. <a href="#sdk-constraints"><em>Learn more.</em></a></dd><dt><code>executables</code></dt><dd>Optional. Used to put a package's executables on your PATH. <a href="#executables"><em>Learn more.</em></a></dd><dt><code>platforms</code></dt><dd>Optional. Used to explicitly declare supported platforms on the pub.dev site. <a href="#platforms"><em>Learn more.</em></a></dd><dt><code>publish_to</code></dt><dd>Optional. Specify where to publish a package. <a href="#publish_to"><em>Learn more.</em></a></dd><dt><code>funding</code></dt><dd>Optional. List of URLs where users can sponsor development of the package. <a href="#funding"><em>Learn more.</em></a></dd><dt><code>false_secrets</code></dt><dd>Optional. Specify files to ignore when conducting a pre-publishing search for potential leaks of secrets. <a href="#false_secrets"><em>Learn more.</em></a></dd><dt><code>screenshots</code></dt><dd>Optional. Specify a list of screenshot files to display on the <a href="https://pub.dev">pub.dev site</a>. <a href="#screenshots"><em>Learn more.</em></a></dd><dt><code>topics</code></dt><dd>Optional. List of topics for the package. <a href="#topics"><em>Learn more.</em></a></dd><dt><code>ignored_advisories</code></dt><dd>Optional. List of ignored security advisories. <a href="#ignored_advisories"><em>Learn more.</em></a></dd></dl><p>Pub ignores all other fields.</p><aside class="alert alert-info"><div class="alert-header"><i class="material-symbols" aria-hidden="true">flutter</i> <span>Flutter note</span></div><div class="alert-content"><p>Pubspecs for <a href="https://flutter.dev">Flutter apps</a> can have <a href="https://docs.flutter.dev/development/tools/pubspec">additional fields</a> for configuring the environment and managing assets.</p></div></aside><p>If you add a custom field, give it a unique name that won't clash with future pubspec fields. For example, instead of adding <code>bugs</code>, you might add a field named <code>my_pkg_bugs</code>.</p><div class="header-wrapper"><h2 id="example">Example</h2><a class="heading-link" href="#example" aria-label="Link to 'Example' section">#</a></div><p>A simple but complete pubspec looks something like the following:</p><div class="code-block-wrapper language-yaml"><div class="code-block-body"><span class="code-block-language" title="Language yaml">yaml</span><pre class="shiki dash-light" tabindex="0"><code><span class="line"><span style="color:#0468D7">name</span><span style="color:#222222">: </span><span style="color:#11796D">newtify</span></span> <span class="line"><span style="color:#0468D7">description</span><span style="color:#222222">: </span><span style="color:#D43324">>-</span></span> <span class="line"><span style="color:#11796D"> Have you been turned into a newt? Would you like to be?</span></span> <span class="line"><span style="color:#11796D"> This package can help. It has all of the</span></span> <span class="line"><span style="color:#11796D"> newt-transmogrification functionality you have been looking</span></span> <span class="line"><span style="color:#11796D"> for.</span></span> <span class="line"><span style="color:#0468D7">version</span><span style="color:#222222">: </span><span style="color:#11796D">1.2.3</span></span> <span class="line"><span style="color:#0468D7">homepage</span><span style="color:#222222">: </span><span style="color:#11796D">https://example-pet-store.com/newtify</span></span> <span class="line"><span style="color:#0468D7">documentation</span><span style="color:#222222">: </span><span style="color:#11796D">https://example-pet-store.com/newtify/docs</span></span> <span class="line"></span> <span class="line"><span style="color:#0468D7">environment</span><span style="color:#222222">:</span></span> <span class="line"><span style="color:#0468D7"> sdk</span><span style="color:#222222">: </span><span style="color:#11796D">'^3.2.0'</span></span> <span class="line"><span style="color:#222222"> </span></span> <span class="line"><span style="color:#0468D7">dependencies</span><span style="color:#222222">:</span></span> <span class="line"><span style="color:#0468D7"> efts</span><span style="color:#222222">: </span><span style="color:#11796D">^2.0.4</span></span> <span class="line"><span style="color:#0468D7"> transmogrify</span><span style="color:#222222">: </span><span style="color:#11796D">^0.4.0</span></span> <span class="line"><span style="color:#222222"> </span></span> <span class="line"><span style="color:#0468D7">dev_dependencies</span><span style="color:#222222">:</span></span> <span class="line"><span style="color:#0468D7"> test</span><span style="color:#222222">: </span><span style="color:#11796D">'>=1.15.0 <2.0.0'</span></span></code></pre></div></div><div class="header-wrapper"><h2 id="details">Details</h2><a class="heading-link" href="#details" aria-label="Link to 'Details' section">#</a></div><p>This section has more information about each of the pubspec fields.</p><div class="header-wrapper"><h3 id="name">Name</h3><a class="heading-link" href="#name" aria-label="Link to 'Name' section">#</a></div><p>Every package needs a name. It's how other packages refer to yours, and how it appears to the world, should you publish it.</p><p>The name should be all lowercase, with underscores to separate words, <code>just_like_this</code>. Use only basic Latin letters and Arabic digits: <code>[a-z0-9_]</code>. Also, make sure the name is a valid Dart identifier—that it doesn't start with digits and isn't a <a href="/language/keywords">reserved word</a>.</p><p>Try to pick a name that is clear, terse, and not already in use. A quick search of packages on the <a href="https://pub.dev/packages">pub.dev site</a> to make sure that nothing else is using your name is recommended.</p><div class="header-wrapper"><h3 id="version">Version</h3><a class="heading-link" href="#version" aria-label="Link to 'Version' section">#</a></div><p>Every package has a version. A version number is required to host your package on the pub.dev site, but can be omitted for local-only packages. If you omit it, your package is implicitly versioned <code>0.0.0</code>.</p><p>Versioning is necessary for reusing code while letting it evolve quickly. A version number is three numbers separated by dots, like <code>0.2.43</code>. It can also optionally have a build ( <code>+1</code>, <code>+2</code>, <code>+hotfix.oopsie</code>) or prerelease (<code>-dev.4</code>, <code>-alpha.12</code>, <code>-beta.7</code>, <code>-rc.5</code>) suffix.</p><p>Each time you publish your package, you publish it at a specific version. Once that's been done, consider it hermetically sealed: you can't touch it anymore. To make more changes, you'll need a new version.</p><p>When you select a version, follow <a href="https://semver.org/spec/v2.0.0-rc.1.html">semantic versioning.</a></p><div class="header-wrapper"><h3 id="description">Description</h3><a class="heading-link" href="#description" aria-label="Link to 'Description' section">#</a></div><p>This is optional for your own personal packages, but if you intend to publish your package you must provide a description, which should be in English. The description should be relatively short—60 to 180 characters—and tell a casual reader what they might want to know about your package.</p><p>Think of the description as the sales pitch for your package. Users see it when they <a href="https://pub.dev/packages">browse for packages.</a> The description is plain text: no markdown or HTML.</p><div class="header-wrapper"><h3 id="homepage">Homepage</h3><a class="heading-link" href="#homepage" aria-label="Link to 'Homepage' section">#</a></div><p>This should be a URL pointing to the website for your package. For <a href="/tools/pub/dependencies#hosted-packages">hosted packages</a>, this URL is linked from the package's page. While providing a <code>homepage</code> is optional, <em>please provide</em> it or <code>repository</code> (or both). It helps users understand where your package is coming from.</p><div class="header-wrapper"><h3 id="repository">Repository</h3><a class="heading-link" href="#repository" aria-label="Link to 'Repository' section">#</a></div><p>The optional <code>repository</code> field should contain the URL for your package's source code repository—for example, <code>https://github.com/<user>/<repository></code>. If you publish your package to the pub.dev site, then your package's page displays the repository URL. While providing a <code>repository</code> is optional, <em>please provide</em> it or <code>homepage</code> (or both). It helps users understand where your package is coming from.</p><div class="header-wrapper"><h3 id="issue-tracker">Issue tracker</h3><a class="heading-link" href="#issue-tracker" aria-label="Link to 'Issue tracker' section">#</a></div><p>The optional <code>issue_tracker</code> field should contain a URL for the package's issue tracker, where existing bugs can be viewed and new bugs can be filed. The pub.dev site attempts to display a link to each package's issue tracker, using the value of this field. If <code>issue_tracker</code> is missing but <code>repository</code> is present and points to GitHub, then the pub.dev site uses the default issue tracker (<code>https://github.com/<user>/<repository>/issues</code>).</p><div class="header-wrapper"><h3 id="documentation">Documentation</h3><a class="heading-link" href="#documentation" aria-label="Link to 'Documentation' section">#</a></div><p>Some packages have a site that hosts documentation, separate from the main homepage and from the Pub-generated API reference. If your package has additional documentation, add a <code>documentation:</code> field with that URL; pub shows a link to this documentation on your package's page.</p><div class="header-wrapper"><h3 id="dependencies">Dependencies</h3><a class="heading-link" href="#dependencies" aria-label="Link to 'Dependencies' section">#</a></div><p><a href="/tools/pub/glossary#dependency">Dependencies</a> are the pubspec's <em>raison d'être</em>. In this section you list each package that your package needs in order to work.</p><p>Dependencies fall into one of two types. <em>Regular dependencies</em> are listed under <code>dependencies:</code>—these are packages that anyone using your package will also need. Dependencies that are only needed in the development phase of the package itself are listed under <code>dev_dependencies</code>.</p><p>During the development process, you might need to temporarily override a dependency. You can do so using <code>dependency_overrides</code>.</p><p>For more information, see <a href="/tools/pub/dependencies">Package dependencies</a>.</p><div class="header-wrapper"><h3 id="executables">Executables</h3><a class="heading-link" href="#executables" aria-label="Link to 'Executables' section">#</a></div><p>A package may expose one or more of its scripts as executables that can be run directly from the command line. To make a script publicly available, list it under the <code>executables</code> field. Entries are listed as key/value pairs:</p><div class="code-block-wrapper language-plaintext"><div class="code-block-body"><pre class="shiki dash-light" tabindex="0"><code><span class="line"><span><name-of-executable>: <Dart-script-from-bin></span></span></code></pre></div></div><p>For example, the following pubspec entry lists two scripts:</p><div class="code-block-wrapper language-yaml"><div class="code-block-body"><span class="code-block-language" title="Language yaml">yaml</span><pre class="shiki dash-light" tabindex="0"><code><span class="line"><span style="color:#0468D7">executables</span><span style="color:#222222">:</span></span> <span class="line"><span style="color:#0468D7"> slidy</span><span style="color:#222222">: </span><span style="color:#11796D">main</span></span> <span class="line"><span style="color:#0468D7"> fvm</span><span style="color:#222222">:</span></span></code></pre></div></div><p>Once the package is activated using <code>dart pub global activate</code>, typing <code>slidy</code> executes <code>bin/main.dart</code>. Typing <code>fvm</code> executes <code>bin/fvm.dart</code>. If you don't specify the value, it is inferred from the key.</p><p>For more information, see <a href="/tools/pub/cmd/pub-global#running-a-script-from-your-path">pub global</a>.</p><div class="header-wrapper"><h3 id="platforms">Platforms</h3><a class="heading-link" href="#platforms" aria-label="Link to 'Platforms' section">#</a></div><p>When you <a href="/tools/pub/publishing">publish a package</a>, pub.dev automatically detects the platforms that the package supports. If this platform-support list is incorrect, use <code>platforms</code> to explicitly declare which platforms your package supports.</p><p>For example, the following <code>platforms</code> entry causes pub.dev to list the package as supporting Android, iOS, Linux, macOS, Web, and Windows:</p><div class="code-block-wrapper language-yaml"><div class="code-block-body"><span class="code-block-language" title="Language yaml">yaml</span><pre class="shiki dash-light" tabindex="0"><code><span class="line"><span style="color:#6E6E70"># This package supports all platforms listed below.</span></span> <span class="line"><span style="color:#0468D7">platforms</span><span style="color:#222222">:</span></span> <span class="line"><span style="color:#0468D7"> android</span><span style="color:#222222">:</span></span> <span class="line"><span style="color:#0468D7"> ios</span><span style="color:#222222">:</span></span> <span class="line"><span style="color:#0468D7"> linux</span><span style="color:#222222">:</span></span> <span class="line"><span style="color:#0468D7"> macos</span><span style="color:#222222">:</span></span> <span class="line"><span style="color:#0468D7"> web</span><span style="color:#222222">:</span></span> <span class="line"><span style="color:#0468D7"> windows</span><span style="color:#222222">:</span></span></code></pre></div></div><p>Here is an example of declaring that the package supports only Linux and macOS (and not, for example, Windows):</p><div class="code-block-wrapper language-yaml"><div class="code-block-body"><span class="code-block-language" title="Language yaml">yaml</span><pre class="shiki dash-light" tabindex="0"><code><span class="line"><span style="color:#6E6E70"># This package supports only Linux and macOS.</span></span> <span class="line"><span style="color:#0468D7">platforms</span><span style="color:#222222">:</span></span> <span class="line"><span style="color:#0468D7"> linux</span><span style="color:#222222">:</span></span> <span class="line"><span style="color:#0468D7"> macos</span><span style="color:#222222">:</span></span></code></pre></div></div><aside class="alert alert-info"><div class="alert-header"><i class="material-symbols" aria-hidden="true">info</i> <span>If you use Flutter</span></div><div class="alert-content"><p>Flutter plugins platform support is by default derived from the <a href="https://docs.flutter.dev/development/packages-and-plugins/developing-packages#plugin-platforms">plugin declarations</a>.</p><p>If there is a discrepancy between the plugin declaration and the actual platform support, a top-level <code>platforms</code> declaration can still be used and takes precedence over the Flutter plugin declaration when deciding platform support.</p></div></aside><aside class="alert alert-info"><div class="alert-header"><i class="material-symbols" aria-hidden="true">merge_type</i> <span>Version note</span></div><div class="alert-content"><p>Support for the <code>platforms</code> entry was added in Dart 2.16.</p></div></aside><div class="header-wrapper"><h3 id="publish_to">Publish_to</h3><a class="heading-link" href="#publish_to" aria-label="Link to 'Publish_to' section">#</a></div><p>The default uses the <a href="https://pub.dev">pub.dev site.</a> Specify <code>none</code> to prevent a package from being published. This setting can be used to specify a <a href="/tools/pub/custom-package-repositories">custom pub package server</a> to publish.</p><div class="code-block-wrapper language-yaml"><div class="code-block-body"><span class="code-block-language" title="Language yaml">yaml</span><pre class="shiki dash-light" tabindex="0"><code><span class="line"><span style="color:#0468D7">publish_to</span><span style="color:#222222">: </span><span style="color:#11796D">none</span></span></code></pre></div></div><div class="header-wrapper"><h3 id="funding">Funding</h3><a class="heading-link" href="#funding" aria-label="Link to 'Funding' section">#</a></div><p>Package authors can use the <code>funding</code> property to specify a list of URLs that provide information on how users can help fund the development of the package. For example:</p><div class="code-block-wrapper language-yaml"><div class="code-block-body"><span class="code-block-language" title="Language yaml">yaml</span><pre class="shiki dash-light" tabindex="0"><code><span class="line"><span style="color:#0468D7">funding</span><span style="color:#222222">:</span></span> <span class="line"><span style="color:#222222"> - </span><span style="color:#11796D">https://www.buymeacoffee.com/example_user</span></span> <span class="line"><span style="color:#222222"> - </span><span style="color:#11796D">https://www.patreon.com/some-account</span></span></code></pre></div></div><p>If published to <a href="https://pub.dev">pub.dev</a> the links are displayed on the package page. This aims to help users fund the development of their dependencies.</p><div class="header-wrapper"><h3 id="false_secrets">False_secrets</h3><a class="heading-link" href="#false_secrets" aria-label="Link to 'False_secrets' section">#</a></div><p>When you try to <a href="/tools/pub/publishing">publish a package</a>, pub conducts a search for potential leaks of secret credentials, API keys, or cryptographic keys. If pub detects a potential leak in a file that would be published, then pub warns you and refuses to publish the package.</p><p>Leak detection isn't perfect. To avoid false positives, you can tell pub not to search for leaks in certain files, by creating an allowlist using <a href="https://git-scm.com/docs/gitignore#_pattern_format"><code>gitignore</code> patterns</a> under <code>false_secrets</code> in the pubspec.</p><p>For example, the following entry causes pub not to look for leaks in the file <code>lib/src/hardcoded_api_key.dart</code> and in all <code>.pem</code> files in the <code>test/localhost_certificates/</code> directory:</p><div class="code-block-wrapper language-yaml"><div class="code-block-body"><span class="code-block-language" title="Language yaml">yaml</span><pre class="shiki dash-light" tabindex="0"><code><span class="line"><span style="color:#0468D7">false_secrets</span><span style="color:#222222">:</span></span> <span class="line"><span style="color:#222222"> - </span><span style="color:#11796D">/lib/src/hardcoded_api_key.dart</span></span> <span class="line"><span style="color:#222222"> - </span><span style="color:#11796D">/test/localhost_certificates/*.pem</span></span></code></pre></div></div><p>Starting a <code>gitignore</code> pattern with slash (<code>/</code>) ensures that the pattern is considered relative to the package's root directory.</p><aside class="alert alert-warning"><div class="alert-header"><i class="material-symbols" aria-hidden="true">warning</i> <span>Warning</span></div><div class="alert-content"><p><strong>Don't rely on leak detection.</strong> It uses a limited set of patterns to detect common mistakes. You're responsible for managing your credentials, preventing accidental leaks, and revoking credentials that are accidentally leaked.</p></div></aside><aside class="alert alert-info"><div class="alert-header"><i class="material-symbols" aria-hidden="true">merge_type</i> <span>Version note</span></div><div class="alert-content"><p>Dart 2.15 added support for the <code>false_secrets</code> field.</p></div></aside><div class="header-wrapper"><h3 id="screenshots">Screenshots</h3><a class="heading-link" href="#screenshots" aria-label="Link to 'Screenshots' section">#</a></div><p>Packages can showcase their widgets or other visual elements using screenshots displayed on their pub.dev page. To specify screenshots for the package to display, use the <code>screenshots</code> field.</p><p>A package can list up to 10 screenshots under the <code>screenshots</code> field. Don't include logos or other branding imagery in this section. Each screenshot includes one <code>description</code> and one <code>path</code>. The <code>description</code> explains what the screenshot depicts in no more than 160 characters. For example:</p><div class="code-block-wrapper language-yaml"><div class="code-block-body"><span class="code-block-language" title="Language yaml">yaml</span><pre class="shiki dash-light" tabindex="0"><code><span class="line"><span style="color:#0468D7">screenshots</span><span style="color:#222222">:</span></span> <span class="line"><span style="color:#222222"> - </span><span style="color:#0468D7">description</span><span style="color:#222222">: </span><span style="color:#11796D">'This screenshot shows the transformation of a number of bytes </span></span> <span class="line"><span style="color:#11796D"> to a human-readable expression.'</span></span> <span class="line"><span style="color:#0468D7"> path</span><span style="color:#222222">: </span><span style="color:#11796D">path/to/image/in/package/500x500.webp</span></span> <span class="line"><span style="color:#222222"> - </span><span style="color:#0468D7">description</span><span style="color:#222222">: </span><span style="color:#11796D">'This screenshot shows a stack trace returning a human-readable</span></span> <span class="line"><span style="color:#11796D"> representation.'</span></span> <span class="line"><span style="color:#0468D7"> path</span><span style="color:#222222">: </span><span style="color:#11796D">path/to/image/in/package.png</span></span></code></pre></div></div><p>Pub.dev limits screenshots to the following specifications:</p><ul><li>File size: max 4 MB per image.</li><li>File types: <code>png</code>, <code>jpg</code>, <code>gif</code>, or <code>webp</code>.</li><li>Static and animated images are both allowed.</li></ul><p>Keep screenshot files small. Each download of the package includes all screenshot files.</p><p>Pub.dev generates the package's thumbnail image from the first screenshot. If this screenshot uses animation, pub.dev uses its first frame.</p><div class="header-wrapper"><h3 id="topics">Topics</h3><a class="heading-link" href="#topics" aria-label="Link to 'Topics' section">#</a></div><p>Package authors can use the <code>topics</code> field to categorize their package. Topics can be used to assist discoverability during search with filters on pub.dev. Pub.dev displays the topics on the package page as well as in the search results.</p><p>The field consists of a list of names. For example:</p><div class="code-block-wrapper language-yaml"><div class="code-block-body"><span class="code-block-language" title="Language yaml">yaml</span><pre class="shiki dash-light" tabindex="0"><code><span class="line"><span style="color:#0468D7">topics</span><span style="color:#222222">:</span></span> <span class="line"><span style="color:#222222"> - </span><span style="color:#11796D">network</span></span> <span class="line"><span style="color:#222222"> - </span><span style="color:#11796D">http</span></span></code></pre></div></div><p>Pub.dev requires topics to follow these specifications:</p><ul><li>Tag each package with at most 5 topics.</li><li>Write the topic name following these requirements:<ul><li>Use between 2 and 32 characters.</li><li>Use only lowercase alphanumeric characters or hyphens (<code>a-z</code>, <code>0-9</code>, <code>-</code>).</li><li>Don't use two consecutive hyphens (<code>--</code>).</li><li>Start the name with lowercase alphabet characters (<code>a-z</code>).</li><li>End with alphanumeric characters (<code>a-z</code> or <code>0-9</code>).</li></ul></li></ul><p>When choosing topics, consider if <a href="https://pub.dev/topics">existing topics</a> are relevant. Tagging with existing topics helps users discover your package.</p><aside class="alert alert-info"><div class="alert-header"><i class="material-symbols" aria-hidden="true">info</i> <span>Note</span></div><div class="alert-content"><p>Pub.dev merges different spellings of a topic into a canonical topic to avoid duplication and improve discovery by topic.</p><p>You can contribute to the list of canonical topics and their aliases by opening a pull request that edits the <a href="https://github.com/dart-lang/pub-dev/blob/master/doc/topics.yaml"><code>topics.yaml</code> file</a> on GitHub.</p></div></aside><div class="header-wrapper"><h3 id="ignored_advisories">Ignored_advisories</h3><a class="heading-link" href="#ignored_advisories" aria-label="Link to 'Ignored_advisories' section">#</a></div><p>If a package has a dependency that is affected by a security advisory, pub warns about the advisory during dependency resolution. Package authors can use the <code>ignored_advisories</code> field as an allowlist of triggered advisories that are not relevant for the package.</p><p>To suppress the warning about an advisory, add the advisory identifier to the <code>ignored_advisories</code> list. For example:</p><div class="code-block-wrapper language-yaml"><div class="code-block-body"><span class="code-block-language" title="Language yaml">yaml</span><pre class="shiki dash-light" tabindex="0"><code><span class="line"><span style="color:#0468D7">name</span><span style="color:#222222">: </span><span style="color:#11796D">myapp</span></span> <span class="line"><span style="color:#0468D7">dependencies</span><span style="color:#222222">:</span></span> <span class="line"><span style="color:#0468D7"> foo</span><span style="color:#222222">: </span><span style="color:#11796D">^1.0.0</span></span> <span class="line"><span style="color:#0468D7">ignored_advisories</span><span style="color:#222222">:</span></span> <span class="line"><span style="color:#222222"> - </span><span style="color:#11796D">GHSA-4rgh-jx4f-qfcq</span></span></code></pre></div></div><p>For more information, check out <a href="/tools/pub/security-advisories">Security advisories</a>.</p><div class="header-wrapper"><h3 id="sdk-constraints">SDK constraints</h3><a class="heading-link" href="#sdk-constraints" aria-label="Link to 'SDK constraints' section">#</a></div><p>A package can indicate which versions of its dependencies it supports, but packages have another implicit dependency: the Dart platform itself. The Dart platform evolves over time, and a package might only work with certain versions of the platform.</p><p>A package can specify those versions using an <em>SDK constraint</em>. This constraint goes inside a separate top-level <code>environment</code> field in the pubspec and uses the same <a href="/tools/pub/dependencies#version-constraints">version constraint</a> syntax as dependencies.</p><aside class="alert alert-info"><div class="alert-header"><i class="material-symbols" aria-hidden="true">merge_type</i> <span>Version note</span></div><div class="alert-content"><p>For a package to use a feature introduced after 2.0, its pubspec must have a lower constraint that's at least the version when the feature was introduced. For details, check out <a href="/guides/language/evolution#language-versioning">Language versioning</a>.</p></div></aside><p>For example, the following constraint says that this package works with any Dart SDK that's version 3.0.0 or higher:</p><div class="code-block-wrapper language-yaml"><div class="code-block-body"><span class="code-block-language" title="Language yaml">yaml</span><pre class="shiki dash-light" tabindex="0"><code><span class="line"><span style="color:#0468D7">environment</span><span style="color:#222222">:</span></span> <span class="line"><span style="color:#0468D7"> sdk</span><span style="color:#222222">: </span><span style="color:#11796D">^3.0.0</span></span></code></pre></div></div><p>Pub tries to find the latest version of a package whose SDK constraint works with the version of the Dart SDK that you have installed.</p><p>Omitting the SDK constraint is an error. When the pubspec has no SDK constraint, <code>dart pub get</code> fails with a message like the following:</p><div class="code-block-wrapper language-plaintext"><div class="code-block-body"><pre class="shiki dash-light" tabindex="0"><code><span class="line"><span>pubspec.yaml has no lower-bound SDK constraint.</span></span> <span class="line"><span>You should edit pubspec.yaml to contain an SDK constraint:</span></span> <span class="line"><span></span></span> <span class="line"><span>environment:</span></span> <span class="line"><span> sdk: '^3.2.0'</span></span> <span class="line"><span> </span></span> <span class="line"><span>See https://dart.dev/go/sdk-constraint</span></span></code></pre></div></div><aside class="alert alert-info"><div class="alert-header"><i class="material-symbols" aria-hidden="true">merge_type</i> <span>Version note</span></div><div class="alert-content"><p>Before Dart 2.19, pub disallowed caret syntax in SDK constraints. In earlier versions, provide a complete range, such as <code>'>=2.12.0 <3.0.0'</code>. For more information, check out the <a href="/tools/pub/dependencies#caret-syntax">Caret syntax</a> documentation.</p></div></aside><div class="header-wrapper"><h4 id="flutter-sdk-constraints">Flutter SDK constraints</h4><a class="heading-link" href="#flutter-sdk-constraints" aria-label="Link to 'Flutter SDK constraints' section">#</a></div><p>Pub supports specifying Flutter SDK constraints under the <code>environment:</code> field:</p><div class="code-block-wrapper language-yaml"><div class="code-block-body"><span class="code-block-language" title="Language yaml">yaml</span><pre class="shiki dash-light" tabindex="0"><code><span class="line"><span style="color:#0468D7">environment</span><span style="color:#222222">:</span></span> <span class="line"><span style="color:#0468D7"> sdk</span><span style="color:#222222">: </span><span style="color:#11796D">^3.2.0</span></span> <span class="line"><span style="color:#0468D7"> flutter</span><span style="color:#222222">: </span><span style="color:#11796D">'>= 3.22.0'</span></span></code></pre></div></div><p>A Flutter SDK constraint is satisfied only if pub is running in the context of the <code>flutter</code> executable, and the Flutter SDK's <code>version</code> file meets the version constraint's lower bound. Otherwise, the package won't be selected.</p><aside class="alert alert-info"><div class="alert-header"><i class="material-symbols" aria-hidden="true">info</i> <span>Note</span></div><div class="alert-content"><p>The Flutter SDK only enforces the lower bound of the flutter constraint. To learn more, check out <a href="https://github.com/flutter/flutter/issues/95472">issue #95472</a> in the <code>flutter/flutter</code> repository.</p></div></aside><p>To publish a package with a Flutter SDK constraint, you must specify a Dart SDK constraint with a minimum version of at least 1.19.0, to ensure that older versions of pub won't accidentally install packages that need Flutter.</p><p id="page-github-links"><span>Unless stated otherwise, the documentation on this site reflects Dart 3.5.4. Page last updated on 2024-11-18.</span> <a href="https://github.com/dart-lang/site-www/tree/main/src/content/tools/pub/pubspec.md" target="_blank" rel="noopener">View source</a> <span>or </span><a href="https://github.com/dart-lang/site-www/issues/new?template=1_page_issue.yml&page-url=https://dart.dev/tools/pub/pubspec/&page-source=https://github.com/dart-lang/site-www/tree/main/src/content/tools/pub/pubspec.md" title="Report an issue with this page" target="_blank" rel="noopener">report an issue</a>.</p></div></article></main><footer id="page-footer"><div class="footer-section footer-main"><a href="/" class="brand" title="Dart"><img src="/assets/img/logo/logo-white-text.svg" alt="Dart" width="164"></a><div class="footer-social-links"><a href="https://medium.com/dartlang" target="_blank" rel="noopener" title="Medium blog"><svg><use href="/assets/img/social/medium.svg#medium"></use></svg> </a><a href="https://github.com/dart-lang" target="_blank" rel="noopener" title="GitHub"><svg><use href="/assets/img/social/github.svg#github"></use></svg> </a><a href="https://twitter.com/dart_lang" target="_blank" rel="noopener" title="X (Twitter)"><svg><use href="/assets/img/social/x.svg#x"></use></svg></a></div></div><div class="footer-section footer-tray"><div class="footer-licenses">Except as otherwise noted, this site is licensed under a <a href="https://creativecommons.org/licenses/by/4.0/">Creative Commons Attribution 4.0 International License</a>, and code samples are licensed under the <a href="https://opensource.org/licenses/BSD-3-Clause">3-Clause BSD License</a>.</div><div class="footer-utility-links"><ul><li><a href="/terms" title="Terms of use">Terms</a></li><li><a href="https://policies.google.com/privacy" target="_blank" rel="noopener" title="Privacy policy">Privacy</a></li><li><a href="/security" title="Security philosophy and practices">Security</a></li></ul></div></div></footer></body></html>