@@ -74,6 +74,19 @@ abstract class PrivacyBase with SerializableMixin, EquatableMixin {
7474 /// it is accessible to read by anyone on the platform.
7575 final bool public;
7676
77+ factory PrivacyBase .from ({
78+ required Set <String > teams,
79+ required Set <String > users,
80+ required Map <String , Role > roles,
81+ required bool public,
82+ }) =>
83+ _PrivacyBaseImpl (
84+ teams: teams,
85+ users: users,
86+ roles: roles,
87+ public: public,
88+ );
89+
7790 /// An owner ID must always exist in the roles map. It's an error
7891 /// if it doesn't.
7992 @JsonKey (includeFromJson: false , includeToJson: false )
@@ -105,12 +118,12 @@ abstract class PrivacyBase with SerializableMixin, EquatableMixin {
105118 public = public ?? false ;
106119
107120 /// Creates a new [PrivacyBase] derived from another [PrivacyBase] .
108- PrivacyBase .private ({required PrivacyBase privacy})
121+ PrivacyBase .private ({required PrivacyBase privacy, bool ? public })
109122 : this (
110123 teams: privacy.teams,
111124 users: privacy.users,
112125 roles: privacy.roles,
113- public: privacy.public,
126+ public: public ?? privacy.public,
114127 );
115128
116129 /// While this PrivacyBase object is extended by other models, calling
@@ -126,7 +139,7 @@ abstract class PrivacyBase with SerializableMixin, EquatableMixin {
126139 /// ...privacyBase.privacy.toJson(),
127140 /// }
128141 @JsonKey (includeFromJson: false , includeToJson: false )
129- PrivacyBaseImpl get privacy => PrivacyBaseImpl ._ (
142+ PrivacyBase get privacy => _PrivacyBaseImpl (
130143 teams: teams,
131144 users: users,
132145 roles: roles,
@@ -140,9 +153,9 @@ abstract class PrivacyBase with SerializableMixin, EquatableMixin {
140153/// A base implementation of the [PrivacyBase] to extract privacy fields from
141154/// an inherited model without worrying about the other fields that may be
142155/// present in the model.
143- @JsonSerializable (constructor : '_' )
144- class PrivacyBaseImpl extends PrivacyBase {
145- const PrivacyBaseImpl ._ ({
156+ @JsonSerializable (createFactory : false )
157+ final class _PrivacyBaseImpl extends PrivacyBase {
158+ const _PrivacyBaseImpl ({
146159 required super .teams,
147160 required super .users,
148161 required super .roles,
@@ -151,7 +164,4 @@ class PrivacyBaseImpl extends PrivacyBase {
151164
152165 @override
153166 Map toJson () => _$PrivacyBaseImplToJson (this );
154-
155- factory PrivacyBaseImpl .fromJson (Map <String , dynamic > json) =>
156- _$PrivacyBaseImplFromJson (json);
157167}
0 commit comments