Dart Keywords

Dart Keywords

Dart, like any programming language, has a set of keywords that serve as reserved words with special meanings in the language. Here are some of the Dart keywords:

  1. abstract: Used to declare an abstract class or to indicate that a method does not have a body and must be implemented in a subclass.

  2. as: Used in import statements to specify a prefix for a library.

  3. assert: Used to throw an exception if a given Boolean expression is false. It's often used for debugging purposes.

  4. async: Used to declare an asynchronous function. Functions marked with async can use the await keyword to pause execution until a Future is complete.

  5. await: Used within an async function to pause execution until the awaited Future completes.

  6. break: Used to exit a loop prematurely.

  7. case: Used in a switch statement to define different cases.

  8. catch: Used to catch exceptions in a try-catch block.

  9. class: Used to declare a class.

  10. const: Used to define a compile-time constant.

  11. continue: Used to skip the rest of a loop's body and move to the next iteration.

  12. covariant: Used in method parameters to allow a subclass to override a method with a parameter type different from the one in the superclass.

  13. default: Used in a switch statement to provide a default case.

  14. deferred: Used in import statements to load a library lazily.

  15. do: Used to start a do-while loop.

  16. dynamic: Represents a dynamic type. Variables of type dynamic can hold values of any type.

  17. else: Used in an if-else statement.

  18. enum: Used to declare an enumeration, a special kind of class representing a fixed number of constant values.

  19. export: Used to export symbols from one Dart library to another.

  20. extends: Used in a class declaration to indicate the class being extended.

  21. extension: Used to declare an extension, allowing you to add new functionality to existing types.

  22. external: Indicates that a member is implemented in external code, such as JavaScript.

  23. factory: Used in a class to indicate that a constructor returns an instance of the class.

  24. false: Boolean literal representing the false value.

  25. final: Used to declare a variable that cannot be reassigned.

These are just some of the keywords in Dart. Understanding and using these keywords correctly is essential for effective Dart programming.