withGetter top-level constant

WithGetterAnnotation const withGetter

This annotation can be used inside any modddel / union of modddels, in front of a member parameter.

Use this annotation if you want to have a direct getter for the member parameter.

For Example :

factory Book({
  @withGetter required String id,
  required String title,
})

Now you can directly access the id field from a Book instance :

// Allowed.
final id = book.id;

// Error.
final title = book.title;

Implementation

const withGetter = WithGetterAnnotation();