Keywords in dart

Published by admin on

Dart keywords explanation with examples

Introduction :

Keywords are treated differently. Like other programming languages, keywords are words you can’t use as identifiers. Actually, you can use a few keywords as identifiers but you shouldn’t if you want to follow the best practices.

 

Built-in identifiers :

These identifiers are valid identifiers. But you can’t use them as the prefix for imports, class name or type names. Following are these identifiers :

[table]

-,-,-,-,-
abstract, dynamic, implements, as, import
static, interface, export, library, external
mixin, factory, Function, operator, typedef
covariant, get, part, set, deferred
[/table]

 

contextual keywords :

These are valid identifiers but have meaning only in specific places.

[table]

-,-,-
async, show, on
hide, sync
[/table]

 

Reserved words :

You can’t use any reserved words as identifier. These are espicifically designed for the dart language.

[table]

-,-,-,-,-
assert, enum, else, extends, in
super, is, switch, this, case
break, true, false, throw, new
final, class, null, try, const
finally, var, continue, for, default
rethrow, while, do, if, return
with, catch,
[/table]

Other than these keywords, two more keywords were introduced in Dart 1.0 :

[table]

-,-
await, yield
[/table]

You can’t use these keywords as an identifier in any async, async* or sync* function.

Categories: dart

0 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *