What does @ operator exactly mean in dart?

158

Solution 1

As Kherel mentioned, the @ symbol is for metadata. It helps developers keep track of certain functions for future purposes.

If you want, you can then use that metadata for programmatic purposes using the 'dart:mirrors' library.

For example, flutter uses @override to ensure that child classes are allowed their specific behavior, separate from the parents.

The most common usage is to classify functions and classes in some way for easy access. IDEs may also keep track of certain metadata to warn you about the way functions operate (via @TODO or @deprecated, for instance).

Solution 2

it's metadata read here about it: dart language-tour

Share:
158
Saeed
Author by

Saeed

Software developer, Human-Computer-Interaction, Flutter, Swift,

Updated on December 21, 2022

Comments

  • Saeed
    Saeed over 1 year

    I see many instances of @ sign like @package_name or @somthing in dart. Although I know the usage of some examples like @override, I can't understand why some packages(eg: @freezed) or dart syntax(eg: @immutable,@lazySingleton) use this operator and what its functionality is.