zero_coding zero_coding - 1 year ago 141
Dart Question

What does const mean?

I am using angular2dart and want to know, why do I have to pass keyword const on:

directives: const [HeroDetailComponent]

component properties.

Answer Source

const means a compile-time constant. Been constant it can be optimized and instantiated only once.

const [HeroDetailComponent] means that the list is a compile time constant. Compile-time constants are mandatory when used as metadata (in your case directives is a named parameter of @Component() that is a metadata of your class).

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download