Datagen class

Annotation class used to configure code generation options for a Dart data class.

Applying Datagen to a class controls which utility methods and factories are automatically generated in the companion .datagen.dart file.

Example:

@Datagen(
  copyWith: true,
  fromJson: true,
  toJson: true,
  stringify: true,
)
class MyModel { ... }

Constructors

Datagen({bool copyWith = true, bool fromJson = true, bool fromJsonList = true, bool toJson = true, bool stringify = true, bool equality = true, bool omitFactory = true})
Creates a Datagen annotation with optional flags. All options default to true.
const

Properties

copyWith bool
Enables generating a copyWith method for the annotated class.
final
equality bool
Enables generating a hashCode and operator == override.
final
fromJson bool
Enables generating a fromJson factory constructor.
final
fromJsonList bool
Enables generating a fromJsonList factory constructor.
final
hashCode int
The hash code for this object.
no setterinherited
omitFactory bool
Controls whether a fromJson factory is generated in the public class. The factory in the generated .datagen.dart class is always created.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
stringify bool
Enables generating a toString override method.
final
toJson bool
Enables generating a toJson method.
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
override

Operators

operator ==(Object other) bool
The equality operator.
inherited