Keywords in Dart
Dart Keywords are the reserve words that have special meaning for the compiler. It cannot be used as the variable name, class name, or function name. Keywords are case sensitive they must be written as they are defined.
There are 61 keywords in the Dart.
Some of them are common, you may be already familiar and few are different.
Abstract modifier is used to define an abstract class—a class that can’t be instantiated. Abstract classes are useful or defining interfaces, often with some implementation.
As operator is used to cast an object to a particular type if and only if when we are sure that the object is of that type.
The assert statement is used to debug the code, and it uses boolean condition for testing. If the boolean expression in the assert statement is true then the code continues to execute, but if it returns false then the code ends with Assertion Error.
When an async function is called, a future is immediately returned and the body of the function is executed later. As the async function’s body is executed, the Future returned by the function call will be completed along with its result. In the above example, calling demo() results in the Future.
Await expressions makes you write the asynchronous code almost as if it were synchronous
Break is used for stopping the loop and switch case whenever the condition is met. Eg: Break in while loop
Case is the same as it is in other programming languages it is used with switch statement.
Catch is used with the try block in dart to catch exceptions in the program.
Class in dart as same as a class in other object-oriented programming languages. A class is a group of objects which have common properties. It is a template or blueprint from which objects are created. It is a logical entity.
Continue statement is used to break one iteration in the loop whenever the condition matches and start the next iteration.
Const is used for making a variable constant throughout the program. The const keyword isn’t just for declaring constant variables. We can also use it to create constant values and declare constructors that create constant values. Any variable can have a constant value.
Covariant keyword to tell the analyzer that you are overriding a parameter’s type with a subtype, which is invalid.This removes the static error and instead checks for an invalid argument type at runtime.
Default statement is used in switch case when no condition matches then the default statement is executed.
Deferred loading (also called lazy loading) allows a web app to load a library on-demand when the library is needed.
Do is used with while for do-while loop.
Else is used with if statement, it is used to test the condition, if block is executed, if the condition is true otherwise else block, is executed.
Enums, are a special kind of class used to represent a fixed number of constant values.
Export is used to create a new library and use other libraries you want to make available automatically when using your package.
Extends to create a subclass, and super to refer to the superclass
Extensions are a way through which we can add functionality to the existing libraries.
An external function is a function whose body is provided separately from its declaration. An external function may be a top-level function or a method.
Factory is used when implementing a constructor that doesn’t always create a new instance of its class.
False is one of the boolean types of dart apart from true.
Final is used when we don’t intend to change a variable in the rest of the program.
Finally is a block, which is used to place codes that should be executed even if there is an exception in the program. finally block is placed after the try block and whenever any error occurs the control goes to the finally block and it is executed.
For is used in ‘for loop’, it is the same as for loops in other programming languages.
Dart is a true object-oriented language, so even functions are objects and have a type,
Function. It means that functions can be assigned to variables or passed as arguments to other functions.
Getters and setters are special methods that provide read and write access to an object’s properties
Hide is used when only part of a library, you can selectively import the library.