GroupKey constructor

const GroupKey(
  1. Type resourceType, {
  2. String? localName,
  3. List<GroupingProperty> groupingProperties = const [],
})

Creates a GroupKey annotation for organizing resources into groups.

The resourceType specifies which RootResource type this group index organizes.

The optional localName distinguishes multiple group indices for the same resource type (defaults to 'default' if omitted).

The groupingProperties define how group key values are extracted and transformed from resource properties. Use GroupingProperty with optional RegexTransforms to normalize values (e.g., extract year-month from dates).

Example:

@GroupKey(
  Note,
  localName: 'byMonth',
  groupingProperties: [
    GroupingProperty(
      Schema.dateCreated,
      transforms: [
        RegexTransform(r'^(\d{4}-\d{2})', r'\1'),  // Extract YYYY-MM
      ],
    ),
  ],
)
class NoteMonthGroupKey { ... }

Implementation

const GroupKey(
  this.resourceType, {
  this.localName,
  this.groupingProperties = const [],
});