keywords in Dart

Contextual keywords

show

If you want to selectively import part of the library.

async

To define an async function, a function marked as async.

sync

To implement a synchronous generator function, mark the function body as sync*.

on

Use on when you need to specify the exception type

hide

If you want to import all names EXCEPT some part of library.

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.

abstract

Use the abstract modifier to define an abstract class and abstract methods.

dynamic

Use dynamic keyword, when you want to explicitly say that no type is expected to an object.

implements

A class may implement a number of interfaces by declaring them in its implements clause.

as

Use the as operator to cast an object to a particular type if and only if you are sure that the object is of that type.

static

Use the static keyword to implement class-wide variables and methods.

import

Use import to specify how a namespace from one library is used in the scope of another library.

export

Use export to specify how a namespace of library is available to access in the scope of another library.

part

Use part directive, which allows you to split a library into multiple Dart files.

interface

The interface keyword was removed from Dart.

external

Used on functions, an external function is a function whose body is provided separately from its declaration.

library

A library directives can help you create a modular and shareable code base.

factory

Use the factory keyword when implementing a constructor that doesn’t always create a new instance of its class.

mixin

Mixins are a way of reusing a class’s code in multiple class hierarchies.

typedef

A typedef, or function-type alias, gives a function type a name that you can use when declaring fields and return types.

operator

An overloaded operator is called an operator function. You declare an operator function with the keyword operator preceding the operator.

covariant

you can use the covariant keyword to tell the analyzer that you are intentionally tightening a type by overriding a parameter’s type with a subtype.

Function

Dart is a true object-oriented language, so even functions are objects and have a type, Function.

deferred

Deferred loading (also called lazy loading) allows a web app to load a library on demand, if and when the library is needed

set

Use set to provide write access to an object’s properties.

get

Use get to provide read access to an object’s properties.

Reserved words

The keyword used in Statements.

if

Dart supports if statements

else

Define optional else statements.

switch

A switch statement is a type of selection control mechanism.

default

Use a default clause to execute code when no case clause matches.

break

A keyword used to used to stop looping.

continue

Use continue to skip to the next loop iteration.

for

You can iterate with the standard for loop

while

A while loop evaluates the condition before the loop.

return

The return statement returns a result to the caller of a synchronous function.

assert

Use an assert statement — assert(condition, optionalMessage); — to disrupt normal execution if a boolean condition is false.

enum

To declare an enumerated type using the enum keyword.

in

for-in used on Iterable classes.

super

super keyword is to refer to the superclass.

extends

Use extends to create a subclass.

is

If you aren’t sure that the object is of type T, then use is to check the type before using the object.

this

The this keyword refers to the current instance.

case

To specify a code block which needs to be executed.

new

A new keyword before the constructor name to create an object.

true

To represent boolean value

false

To represent boolean value.

class

Use to declare a class.

final

If you never intend to change a variable, use final.

const

If you never intend to change a variable, use const.

null

Uninitialized variables have an initial value of null.

var

creating a variable and initializing it.

void

Used at method declaration and definition to specify that the method does not return any type.

with

To use a mixin, use the with keyword followed by one or more mixin names.

do

A do-while loop evaluates the condition after the loop.

The keyword used in Exception handling.

try

The try statement is definition of exception handling code in a structured way.

catch

Catching, or capturing, an exception.

finally

The finally keyword is to ensure that some code runs whether or not an exception is thrown.

throw

use to throw as exception.

rethrow

To partially handle an exception, while allowing it to propagate, use the rethrow keyword.

Limited Reserved keywords

await

Uses await to wait for the result of an asynchronous function.

yield

Use yield statements to deliver values