CINXE.COM

Glossary | 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="A glossary reference for terminology used across dart.dev."><title>Glossary | 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="Glossary"><meta name="twitter:description" content="A glossary reference for terminology used across dart.dev."><meta property="og:title" content="Glossary"><meta property="og:description" content="A glossary reference for terminology used across dart.dev."><meta property="og:url" content="/resources/glossary/"><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 glossary-page"><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 collapsed collapsible" data-toggle="collapse" href="#sidenav-4" role="button" aria-expanded="false" aria-controls="sidenav-4">Packages</a><ul class="nav flex-column flex-nowrap collapse" 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 collapsible collapsed" data-toggle="collapse" data-target="#sidenav-4-6" href="#sidenav-4-6" role="button" aria-expanded="false" aria-controls="sidenav-4-6">Package reference</a><ul class="nav flex-column flex-nowrap collapse" 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" 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 active collapsible" data-toggle="collapse" href="#sidenav-9" role="button" aria-expanded="true" aria-controls="sidenav-9">Resources</a><ul class="nav flex-column flex-nowrap collapse show" 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 active" 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="#assist">Assist</a></li><li class="toc-entry nav-item"><a class="nav-link" href="#constant-context">Constant context</a></li><li class="toc-entry nav-item"><a class="nav-link" href="#definite-assignment">Definite assignment</a></li><li class="toc-entry nav-item"><a class="nav-link" href="#function">Function</a></li><li class="toc-entry nav-item"><a class="nav-link" href="#irrefutable-pattern">Irrefutable pattern</a></li><li class="toc-entry nav-item"><a class="nav-link" href="#mixin-application">Mixin application</a></li><li class="toc-entry nav-item"><a class="nav-link" href="#override-inference">Override inference</a></li><li class="toc-entry nav-item"><a class="nav-link" href="#part-file">Part file</a></li><li class="toc-entry nav-item"><a class="nav-link" href="#potentially-non-nullable">Potentially non-nullable</a></li><li class="toc-entry nav-item"><a class="nav-link" href="#public-library">Public library</a></li><li class="toc-entry nav-item"><a class="nav-link" href="#quick-fix">Quick fix</a></li><li class="toc-entry nav-item"><a class="nav-link" href="#refactor">Refactor</a></li><li class="toc-entry nav-item"><a class="nav-link" href="#refutable-pattern">Refutable pattern</a></li><li class="toc-entry nav-item"><a class="nav-link" href="#subclass">Subclass</a></li><li class="toc-entry nav-item"><a class="nav-link" href="#subtype">Subtype</a></li><li class="toc-entry nav-item"><a class="nav-link" href="#variance">Variance and variance positions</a></li></ul></div><article><div class="content"><div id="site-content-title"><h1>Glossary</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="#assist">Assist</a></li><li class="toc-entry"><a href="#constant-context">Constant context</a></li><li class="toc-entry"><a href="#definite-assignment">Definite assignment</a></li><li class="toc-entry"><a href="#function">Function</a></li><li class="toc-entry"><a href="#irrefutable-pattern">Irrefutable pattern</a></li><li class="toc-entry"><a href="#mixin-application">Mixin application</a></li><li class="toc-entry"><a href="#override-inference">Override inference</a></li><li class="toc-entry"><a href="#part-file">Part file</a></li><li class="toc-entry"><a href="#potentially-non-nullable">Potentially non-nullable</a></li><li class="toc-entry"><a href="#public-library">Public library</a></li><li class="toc-entry"><a href="#quick-fix">Quick fix</a></li><li class="toc-entry"><a href="#refactor">Refactor</a></li><li class="toc-entry"><a href="#refutable-pattern">Refutable pattern</a></li><li class="toc-entry"><a href="#subclass">Subclass</a></li><li class="toc-entry"><a href="#subtype">Subtype</a></li><li class="toc-entry"><a href="#variance">Variance and variance positions</a></li></ul><span class="site-toc--inline__toggle toc-toggle-more-items"><i class="material-symbols">more_horiz</i></span></div><p>The following are definitions of terms used across the Dart documentation.</p><div class="term-separator" aria-hidden="true"></div><div class="header-wrapper"><h2 id="assist">Assist</h2><a class="heading-link" href="#assist" aria-label="Link to 'Assist' section">#</a></div><p>An assist is an automated, local code edit targeted at making common improvements to code. Examples of assists include converting <code>switch</code> statements to <code>switch</code> expressions, reversing the <code>then</code> and <code>else</code> blocks in an <code>if</code> statement, and inserting widgets into a widget structure.</p><p><strong>Related docs and resources:</strong></p><ul><li><a href="#refactor">Refactor</a></li></ul><div class="term-separator" aria-hidden="true"></div><div class="header-wrapper"><h2 id="constant-context">Constant context</h2><a class="heading-link" href="#constant-context" aria-label="Link to 'Constant context' section">#</a></div><p>A <em>constant context</em> is a region of code in which it isn't necessary to include the <code>const</code> keyword because it's implied by the fact that everything in that region is required to be a constant. The following locations are constant contexts:</p><ul><li><p>Everything inside a list, map or set literal that's prefixed by the <code>const</code> keyword. For example:</p><div class="code-block-wrapper language-dart"><div class="code-block-body"><span class="code-block-language" title="Language dart">dart</span><pre class="shiki dash-light" tabindex="0"><code><span class="line"><span style="color:#D43324">var</span><span style="color:#222222"> l = </span><span style="color:#D43324">const</span><span style="color:#222222"> [</span><span style="color:#6E6E70">/*constant context*/</span><span style="color:#222222">];</span></span></code></pre></div></div></li><li><p>The arguments inside an invocation of a constant constructor. For example:</p><div class="code-block-wrapper language-dart"><div class="code-block-body"><span class="code-block-language" title="Language dart">dart</span><pre class="shiki dash-light" tabindex="0"><code><span class="line"><span style="color:#D43324">var</span><span style="color:#222222"> p = </span><span style="color:#D43324">const</span><span style="color:#0468D7"> Point</span><span style="color:#222222">(</span><span style="color:#6E6E70">/*constant context*/</span><span style="color:#222222">);</span></span></code></pre></div></div></li><li><p>The initializer for a variable that's prefixed by the <code>const</code> keyword. For example:</p><div class="code-block-wrapper language-dart"><div class="code-block-body"><span class="code-block-language" title="Language dart">dart</span><pre class="shiki dash-light" tabindex="0"><code><span class="line"><span style="color:#D43324">const</span><span style="color:#222222"> v = </span><span style="color:#6E6E70">/*constant context*/</span><span style="color:#222222">;</span></span></code></pre></div></div></li><li><p>Annotations.</p></li><li><p>The expression in a <code>case</code> clause. For example:</p><div class="code-block-wrapper language-dart"><div class="code-block-body"><span class="code-block-language" title="Language dart">dart</span><pre class="shiki dash-light" tabindex="0"><code><span class="line"><span style="color:#D43324">void</span><span style="color:#6200EE"> f</span><span style="color:#222222">(</span><span style="color:#0468D7">int</span><span style="color:#222222"> e) {</span></span> <span class="line"><span style="color:#D43324"> switch</span><span style="color:#222222"> (e) {</span></span> <span class="line"><span style="color:#D43324"> case</span><span style="color:#6E6E70"> /*constant context*/</span><span style="color:#222222">:</span></span> <span class="line"><span style="color:#D43324"> break</span><span style="color:#222222">;</span></span> <span class="line"><span style="color:#222222"> }</span></span> <span class="line"><span style="color:#222222">}</span></span></code></pre></div></div></li></ul><p><strong>Related docs and resources:</strong></p><ul><li><a href="/language/variables#final-and-const">Final and const variables</a></li><li><a href="/effective-dart/usage#dont-use-const-redundantly">Don't use const redundantly</a></li></ul><div class="term-separator" aria-hidden="true"></div><div class="header-wrapper"><h2 id="definite-assignment">Definite assignment</h2><a class="heading-link" href="#definite-assignment" aria-label="Link to 'Definite assignment' section">#</a></div><p>Definite assignment analysis is the process of determining, for each local variable at each point in the code, which of the following is true:</p><ul><li>The variable has definitely been assigned a value (<em>definitely assigned</em>).</li><li>The variable has definitely not been assigned a value (<em>definitely unassigned</em>).</li><li>The variable might or might not have been assigned a value, depending on the execution path taken to arrive at that point.</li></ul><p>Definite assignment analysis helps find problems in code, such as places where a variable that might not have been assigned a value is being referenced, or places where a variable that can only be assigned a value one time is being assigned after it might already have been assigned a value.</p><p>For example, in the following code the variable <code>s</code> is definitely unassigned when it's passed as an argument to <code>print</code>:</p><div class="code-block-wrapper language-dart"><div class="code-block-body"><span class="code-block-language" title="Language dart">dart</span><pre class="shiki dash-light" tabindex="0"><code><span class="line"><span style="color:#D43324">void</span><span style="color:#6200EE"> f</span><span style="color:#222222">() {</span></span> <span class="line"><span style="color:#0468D7"> String</span><span style="color:#222222"> s;</span></span> <span class="line"><span style="color:#6200EE"> print</span><span style="color:#222222">(s);</span></span> <span class="line"><span style="color:#222222">}</span></span></code></pre></div></div><p>But in the following code, the variable <code>s</code> is definitely assigned:</p><div class="code-block-wrapper language-dart"><div class="code-block-body"><span class="code-block-language" title="Language dart">dart</span><pre class="shiki dash-light" tabindex="0"><code><span class="line"><span style="color:#D43324">void</span><span style="color:#6200EE"> f</span><span style="color:#222222">(</span><span style="color:#0468D7">String</span><span style="color:#222222"> name) {</span></span> <span class="line"><span style="color:#0468D7"> String</span><span style="color:#222222"> s = </span><span style="color:#11796D">'Hello </span><span style="color:#11796D">$</span><span style="color:#222222">name</span><span style="color:#11796D">!'</span><span style="color:#222222">;</span></span> <span class="line"><span style="color:#6200EE"> print</span><span style="color:#222222">(s);</span></span> <span class="line"><span style="color:#222222">}</span></span></code></pre></div></div><p>Definite assignment analysis can even tell whether a variable is definitely assigned (or unassigned) when there are multiple possible execution paths. In the following code the <code>print</code> function is called if execution goes through either the true or the false branch of the <code>if</code> statement, but because <code>s</code> is assigned no matter which branch is taken, it's definitely assigned before it's passed to <code>print</code>:</p><div class="code-block-wrapper language-dart"><div class="code-block-body"><span class="code-block-language" title="Language dart">dart</span><pre class="shiki dash-light" tabindex="0"><code><span class="line"><span style="color:#D43324">void</span><span style="color:#6200EE"> f</span><span style="color:#222222">(</span><span style="color:#0468D7">String</span><span style="color:#222222"> name, </span><span style="color:#0468D7">bool</span><span style="color:#222222"> casual) {</span></span> <span class="line"><span style="color:#0468D7"> String</span><span style="color:#222222"> s;</span></span> <span class="line"><span style="color:#D43324"> if</span><span style="color:#222222"> (casual) {</span></span> <span class="line"><span style="color:#222222"> s = </span><span style="color:#11796D">'Hi </span><span style="color:#11796D">$</span><span style="color:#222222">name</span><span style="color:#11796D">!'</span><span style="color:#222222">;</span></span> <span class="line"><span style="color:#222222"> } </span><span style="color:#D43324">else</span><span style="color:#222222"> {</span></span> <span class="line"><span style="color:#222222"> s = </span><span style="color:#11796D">'Hello </span><span style="color:#11796D">$</span><span style="color:#222222">name</span><span style="color:#11796D">!'</span><span style="color:#222222">;</span></span> <span class="line"><span style="color:#222222"> }</span></span> <span class="line"><span style="color:#6200EE"> print</span><span style="color:#222222">(s);</span></span> <span class="line"><span style="color:#222222">}</span></span></code></pre></div></div><p>In flow analysis, the end of the <code>if</code> statement is referred to as a <em>join</em>鈥攁 place where two or more execution paths merge back together. Where there's a join, the analysis says that a variable is definitely assigned if it's definitely assigned along all of the paths that are merging, and definitely unassigned if it's definitely unassigned along all of the paths.</p><p>Sometimes a variable is assigned a value on one path but not on another, in which case the variable might or might not have been assigned a value. In the following example, the true branch of the <code>if</code> statement might or might not be executed, so the variable might or might be assigned a value:</p><div class="code-block-wrapper language-dart"><div class="code-block-body"><span class="code-block-language" title="Language dart">dart</span><pre class="shiki dash-light" tabindex="0"><code><span class="line"><span style="color:#D43324">void</span><span style="color:#6200EE"> f</span><span style="color:#222222">(</span><span style="color:#0468D7">String</span><span style="color:#222222"> name, </span><span style="color:#0468D7">bool</span><span style="color:#222222"> casual) {</span></span> <span class="line"><span style="color:#0468D7"> String</span><span style="color:#222222"> s;</span></span> <span class="line"><span style="color:#D43324"> if</span><span style="color:#222222"> (casual) {</span></span> <span class="line"><span style="color:#222222"> s = </span><span style="color:#11796D">'Hi </span><span style="color:#11796D">$</span><span style="color:#222222">name</span><span style="color:#11796D">!'</span><span style="color:#222222">;</span></span> <span class="line"><span style="color:#222222"> }</span></span> <span class="line"><span style="color:#6200EE"> print</span><span style="color:#222222">(s);</span></span> <span class="line"><span style="color:#222222">}</span></span></code></pre></div></div><p>The same is true if there is a false branch that doesn't assign a value to <code>s</code>.</p><p>The analysis of loops is a little more complicated, but it follows the same basic reasoning. For example, the condition in a <code>while</code> loop is always executed, but the body might or might not be. So just like an <code>if</code> statement, there's a join at the end of the <code>while</code> statement between the path in which the condition is <code>true</code> and the path in which the condition is <code>false</code>.</p><p><strong>Related docs and resources:</strong></p><ul><li><a href="https://github.com/dart-lang/language/blob/main/resources/type-system/flow-analysis.md">Definite assignment specification</a></li><li><a href="/null-safety/understanding-null-safety#definite-assignment-analysis">Understanding definite assignment analysis</a></li></ul><div class="term-separator" aria-hidden="true"></div><div class="header-wrapper"><h2 id="function">Function</h2><a class="heading-link" href="#function" aria-label="Link to 'Function' section">#</a></div><p>An umbrella term to refer to top-level functions, local functions, static methods, and instance methods.</p><p><strong>Related docs and resources:</strong></p><ul><li><a href="/language/functions">Functions overview</a></li><li><a href="/language/methods">Instance methods</a></li></ul><div class="term-separator" aria-hidden="true"></div><div class="header-wrapper"><h2 id="irrefutable-pattern">Irrefutable pattern</h2><a class="heading-link" href="#irrefutable-pattern" aria-label="Link to 'Irrefutable pattern' section">#</a></div><p><em>Irrefutable patterns</em> are patterns that always match. Irrefutable patterns are the only patterns that can appear in <em>irrefutable contexts</em>: the <a href="/language/patterns#variable-declaration"><em>declaration</em></a> and <a href="/language/patterns#variable-assignment"><em>assignment</em></a> pattern contexts.</p><p><strong>Related docs and resources:</strong></p><ul><li><a href="/language/patterns#places-patterns-can-appear">Places patterns can appear</a></li><li><a href="https://codelabs.developers.google.com/codelabs/dart-patterns-records">Dive into Dart patterns and records</a></li></ul><div class="term-separator" aria-hidden="true"></div><div class="header-wrapper"><h2 id="mixin-application">Mixin application</h2><a class="heading-link" href="#mixin-application" aria-label="Link to 'Mixin application' section">#</a></div><p>A <em>mixin application</em> is the class created when a mixin is applied to a class. For example, consider the following declarations:</p><div class="code-block-wrapper language-dart"><div class="code-block-body"><span class="code-block-language" title="Language dart">dart</span><pre class="shiki dash-light" tabindex="0"><code><span class="line"><span style="color:#D43324">class</span><span style="color:#0468D7"> A</span><span style="color:#222222"> {}</span></span> <span class="line"></span> <span class="line"><span style="color:#D43324">mixin</span><span style="color:#0468D7"> M</span><span style="color:#222222"> {}</span></span> <span class="line"></span> <span class="line"><span style="color:#D43324">class</span><span style="color:#0468D7"> B</span><span style="color:#D43324"> extends</span><span style="color:#0468D7"> A</span><span style="color:#D43324"> with</span><span style="color:#0468D7"> M</span><span style="color:#222222"> {}</span></span></code></pre></div></div><p>The class <code>B</code> is a subclass of the mixin application of <code>M</code> to <code>A</code>, sometimes nomenclated as <code>A+M</code>. The class <code>A+M</code> is a subclass of <code>A</code> and has members that are copied from <code>M</code>.</p><p>You can give an actual name to a mixin application by defining it as:</p><div class="code-block-wrapper language-dart"><div class="code-block-body"><span class="code-block-language" title="Language dart">dart</span><pre class="shiki dash-light" tabindex="0"><code><span class="line"><span style="color:#D43324">class</span><span style="color:#0468D7"> A</span><span style="color:#222222"> {}</span></span> <span class="line"></span> <span class="line"><span style="color:#D43324">mixin</span><span style="color:#0468D7"> M</span><span style="color:#222222"> {}</span></span> <span class="line"></span> <span class="line"><span style="color:#D43324">class</span><span style="color:#0468D7"> A_M</span><span style="color:#222222"> = </span><span style="color:#0468D7">A</span><span style="color:#D43324"> with</span><span style="color:#0468D7"> M</span><span style="color:#222222">;</span></span></code></pre></div></div><p>Given this declaration of <code>A_M</code>, the following declaration of <code>B</code> is equivalent to the declaration of <code>B</code> in the original example:</p><div class="code-block-wrapper language-dart"><div class="code-block-body"><span class="code-block-language" title="Language dart">dart</span><pre class="shiki dash-light" tabindex="0"><code><span class="line"><span style="color:#D43324">class</span><span style="color:#0468D7"> B</span><span style="color:#D43324"> extends</span><span style="color:#0468D7"> A_M</span><span style="color:#222222"> {}</span></span></code></pre></div></div><p><strong>Related docs and resources:</strong></p><ul><li><a href="/language/mixins">Mixins in Dart</a></li></ul><div class="term-separator" aria-hidden="true"></div><div class="header-wrapper"><h2 id="override-inference">Override inference</h2><a class="heading-link" href="#override-inference" aria-label="Link to 'Override inference' section">#</a></div><p>Override inference is the process by which any missing types in a method declaration are inferred based on the corresponding types from the method or methods that it overrides.</p><p>If a candidate method (the method that's missing type information) overrides a single inherited method, then the corresponding types from the overridden method are inferred. For example, consider the following code:</p><div class="code-block-wrapper language-dart"><div class="code-block-body"><span class="code-block-language" title="Language dart">dart</span><pre class="shiki dash-light" tabindex="0"><code><span class="line"><span style="color:#D43324">class</span><span style="color:#0468D7"> A</span><span style="color:#222222"> {</span></span> <span class="line"><span style="color:#0468D7"> int</span><span style="color:#6200EE"> m</span><span style="color:#222222">(</span><span style="color:#0468D7">String</span><span style="color:#222222"> s) => </span><span style="color:#11796D">0</span><span style="color:#222222">;</span></span> <span class="line"><span style="color:#222222">}</span></span> <span class="line"></span> <span class="line"><span style="color:#D43324">class</span><span style="color:#0468D7"> B</span><span style="color:#D43324"> extends</span><span style="color:#0468D7"> A</span><span style="color:#222222"> {</span></span> <span class="line"><span style="color:#D43324"> @override</span></span> <span class="line"><span style="color:#6200EE"> m</span><span style="color:#222222">(s) => </span><span style="color:#11796D">1</span><span style="color:#222222">;</span></span> <span class="line"><span style="color:#222222">}</span></span></code></pre></div></div><p>The declaration of <code>m</code> in <code>B</code> is a candidate because it's missing both the return type and the parameter type. Because it overrides a single method (the method <code>m</code> in <code>A</code>), the types from the overridden method will be used to infer the missing types and it will be as if the method in <code>B</code> had been declared as <code>int m(String s) =&gt; 1;</code>.</p><p>If a candidate method overrides multiple methods, and the function type one of those overridden methods, M<sub>s</sub>, is a supertype of the function types of all of the other overridden methods, then M<sub>s</sub> is used to infer the missing types. For example, consider the following code:</p><div class="code-block-wrapper language-dart"><div class="code-block-body"><span class="code-block-language" title="Language dart">dart</span><pre class="shiki dash-light" tabindex="0"><code><span class="line"><span style="color:#D43324">class</span><span style="color:#0468D7"> A</span><span style="color:#222222"> {</span></span> <span class="line"><span style="color:#0468D7"> int</span><span style="color:#6200EE"> m</span><span style="color:#222222">(</span><span style="color:#0468D7">num</span><span style="color:#222222"> n) => </span><span style="color:#11796D">0</span><span style="color:#222222">;</span></span> <span class="line"><span style="color:#222222">}</span></span> <span class="line"></span> <span class="line"><span style="color:#D43324">class</span><span style="color:#0468D7"> B</span><span style="color:#222222"> {</span></span> <span class="line"><span style="color:#0468D7"> num</span><span style="color:#6200EE"> m</span><span style="color:#222222">(</span><span style="color:#0468D7">int</span><span style="color:#222222"> i) => </span><span style="color:#11796D">0</span><span style="color:#222222">;</span></span> <span class="line"><span style="color:#222222">}</span></span> <span class="line"></span> <span class="line"><span style="color:#D43324">class</span><span style="color:#0468D7"> C</span><span style="color:#D43324"> implements</span><span style="color:#0468D7"> A</span><span style="color:#222222">, </span><span style="color:#0468D7">B</span><span style="color:#222222"> {</span></span> <span class="line"><span style="color:#D43324"> @override</span></span> <span class="line"><span style="color:#6200EE"> m</span><span style="color:#222222">(n) => </span><span style="color:#11796D">1</span><span style="color:#222222">;</span></span> <span class="line"><span style="color:#222222">}</span></span></code></pre></div></div><p>The declaration of <code>m</code> in <code>C</code> is a candidate for override inference because it's missing both the return type and the parameter type. It overrides both <code>m</code> in <code>A</code> and <code>m</code> in <code>B</code>, so the compiler needs to choose one of them from which the missing types can be inferred. But because the function type of <code>m</code> in <code>A</code> (<code>int Function(num)</code>) is a supertype of the function type of <code>m</code> in <code>B</code> (<code>num Function(int)</code>), the function in <code>A</code> is used to infer the missing types. The result is the same as declaring the method in <code>C</code> as <code>int m(num n) =&gt; 1;</code>.</p><p>It is an error if none of the overridden methods have a function type that is a supertype of all the other overridden methods.</p><p><strong>Related docs and resources:</strong></p><ul><li><a href="/language/extend">Inheritance in Dart</a></li></ul><div class="term-separator" aria-hidden="true"></div><div class="header-wrapper"><h2 id="part-file">Part file</h2><a class="heading-link" href="#part-file" aria-label="Link to 'Part file' section">#</a></div><p>A part file is a Dart source file that contains a <code>part of</code> directive and is included in a library using the <code>part</code> directive.</p><p><strong>Related docs and resources:</strong></p><ul><li><a href="/guides/libraries/create-packages#organizing-a-package">Guidance on libraries and parts</a></li><li><a href="/effective-dart/usage#do-use-strings-in-part-of-directives">Use library URIs in <code>part of</code> directives</a></li></ul><div class="term-separator" aria-hidden="true"></div><div class="header-wrapper"><h2 id="potentially-non-nullable">Potentially non-nullable</h2><a class="heading-link" href="#potentially-non-nullable" aria-label="Link to 'Potentially non-nullable' section">#</a></div><p>A type is <em>potentially non-nullable</em> if it's either explicitly non-nullable or if it's a type parameter.</p><p>A type is explicitly non-nullable if it is a type name that isn't followed by a question mark (<code>?</code>). Note that there are a few types that are always nullable, such as <code>Null</code> and <code>dynamic</code>, and that <code>FutureOr</code> is only non-nullable if it isn't followed by a question mark <em>and</em> the type argument is non-nullable (such as <code>FutureOr&lt;String&gt;</code>).</p><p>Type parameters are potentially non-nullable because the actual runtime type (the type specified as a type argument) might be non-nullable. For example, given a declaration of <code>class C&lt;T&gt; {}</code>, the type <code>C</code> could be used with a non-nullable type argument as in <code>C&lt;int&gt;</code>.</p><p><strong>Related docs and resources:</strong></p><ul><li><a href="/null-safety/understanding-null-safety#nullability-and-generics">Nullability and generics</a></li></ul><div class="term-separator" aria-hidden="true"></div><div class="header-wrapper"><h2 id="public-library">Public library</h2><a class="heading-link" href="#public-library" aria-label="Link to 'Public library' section">#</a></div><p>A public library is a library that is located inside the package's <code>lib</code> directory but not inside the <code>lib/src</code> directory.</p><p><strong>Related docs and resources:</strong></p><ul><li><a href="/guides/libraries/create-packages#organizing-a-package">Organizing a package's libraries</a></li><li><a href="/tools/pub/package-layout#public-directories">Public package directories</a></li></ul><div class="term-separator" aria-hidden="true"></div><div class="header-wrapper"><h2 id="quick-fix">Quick fix</h2><a class="heading-link" href="#quick-fix" aria-label="Link to 'Quick fix' section">#</a></div><p>An automated, local code edit targeted at fixing the issue reported by a specific diagnostic.</p><p><strong>Related docs and resources:</strong></p><ul><li><a href="https://medium.com/dartlang/quick-fixes-for-analysis-issues-c10df084971a">Quick fixes for analysis issues</a></li><li><a href="/tools/diagnostic-messages">Diagnostic messages</a></li><li><a href="/tools/linter-rules">Linter rules</a></li></ul><div class="term-separator" aria-hidden="true"></div><div class="header-wrapper"><h2 id="refactor">Refactor</h2><a class="heading-link" href="#refactor" aria-label="Link to 'Refactor' section">#</a></div><p>A refactor is a code edit targeted at modifications that are either non-local or that require user interaction. Examples of refactors include renaming, removing, or extracting code.</p><p><strong>Related docs and resources:</strong></p><ul><li><a href="#assist">Assist</a></li></ul><div class="term-separator" aria-hidden="true"></div><div class="header-wrapper"><h2 id="refutable-pattern">Refutable pattern</h2><a class="heading-link" href="#refutable-pattern" aria-label="Link to 'Refutable pattern' section">#</a></div><p>A <em>refutable pattern</em> is a pattern that can be tested against a value to determine if the pattern matches the value. If not, the pattern <em>refutes</em>, or denies, the match. Refutable patterns appear in <a href="/language/patterns#matching"><em>matching contexts</em></a>.</p><p><strong>Related docs and resources:</strong></p><ul><li><a href="/language/patterns#places-patterns-can-appear">Places patterns can appear</a></li><li><a href="https://codelabs.developers.google.com/codelabs/dart-patterns-records">Dive into Dart patterns and records</a></li></ul><div class="term-separator" aria-hidden="true"></div><div class="header-wrapper"><h2 id="subclass">Subclass</h2><a class="heading-link" href="#subclass" aria-label="Link to 'Subclass' section">#</a></div><p>A <em>subclass</em> is a class that inherits the implementation of another class by using the <a href="/language/extend"><code>extends</code></a> keyword, or by <a href="#mixin-application">mixin application</a>.</p><div class="code-block-wrapper language-dart"><div class="code-block-body"><span class="code-block-language" title="Language dart">dart</span><pre class="shiki dash-light" tabindex="0"><code><span class="line"><span style="color:#6E6E70">// A is a subclass of B; B is the superclass of A.</span></span> <span class="line"><span style="color:#D43324">class</span><span style="color:#0468D7"> A</span><span style="color:#D43324"> extends</span><span style="color:#0468D7"> B</span><span style="color:#222222"> {}</span></span> <span class="line"></span> <span class="line"><span style="color:#6E6E70">// B1 has the superclass `A with M`, which has the superclass A.</span></span> <span class="line"><span style="color:#D43324">class</span><span style="color:#0468D7"> B1</span><span style="color:#D43324"> extends</span><span style="color:#0468D7"> A</span><span style="color:#D43324"> with</span><span style="color:#0468D7"> M</span><span style="color:#222222"> {}</span></span></code></pre></div></div><p>A subclass relation also implies an associated <a href="#subtype">subtype</a> relation. For example, <code>class A</code> implicitly defines an associated type <code>A</code> which instances of the class <code>A</code> inhabit. So, <code>class A extends B</code> declares not just that the class <code>A</code> is a subclass of <code>B</code>, but also establishes that the <em>type</em> <code>A</code> is a <em>subtype</em> of the type <code>B</code>.</p><p>Subclass relations are a subset of subtype relations. When the documentation says &quot;<code>S</code> must be a subtype of <code>T</code>&quot;, it's fine for <code>S</code> to be a subclass of <code>T</code>. However, the converse is not true: not all subtypes are subclasses.</p><p><strong>Related docs and resources:</strong></p><ul><li><a href="/language/extend">Inheritance in Dart</a></li><li><a href="#subtype">Subtype relationship</a></li></ul><div class="term-separator" aria-hidden="true"></div><div class="header-wrapper"><h2 id="subtype">Subtype</h2><a class="heading-link" href="#subtype" aria-label="Link to 'Subtype' section">#</a></div><p>A <em>subtype</em> relation is where a value of a certain type is substitutable where the value of another type, the supertype, is expected. For example, if <code>S</code> is a subtype of <code>T</code>, then you can substitute a value of type <code>S</code> where a value of type <code>T</code> is expected.</p><p>A subtype supports all of the operations of its supertype (and possibly some extra operations). In practice, this means you can assign the value of a subtype to any location expecting the supertype, and all of the methods of the supertype are available on the subtype.</p><p>This is true at least statically. A specific API might not allow the substitution at run time, depending on its operations.</p><p>Some subtype relations are based on the structure of the type, like with nullable types (for example, <code>int</code> is a subtype of <code>int?</code>) and function types (for example, <code>String Function()</code> is a subtype of <code>void Function()</code>).</p><p>Subtypes can also be introduced for classes by <a href="/language/classes#implicit-interfaces">implementation</a> or <a href="/language/extend">inheritance</a> (direct or indirect):</p><div class="code-block-wrapper language-dart"><div class="code-block-body"><span class="code-block-language" title="Language dart">dart</span><pre class="shiki dash-light" tabindex="0"><code><span class="line"><span style="color:#6E6E70">// A is a subtype of B, but NOT a subclass of B.</span></span> <span class="line"><span style="color:#D43324">class</span><span style="color:#0468D7"> A</span><span style="color:#D43324"> implements</span><span style="color:#0468D7"> B</span><span style="color:#222222"> {}</span></span> <span class="line"></span> <span class="line"><span style="color:#6E6E70">// C is a subtype AND a subclass of D.</span></span> <span class="line"><span style="color:#D43324">class</span><span style="color:#0468D7"> C</span><span style="color:#D43324"> extends</span><span style="color:#0468D7"> D</span><span style="color:#222222"> {}</span></span></code></pre></div></div><p><strong>Related docs and resources:</strong></p><ul><li><a href="#subclass">Subclass</a></li><li><a href="/language/type-system#substituting-types">Substituting types</a></li></ul><div class="term-separator" aria-hidden="true"></div><div class="header-wrapper"><h2 id="variance">Variance and variance positions</h2><a class="heading-link" href="#variance" aria-label="Link to 'Variance and variance positions' section">#</a></div><p>A type parameter of a class (or other type declaration, like a mixin) is said to be <em>covariant</em> when the type as a whole &quot;co-varies&quot; with the actual type argument. In other words, if the type argument is replaced by a subtype then the type as a whole is also a subtype.</p><p>For example, the type parameter of the class <code>List</code> is covariant because list types co-vary with their type argument: <code>List&lt;int&gt;</code> is a subtype of <code>List&lt;Object&gt;</code> because <code>int</code> is a subtype of <code>Object</code>.</p><p>In Dart, all type parameters of all class, mixin, mixin class, and enum declarations are covariant.</p><p>However, function types are different: A function type is covariant in its return type, but the opposite (known as <em>contravariant</em>) in its parameter types. For example, the type <code>int Function(int)</code> is a subtype of the type <code>Object Function(int)</code>, but it is a supertype of <code>int Function(Object)</code>.</p><p>This makes sense if you consider their <a href="#subtype">substitutability</a>. If you call a function with a static type of <code>int Function(int)</code>, that function can actually be of type <code>int Function(Object)</code> at runtime. Based on the static type, you expect to be able to pass an <code>int</code> to it. That will be fine since the function actually accepts any <code>Object</code>, and this includes every object of type <code>int</code>. Similarly, the returned result will be of type <code>int</code>, which is also what you expect based on the static type.</p><p>Hence, <code>int Function(Object)</code> is a subtype of <code>int Function(int)</code>.</p><p>Note that everything is turned upside-down for parameter types. In particular, this subtype relation among function types requires that the <em>opposite</em> subtype relation exists for the parameter type. For example, <code>void Function(Object)</code> is a subtype of <code>void Function(int)</code> because <code>int</code> is a subtype of <code>Object</code>.</p><p>With a more complex type like <code>List&lt;void Function(int)&gt;</code>, you have to consider the <em>positions</em> in the type. To accomplish this, turn one of the parts of the type into a placeholder, and then consider what happens to the type when different types are placed in that position.</p><p>For example, consider <code>List&lt;void Function(_)&gt;</code> as a template for a type where you can put different types in place of the placeholder <code>_</code>. This type is contravariant in the position where that placeholder occurs.</p><p>The following illustrates this by substituting <code>Object</code> and <code>int</code> for <code>_</code>. <code>List&lt;void Function(Object)&gt;</code> is a subtype of <code>List&lt;void Function(int)&gt;</code> because <code>void Function(Object)</code> is a subtype of <code>void Function(int)</code> because <code>void</code> is a subtype of <code>void</code> (the return types) and <code>int</code> is a subtype of <code>Object</code> (the parameter types, in the opposite order). Hence, the type at <code>_</code> varies in the opposite direction of the type <code>List&lt;void Function(_)&gt;</code> as a whole, and this 'opposite direction' by definition makes it a <em>contravariant position</em>.</p><p>A <em>covariant position</em> is defined similarly. For example, <code>_</code> is at a covariant position in the type <code>List&lt;_&gt;</code>, and <code>_</code> is also at a covariant position in the type <code>_ Function(int)</code>.</p><p>There is yet another kind of position known as <em>invariant</em>, but it occurs much more rarely so the details are omitted here.</p><p>In practice, it's often sufficient to know that the type arguments of a class, mixin, etc. are in a covariant position, and so is the return type of a function type, but the parameter types are in a contravariant position.</p><p><strong>Related docs and resources:</strong></p><ul><li><a href="#subtype">Subtype relationship</a></li><li><a href="https://en.wikipedia.org/wiki/Covariance_and_contravariance_(computer_science)">Covariance and contravariance</a></li><li><a href="/guides/language/sound-problems#the-covariant-keyword">The covariant keyword</a></li></ul><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-06.</span> <a href="https://github.com/dart-lang/site-www/tree/main/src/content/resources/glossary.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/resources/glossary/&page-source=https://github.com/dart-lang/site-www/tree/main/src/content/resources/glossary.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>

Pages: 1 2 3 4 5 6 7 8 9 10