Skip to main content

Command Palette

Search for a command to run...

Keywords in Dart

Keywords have a special meaning in the language. These reserved words cannot be used as identifiers.

Updated
•3 min read•View as Markdown
Keywords in Dart
J

Hello! I'm Jay Tillu, an Information Security Engineer at Simple2Call. I have expertise in security frameworks and compliance, including NIST, ISO 27001, and ISO 27701. My specialities include Vulnerability Management, Threat Analysis, and Incident Response. I have also earned certifications in Google Cybersecurity and Microsoft Azure. I’m always eager to connect and discuss cybersecurity—let's get in touch!

Knowledge of keywords is also important. As we cannot use it as Identifiers (Although in some cases we can. let’s follow the best practices).

Keywords have a special meaning in the language.

Reserved Words

  • Following are the reserved words in a dart. These reserved words cannot be used as identifiers.
assertdefaultfinally
trybreakdo
returnvarcase
ifsupervoid
enuminswitch
classextendsis
withconstfalse
throwcontinuefinal
truerethrowfor
elsecatchwhile
thisnewnull

Contextual Keywords

  • These keywords have meaning only in specific places. In other places, they are valid identifiers.
asyncshowhide
syncon

Built-in Identifiers

  • These keywords are valid identifiers in most places, but they can’t be used as class or type names, or as import prefixes.
abstractdynamicFunctioninterface
partasexportget
librarysetcovariantexternal
implementsmixinstaticdeferred
factoryimportoperatortypedef

await*andyieldare newer words added after Dart’s 1.0 release. And cannot be used as an identifier in any function body marked with async, async*, or sync*.*

These all are keywords of a dart. That you need to know as a developer. Don’t use any one of these as an identifier (Although you can. Just take it as my personal tipā˜ŗļø)

Conclusion

In conclusion, understanding the significance of keywords in Dart is crucial, as they cannot be used as identifiers in general (with some exceptions). Keywords hold a specific meaning within the language and should be recognized as such. Dart includes reserved words that cannot be used as identifiers, along with contextual keywords that have meaning only in specific contexts. Built-in identifiers are valid in most instances, except as class or type names, or as import prefixes. Lastly, the newer keywords "await" and "yield" has certain limitations and cannot be used as identifiers in function bodies marked with async, async*, or sync*.

Feel free to let me know if I miss something. And I’ll surely catch you up in the next article.

Till Then Keep Coding, Keep Loving. Jai Hind, Vande Mataram šŸ‡®šŸ‡³

Remember no teacher, no book, no video tutorial, or no blog can teach you everything. As one said Learning is Journey and Journey never ends. Just collect some data from here and there, read it, learn it, practice it, and try to apply it. Don’t feel hesitant that you can’t do that or you don’t know this concept or that concept. Remember every programmer was passed from the path on which you are walking right now. Remember Every Master was Once a Beginner. Work hard and Give your best.

šŸ’”
Subscribe To My Newsletter For More Such Content.

Do you know how many types of hackers are there?

Learn More about Dart and Flutter

Follow me for more such content

Flutter

Part 21 of 25

In this series, we will learn about the mobile application framework by Google named Flutter. We'll start from basics and cover till advance topics of Dart and Flutter.

Up next

Variables in Dart

Variable is a named space in memory that stores value. You can say that it is a container for data.