Home > Blockchain >  What does the @ ('at sign') sign mean in dart?
What does the @ ('at sign') sign mean in dart?

Time:12-09

What does the @(at sign) mean in dart?

@immutable
@JsonSerializable(createToJson: false)
class ClassA  {

  @JsonKey(name: 'field_1')
  final int field1;
  @JsonKey(name: 'field_2')
  final String field2;

  const ClassA(this.field1, this.field2);

  factory ClassA.fromJson(Map<String, dynamic> json) => _$ClassAFromJson(json);
}

CodePudding user response:

@ sign means Metadata annotation

Use metadata to give additional information about your code. A metadata annotation begins with the character @, followed by either a reference to a compile-time constant (such as deprecated) or a call to a constant constructor.

More on dart.dev

  • Related