GeneratePreferences class

Annotates a class that extends BasePreferences to trigger code generation.

This is the entry point for the generator. When a class is marked with @GeneratePreferences(), the builder creates a corresponding part 'file.preferences.dart' file.

Detailed Scenario: Multi-Module App

If you have a modular app, you can create separate preference classes for each module (e.g., AuthPreferences, ProfilePreferences).

@GeneratePreferences()
class UserPreferences extends BasePreferences with _$UserPreferences {
  @UserDefault('user_id')
  late final int _userId = 0;
}

Constructors

GeneratePreferences()
const

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

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

Operators

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