ModelGroupMember class
Represents a member bound to a group.
This model ties an identity (email/userId) to a ModelGroup with a role (role), entity type (entityType) and source of membership (source), along with subscription preferences and audit metadata (crud).
JSON contract:
- Required fields:
id(string)groupId(string)email(string; validated by Utils.getEmailFromDynamic)userId(string)role(string;ModelGroupMemberRole.name)entityType(string;ModelGroupMemberEntityType.name)membershipId(string)source(string;ModelGroupMemberSource.name)subscription(string;ModelGroupMemberSubscription.name)includeDerived(bool; defaults tofalsewhen missing/null)active(bool; defaults totruewhen missing/null)crud(object; ModelCrudMetadata.toJson)
Parsing rules:
- Scalar strings fall back to
''when missing ornull. - email uses Utils.getEmailFromDynamic: any non-valid email yields
''. - Enum fields use Utils.enumFromJson with these defaults:
- includeDerived and active are normalized with
Utils.getBoolFromDynamic with respective defaults
falseandtrue.
Minimal runnable example:
void main() {
final DateTime now = DateTime.utc(2025, 1, 1, 10, 0, 0);
final ModelCrudMetadata crud = ModelCrudMetadata(
recordId: 'member-1',
createdBy: 'system@domain.com',
createdAt: now,
updatedBy: 'system@domain.com',
updatedAt: now,
version: 1,
);
final ModelGroupMember member = ModelGroupMember(
id: 'member-1',
groupId: 'group-001',
email: 'user@domain.com',
userId: 'user-001',
role: ModelGroupMemberRole.member,
entityType: ModelGroupMemberEntityType.user,
membershipId: 'm-001',
source: ModelGroupMemberSource.manual,
subscription: ModelGroupMemberSubscription.allMail,
includeDerived: false,
active: true,
crud: crud,
);
final Map<String, dynamic> json = member.toJson();
final ModelGroupMember roundtrip = ModelGroupMember.fromJson(json);
print(roundtrip.email); // user@domain.com
print(roundtrip.role); // ModelGroupMemberRole.member
}
Constructors
- ModelGroupMember({required String id, required String groupId, required String email, required String userId, required ModelGroupMemberRole role, required ModelGroupMemberEntityType entityType, required String membershipId, required ModelGroupMemberSource source, required ModelGroupMemberSubscription subscription, required bool includeDerived, required bool active, required ModelCrudMetadata crud})
-
const
-
ModelGroupMember.fromJson(Map<
String, dynamic> json) -
Creates a ModelGroupMember from a JSON-like map.
factory
Properties
- active → bool
-
final
- crud → ModelCrudMetadata
-
final
- email → String
-
final
- entityType → ModelGroupMemberEntityType
-
final
- groupId → String
-
final
- hashCode → int
-
Gets the hash code for this entity model.
no setteroverride
- id → String
-
final
- includeDerived → bool
-
final
- membershipId → String
-
final
- role → ModelGroupMemberRole
-
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- source → ModelGroupMemberSource
-
final
- subscription → ModelGroupMemberSubscription
-
final
- userId → String
-
final
Methods
-
copyWith(
{String? id, String? groupId, String? email, String? userId, ModelGroupMemberRole? role, ModelGroupMemberEntityType? entityType, String? membershipId, ModelGroupMemberSource? source, ModelGroupMemberSubscription? subscription, bool? includeDerived, bool? active, ModelCrudMetadata? crud}) → ModelGroupMember -
Creates a copy of the entity model.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toJson(
) → Map< String, dynamic> -
Converts the entity model to a JSON Map.
override
-
toString(
) → String -
A string representation of this object.
override
Operators
-
operator ==(
Object other) → bool -
Checks whether the given
otherobject is equal to this entity model.override