Merge pull request 'notification_important' (#170) from notification_important into main

Reviewed-on: https://repo.ravanertebat.com/TM/tm_app/pulls/170
This commit is contained in:
a.ghabeli
2025-09-27 13:36:05 +03:30
17 changed files with 1237 additions and 870 deletions
@@ -2,7 +2,8 @@
import 'package:freezed_annotation/freezed_annotation.dart'; import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:tm_app/data/services/model/error/error_model.dart'; import 'package:tm_app/data/services/model/error/error_model.dart';
import 'package:tm_app/data/services/model/notification_data/notification_data.dart'; import 'package:tm_app/data/services/model/meta/meta.dart';
import 'package:tm_app/data/services/model/notification_data/notification_recipient.dart';
part 'notification_response_model.freezed.dart'; part 'notification_response_model.freezed.dart';
part 'notification_response_model.g.dart'; part 'notification_response_model.g.dart';
@@ -12,10 +13,40 @@ abstract class NotificationResponseModel with _$NotificationResponseModel {
const factory NotificationResponseModel({ const factory NotificationResponseModel({
required bool? success, required bool? success,
required String? message, required String? message,
required NotificationData? data, required List<NotificationItem>? data,
required ErrorModel? error, required ErrorModel? error,
required Meta? meta,
}) = _NotificationResponseModel; }) = _NotificationResponseModel;
factory NotificationResponseModel.fromJson(Map<String, Object?> json) => factory NotificationResponseModel.fromJson(Map<String, Object?> json) =>
_$NotificationResponseModelFromJson(json); _$NotificationResponseModelFromJson(json);
} }
@freezed
abstract class NotificationItem with _$NotificationItem {
const factory NotificationItem({
required String? id,
@JsonKey(name: 'user_id') required String? userId,
required Recipient? recipient,
required String? title,
required String? message,
required String? link,
required String? image,
required String? priority,
required String? type,
@JsonKey(name: 'event_type') required String? eventType,
required String? status,
required Map<String, dynamic>? methods,
required Map<String, dynamic>? metadata,
@JsonKey(name: 'schedule_at') required int? scheduleAt,
@JsonKey(name: 'created_at') required int? createdAt,
@JsonKey(name: 'updated_at') required int? updatedAt,
required bool? seen,
@JsonKey(name: 'seen_at') required int? seenAt,
@JsonKey(name: 'is_scheduled') required bool? isScheduled,
@JsonKey(name: 'scheduled_at') required int? scheduledAt,
}) = _NotificationItem;
factory NotificationItem.fromJson(Map<String, Object?> json) =>
_$NotificationItemFromJson(json);
}
@@ -15,7 +15,7 @@ T _$identity<T>(T value) => value;
/// @nodoc /// @nodoc
mixin _$NotificationResponseModel { mixin _$NotificationResponseModel {
bool? get success; String? get message; NotificationData? get data; ErrorModel? get error; bool? get success; String? get message; List<NotificationItem>? get data; ErrorModel? get error; Meta? get meta;
/// Create a copy of NotificationResponseModel /// Create a copy of NotificationResponseModel
/// with the given fields replaced by the non-null parameter values. /// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false) @JsonKey(includeFromJson: false, includeToJson: false)
@@ -28,16 +28,16 @@ $NotificationResponseModelCopyWith<NotificationResponseModel> get copyWith => _$
@override @override
bool operator ==(Object other) { bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is NotificationResponseModel&&(identical(other.success, success) || other.success == success)&&(identical(other.message, message) || other.message == message)&&(identical(other.data, data) || other.data == data)&&(identical(other.error, error) || other.error == error)); return identical(this, other) || (other.runtimeType == runtimeType&&other is NotificationResponseModel&&(identical(other.success, success) || other.success == success)&&(identical(other.message, message) || other.message == message)&&const DeepCollectionEquality().equals(other.data, data)&&(identical(other.error, error) || other.error == error)&&(identical(other.meta, meta) || other.meta == meta));
} }
@JsonKey(includeFromJson: false, includeToJson: false) @JsonKey(includeFromJson: false, includeToJson: false)
@override @override
int get hashCode => Object.hash(runtimeType,success,message,data,error); int get hashCode => Object.hash(runtimeType,success,message,const DeepCollectionEquality().hash(data),error,meta);
@override @override
String toString() { String toString() {
return 'NotificationResponseModel(success: $success, message: $message, data: $data, error: $error)'; return 'NotificationResponseModel(success: $success, message: $message, data: $data, error: $error, meta: $meta)';
} }
@@ -48,11 +48,11 @@ abstract mixin class $NotificationResponseModelCopyWith<$Res> {
factory $NotificationResponseModelCopyWith(NotificationResponseModel value, $Res Function(NotificationResponseModel) _then) = _$NotificationResponseModelCopyWithImpl; factory $NotificationResponseModelCopyWith(NotificationResponseModel value, $Res Function(NotificationResponseModel) _then) = _$NotificationResponseModelCopyWithImpl;
@useResult @useResult
$Res call({ $Res call({
bool? success, String? message, NotificationData? data, ErrorModel? error bool? success, String? message, List<NotificationItem>? data, ErrorModel? error, Meta? meta
}); });
$NotificationDataCopyWith<$Res>? get data;$ErrorModelCopyWith<$Res>? get error; $ErrorModelCopyWith<$Res>? get error;$MetaCopyWith<$Res>? get meta;
} }
/// @nodoc /// @nodoc
@@ -65,31 +65,20 @@ class _$NotificationResponseModelCopyWithImpl<$Res>
/// Create a copy of NotificationResponseModel /// Create a copy of NotificationResponseModel
/// with the given fields replaced by the non-null parameter values. /// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @override $Res call({Object? success = freezed,Object? message = freezed,Object? data = freezed,Object? error = freezed,}) { @pragma('vm:prefer-inline') @override $Res call({Object? success = freezed,Object? message = freezed,Object? data = freezed,Object? error = freezed,Object? meta = freezed,}) {
return _then(_self.copyWith( return _then(_self.copyWith(
success: freezed == success ? _self.success : success // ignore: cast_nullable_to_non_nullable success: freezed == success ? _self.success : success // ignore: cast_nullable_to_non_nullable
as bool?,message: freezed == message ? _self.message : message // ignore: cast_nullable_to_non_nullable as bool?,message: freezed == message ? _self.message : message // ignore: cast_nullable_to_non_nullable
as String?,data: freezed == data ? _self.data : data // ignore: cast_nullable_to_non_nullable as String?,data: freezed == data ? _self.data : data // ignore: cast_nullable_to_non_nullable
as NotificationData?,error: freezed == error ? _self.error : error // ignore: cast_nullable_to_non_nullable as List<NotificationItem>?,error: freezed == error ? _self.error : error // ignore: cast_nullable_to_non_nullable
as ErrorModel?, as ErrorModel?,meta: freezed == meta ? _self.meta : meta // ignore: cast_nullable_to_non_nullable
as Meta?,
)); ));
} }
/// Create a copy of NotificationResponseModel /// Create a copy of NotificationResponseModel
/// with the given fields replaced by the non-null parameter values. /// with the given fields replaced by the non-null parameter values.
@override @override
@pragma('vm:prefer-inline') @pragma('vm:prefer-inline')
$NotificationDataCopyWith<$Res>? get data {
if (_self.data == null) {
return null;
}
return $NotificationDataCopyWith<$Res>(_self.data!, (value) {
return _then(_self.copyWith(data: value));
});
}/// Create a copy of NotificationResponseModel
/// with the given fields replaced by the non-null parameter values.
@override
@pragma('vm:prefer-inline')
$ErrorModelCopyWith<$Res>? get error { $ErrorModelCopyWith<$Res>? get error {
if (_self.error == null) { if (_self.error == null) {
return null; return null;
@@ -98,6 +87,18 @@ $ErrorModelCopyWith<$Res>? get error {
return $ErrorModelCopyWith<$Res>(_self.error!, (value) { return $ErrorModelCopyWith<$Res>(_self.error!, (value) {
return _then(_self.copyWith(error: value)); return _then(_self.copyWith(error: value));
}); });
}/// Create a copy of NotificationResponseModel
/// with the given fields replaced by the non-null parameter values.
@override
@pragma('vm:prefer-inline')
$MetaCopyWith<$Res>? get meta {
if (_self.meta == null) {
return null;
}
return $MetaCopyWith<$Res>(_self.meta!, (value) {
return _then(_self.copyWith(meta: value));
});
} }
} }
@@ -180,10 +181,10 @@ return $default(_that);case _:
/// } /// }
/// ``` /// ```
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( bool? success, String? message, NotificationData? data, ErrorModel? error)? $default,{required TResult orElse(),}) {final _that = this; @optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( bool? success, String? message, List<NotificationItem>? data, ErrorModel? error, Meta? meta)? $default,{required TResult orElse(),}) {final _that = this;
switch (_that) { switch (_that) {
case _NotificationResponseModel() when $default != null: case _NotificationResponseModel() when $default != null:
return $default(_that.success,_that.message,_that.data,_that.error);case _: return $default(_that.success,_that.message,_that.data,_that.error,_that.meta);case _:
return orElse(); return orElse();
} }
@@ -201,10 +202,10 @@ return $default(_that.success,_that.message,_that.data,_that.error);case _:
/// } /// }
/// ``` /// ```
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( bool? success, String? message, NotificationData? data, ErrorModel? error) $default,) {final _that = this; @optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( bool? success, String? message, List<NotificationItem>? data, ErrorModel? error, Meta? meta) $default,) {final _that = this;
switch (_that) { switch (_that) {
case _NotificationResponseModel(): case _NotificationResponseModel():
return $default(_that.success,_that.message,_that.data,_that.error);case _: return $default(_that.success,_that.message,_that.data,_that.error,_that.meta);case _:
throw StateError('Unexpected subclass'); throw StateError('Unexpected subclass');
} }
@@ -221,10 +222,10 @@ return $default(_that.success,_that.message,_that.data,_that.error);case _:
/// } /// }
/// ``` /// ```
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( bool? success, String? message, NotificationData? data, ErrorModel? error)? $default,) {final _that = this; @optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( bool? success, String? message, List<NotificationItem>? data, ErrorModel? error, Meta? meta)? $default,) {final _that = this;
switch (_that) { switch (_that) {
case _NotificationResponseModel() when $default != null: case _NotificationResponseModel() when $default != null:
return $default(_that.success,_that.message,_that.data,_that.error);case _: return $default(_that.success,_that.message,_that.data,_that.error,_that.meta);case _:
return null; return null;
} }
@@ -236,13 +237,22 @@ return $default(_that.success,_that.message,_that.data,_that.error);case _:
@JsonSerializable() @JsonSerializable()
class _NotificationResponseModel implements NotificationResponseModel { class _NotificationResponseModel implements NotificationResponseModel {
const _NotificationResponseModel({required this.success, required this.message, required this.data, required this.error}); const _NotificationResponseModel({required this.success, required this.message, required final List<NotificationItem>? data, required this.error, required this.meta}): _data = data;
factory _NotificationResponseModel.fromJson(Map<String, dynamic> json) => _$NotificationResponseModelFromJson(json); factory _NotificationResponseModel.fromJson(Map<String, dynamic> json) => _$NotificationResponseModelFromJson(json);
@override final bool? success; @override final bool? success;
@override final String? message; @override final String? message;
@override final NotificationData? data; final List<NotificationItem>? _data;
@override List<NotificationItem>? get data {
final value = _data;
if (value == null) return null;
if (_data is EqualUnmodifiableListView) return _data;
// ignore: implicit_dynamic_type
return EqualUnmodifiableListView(value);
}
@override final ErrorModel? error; @override final ErrorModel? error;
@override final Meta? meta;
/// Create a copy of NotificationResponseModel /// Create a copy of NotificationResponseModel
/// with the given fields replaced by the non-null parameter values. /// with the given fields replaced by the non-null parameter values.
@@ -257,16 +267,16 @@ Map<String, dynamic> toJson() {
@override @override
bool operator ==(Object other) { bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _NotificationResponseModel&&(identical(other.success, success) || other.success == success)&&(identical(other.message, message) || other.message == message)&&(identical(other.data, data) || other.data == data)&&(identical(other.error, error) || other.error == error)); return identical(this, other) || (other.runtimeType == runtimeType&&other is _NotificationResponseModel&&(identical(other.success, success) || other.success == success)&&(identical(other.message, message) || other.message == message)&&const DeepCollectionEquality().equals(other._data, _data)&&(identical(other.error, error) || other.error == error)&&(identical(other.meta, meta) || other.meta == meta));
} }
@JsonKey(includeFromJson: false, includeToJson: false) @JsonKey(includeFromJson: false, includeToJson: false)
@override @override
int get hashCode => Object.hash(runtimeType,success,message,data,error); int get hashCode => Object.hash(runtimeType,success,message,const DeepCollectionEquality().hash(_data),error,meta);
@override @override
String toString() { String toString() {
return 'NotificationResponseModel(success: $success, message: $message, data: $data, error: $error)'; return 'NotificationResponseModel(success: $success, message: $message, data: $data, error: $error, meta: $meta)';
} }
@@ -277,11 +287,11 @@ abstract mixin class _$NotificationResponseModelCopyWith<$Res> implements $Notif
factory _$NotificationResponseModelCopyWith(_NotificationResponseModel value, $Res Function(_NotificationResponseModel) _then) = __$NotificationResponseModelCopyWithImpl; factory _$NotificationResponseModelCopyWith(_NotificationResponseModel value, $Res Function(_NotificationResponseModel) _then) = __$NotificationResponseModelCopyWithImpl;
@override @useResult @override @useResult
$Res call({ $Res call({
bool? success, String? message, NotificationData? data, ErrorModel? error bool? success, String? message, List<NotificationItem>? data, ErrorModel? error, Meta? meta
}); });
@override $NotificationDataCopyWith<$Res>? get data;@override $ErrorModelCopyWith<$Res>? get error; @override $ErrorModelCopyWith<$Res>? get error;@override $MetaCopyWith<$Res>? get meta;
} }
/// @nodoc /// @nodoc
@@ -294,13 +304,14 @@ class __$NotificationResponseModelCopyWithImpl<$Res>
/// Create a copy of NotificationResponseModel /// Create a copy of NotificationResponseModel
/// with the given fields replaced by the non-null parameter values. /// with the given fields replaced by the non-null parameter values.
@override @pragma('vm:prefer-inline') $Res call({Object? success = freezed,Object? message = freezed,Object? data = freezed,Object? error = freezed,}) { @override @pragma('vm:prefer-inline') $Res call({Object? success = freezed,Object? message = freezed,Object? data = freezed,Object? error = freezed,Object? meta = freezed,}) {
return _then(_NotificationResponseModel( return _then(_NotificationResponseModel(
success: freezed == success ? _self.success : success // ignore: cast_nullable_to_non_nullable success: freezed == success ? _self.success : success // ignore: cast_nullable_to_non_nullable
as bool?,message: freezed == message ? _self.message : message // ignore: cast_nullable_to_non_nullable as bool?,message: freezed == message ? _self.message : message // ignore: cast_nullable_to_non_nullable
as String?,data: freezed == data ? _self.data : data // ignore: cast_nullable_to_non_nullable as String?,data: freezed == data ? _self._data : data // ignore: cast_nullable_to_non_nullable
as NotificationData?,error: freezed == error ? _self.error : error // ignore: cast_nullable_to_non_nullable as List<NotificationItem>?,error: freezed == error ? _self.error : error // ignore: cast_nullable_to_non_nullable
as ErrorModel?, as ErrorModel?,meta: freezed == meta ? _self.meta : meta // ignore: cast_nullable_to_non_nullable
as Meta?,
)); ));
} }
@@ -308,18 +319,6 @@ as ErrorModel?,
/// with the given fields replaced by the non-null parameter values. /// with the given fields replaced by the non-null parameter values.
@override @override
@pragma('vm:prefer-inline') @pragma('vm:prefer-inline')
$NotificationDataCopyWith<$Res>? get data {
if (_self.data == null) {
return null;
}
return $NotificationDataCopyWith<$Res>(_self.data!, (value) {
return _then(_self.copyWith(data: value));
});
}/// Create a copy of NotificationResponseModel
/// with the given fields replaced by the non-null parameter values.
@override
@pragma('vm:prefer-inline')
$ErrorModelCopyWith<$Res>? get error { $ErrorModelCopyWith<$Res>? get error {
if (_self.error == null) { if (_self.error == null) {
return null; return null;
@@ -328,6 +327,380 @@ $ErrorModelCopyWith<$Res>? get error {
return $ErrorModelCopyWith<$Res>(_self.error!, (value) { return $ErrorModelCopyWith<$Res>(_self.error!, (value) {
return _then(_self.copyWith(error: value)); return _then(_self.copyWith(error: value));
}); });
}/// Create a copy of NotificationResponseModel
/// with the given fields replaced by the non-null parameter values.
@override
@pragma('vm:prefer-inline')
$MetaCopyWith<$Res>? get meta {
if (_self.meta == null) {
return null;
}
return $MetaCopyWith<$Res>(_self.meta!, (value) {
return _then(_self.copyWith(meta: value));
});
}
}
/// @nodoc
mixin _$NotificationItem {
String? get id;@JsonKey(name: 'user_id') String? get userId; Recipient? get recipient;// ✅ اضافه شد
String? get title; String? get message; String? get link; String? get image; String? get priority; String? get type;@JsonKey(name: 'event_type') String? get eventType; String? get status; Map<String, dynamic>? get methods; Map<String, dynamic>? get metadata;@JsonKey(name: 'schedule_at') int? get scheduleAt;@JsonKey(name: 'created_at') int? get createdAt;@JsonKey(name: 'updated_at') int? get updatedAt; bool? get seen;@JsonKey(name: 'seen_at') int? get seenAt;@JsonKey(name: 'is_scheduled') bool? get isScheduled;@JsonKey(name: 'scheduled_at') int? get scheduledAt;
/// Create a copy of NotificationItem
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
$NotificationItemCopyWith<NotificationItem> get copyWith => _$NotificationItemCopyWithImpl<NotificationItem>(this as NotificationItem, _$identity);
/// Serializes this NotificationItem to a JSON map.
Map<String, dynamic> toJson();
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is NotificationItem&&(identical(other.id, id) || other.id == id)&&(identical(other.userId, userId) || other.userId == userId)&&(identical(other.recipient, recipient) || other.recipient == recipient)&&(identical(other.title, title) || other.title == title)&&(identical(other.message, message) || other.message == message)&&(identical(other.link, link) || other.link == link)&&(identical(other.image, image) || other.image == image)&&(identical(other.priority, priority) || other.priority == priority)&&(identical(other.type, type) || other.type == type)&&(identical(other.eventType, eventType) || other.eventType == eventType)&&(identical(other.status, status) || other.status == status)&&const DeepCollectionEquality().equals(other.methods, methods)&&const DeepCollectionEquality().equals(other.metadata, metadata)&&(identical(other.scheduleAt, scheduleAt) || other.scheduleAt == scheduleAt)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.updatedAt, updatedAt) || other.updatedAt == updatedAt)&&(identical(other.seen, seen) || other.seen == seen)&&(identical(other.seenAt, seenAt) || other.seenAt == seenAt)&&(identical(other.isScheduled, isScheduled) || other.isScheduled == isScheduled)&&(identical(other.scheduledAt, scheduledAt) || other.scheduledAt == scheduledAt));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hashAll([runtimeType,id,userId,recipient,title,message,link,image,priority,type,eventType,status,const DeepCollectionEquality().hash(methods),const DeepCollectionEquality().hash(metadata),scheduleAt,createdAt,updatedAt,seen,seenAt,isScheduled,scheduledAt]);
@override
String toString() {
return 'NotificationItem(id: $id, userId: $userId, recipient: $recipient, title: $title, message: $message, link: $link, image: $image, priority: $priority, type: $type, eventType: $eventType, status: $status, methods: $methods, metadata: $metadata, scheduleAt: $scheduleAt, createdAt: $createdAt, updatedAt: $updatedAt, seen: $seen, seenAt: $seenAt, isScheduled: $isScheduled, scheduledAt: $scheduledAt)';
}
}
/// @nodoc
abstract mixin class $NotificationItemCopyWith<$Res> {
factory $NotificationItemCopyWith(NotificationItem value, $Res Function(NotificationItem) _then) = _$NotificationItemCopyWithImpl;
@useResult
$Res call({
String? id,@JsonKey(name: 'user_id') String? userId, Recipient? recipient, String? title, String? message, String? link, String? image, String? priority, String? type,@JsonKey(name: 'event_type') String? eventType, String? status, Map<String, dynamic>? methods, Map<String, dynamic>? metadata,@JsonKey(name: 'schedule_at') int? scheduleAt,@JsonKey(name: 'created_at') int? createdAt,@JsonKey(name: 'updated_at') int? updatedAt, bool? seen,@JsonKey(name: 'seen_at') int? seenAt,@JsonKey(name: 'is_scheduled') bool? isScheduled,@JsonKey(name: 'scheduled_at') int? scheduledAt
});
$RecipientCopyWith<$Res>? get recipient;
}
/// @nodoc
class _$NotificationItemCopyWithImpl<$Res>
implements $NotificationItemCopyWith<$Res> {
_$NotificationItemCopyWithImpl(this._self, this._then);
final NotificationItem _self;
final $Res Function(NotificationItem) _then;
/// Create a copy of NotificationItem
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @override $Res call({Object? id = freezed,Object? userId = freezed,Object? recipient = freezed,Object? title = freezed,Object? message = freezed,Object? link = freezed,Object? image = freezed,Object? priority = freezed,Object? type = freezed,Object? eventType = freezed,Object? status = freezed,Object? methods = freezed,Object? metadata = freezed,Object? scheduleAt = freezed,Object? createdAt = freezed,Object? updatedAt = freezed,Object? seen = freezed,Object? seenAt = freezed,Object? isScheduled = freezed,Object? scheduledAt = freezed,}) {
return _then(_self.copyWith(
id: freezed == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
as String?,userId: freezed == userId ? _self.userId : userId // ignore: cast_nullable_to_non_nullable
as String?,recipient: freezed == recipient ? _self.recipient : recipient // ignore: cast_nullable_to_non_nullable
as Recipient?,title: freezed == title ? _self.title : title // ignore: cast_nullable_to_non_nullable
as String?,message: freezed == message ? _self.message : message // ignore: cast_nullable_to_non_nullable
as String?,link: freezed == link ? _self.link : link // ignore: cast_nullable_to_non_nullable
as String?,image: freezed == image ? _self.image : image // ignore: cast_nullable_to_non_nullable
as String?,priority: freezed == priority ? _self.priority : priority // ignore: cast_nullable_to_non_nullable
as String?,type: freezed == type ? _self.type : type // ignore: cast_nullable_to_non_nullable
as String?,eventType: freezed == eventType ? _self.eventType : eventType // ignore: cast_nullable_to_non_nullable
as String?,status: freezed == status ? _self.status : status // ignore: cast_nullable_to_non_nullable
as String?,methods: freezed == methods ? _self.methods : methods // ignore: cast_nullable_to_non_nullable
as Map<String, dynamic>?,metadata: freezed == metadata ? _self.metadata : metadata // ignore: cast_nullable_to_non_nullable
as Map<String, dynamic>?,scheduleAt: freezed == scheduleAt ? _self.scheduleAt : scheduleAt // ignore: cast_nullable_to_non_nullable
as int?,createdAt: freezed == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable
as int?,updatedAt: freezed == updatedAt ? _self.updatedAt : updatedAt // ignore: cast_nullable_to_non_nullable
as int?,seen: freezed == seen ? _self.seen : seen // ignore: cast_nullable_to_non_nullable
as bool?,seenAt: freezed == seenAt ? _self.seenAt : seenAt // ignore: cast_nullable_to_non_nullable
as int?,isScheduled: freezed == isScheduled ? _self.isScheduled : isScheduled // ignore: cast_nullable_to_non_nullable
as bool?,scheduledAt: freezed == scheduledAt ? _self.scheduledAt : scheduledAt // ignore: cast_nullable_to_non_nullable
as int?,
));
}
/// Create a copy of NotificationItem
/// with the given fields replaced by the non-null parameter values.
@override
@pragma('vm:prefer-inline')
$RecipientCopyWith<$Res>? get recipient {
if (_self.recipient == null) {
return null;
}
return $RecipientCopyWith<$Res>(_self.recipient!, (value) {
return _then(_self.copyWith(recipient: value));
});
}
}
/// Adds pattern-matching-related methods to [NotificationItem].
extension NotificationItemPatterns on NotificationItem {
/// A variant of `map` that fallback to returning `orElse`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs TResult maybeMap<TResult extends Object?>(TResult Function( _NotificationItem value)? $default,{required TResult orElse(),}){
final _that = this;
switch (_that) {
case _NotificationItem() when $default != null:
return $default(_that);case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// Callbacks receives the raw object, upcasted.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case final Subclass2 value:
/// return ...;
/// }
/// ```
@optionalTypeArgs TResult map<TResult extends Object?>(TResult Function( _NotificationItem value) $default,){
final _that = this;
switch (_that) {
case _NotificationItem():
return $default(_that);case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `map` that fallback to returning `null`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>(TResult? Function( _NotificationItem value)? $default,){
final _that = this;
switch (_that) {
case _NotificationItem() when $default != null:
return $default(_that);case _:
return null;
}
}
/// A variant of `when` that fallback to an `orElse` callback.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String? id, @JsonKey(name: 'user_id') String? userId, Recipient? recipient, String? title, String? message, String? link, String? image, String? priority, String? type, @JsonKey(name: 'event_type') String? eventType, String? status, Map<String, dynamic>? methods, Map<String, dynamic>? metadata, @JsonKey(name: 'schedule_at') int? scheduleAt, @JsonKey(name: 'created_at') int? createdAt, @JsonKey(name: 'updated_at') int? updatedAt, bool? seen, @JsonKey(name: 'seen_at') int? seenAt, @JsonKey(name: 'is_scheduled') bool? isScheduled, @JsonKey(name: 'scheduled_at') int? scheduledAt)? $default,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _NotificationItem() when $default != null:
return $default(_that.id,_that.userId,_that.recipient,_that.title,_that.message,_that.link,_that.image,_that.priority,_that.type,_that.eventType,_that.status,_that.methods,_that.metadata,_that.scheduleAt,_that.createdAt,_that.updatedAt,_that.seen,_that.seenAt,_that.isScheduled,_that.scheduledAt);case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// As opposed to `map`, this offers destructuring.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case Subclass2(:final field2):
/// return ...;
/// }
/// ```
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String? id, @JsonKey(name: 'user_id') String? userId, Recipient? recipient, String? title, String? message, String? link, String? image, String? priority, String? type, @JsonKey(name: 'event_type') String? eventType, String? status, Map<String, dynamic>? methods, Map<String, dynamic>? metadata, @JsonKey(name: 'schedule_at') int? scheduleAt, @JsonKey(name: 'created_at') int? createdAt, @JsonKey(name: 'updated_at') int? updatedAt, bool? seen, @JsonKey(name: 'seen_at') int? seenAt, @JsonKey(name: 'is_scheduled') bool? isScheduled, @JsonKey(name: 'scheduled_at') int? scheduledAt) $default,) {final _that = this;
switch (_that) {
case _NotificationItem():
return $default(_that.id,_that.userId,_that.recipient,_that.title,_that.message,_that.link,_that.image,_that.priority,_that.type,_that.eventType,_that.status,_that.methods,_that.metadata,_that.scheduleAt,_that.createdAt,_that.updatedAt,_that.seen,_that.seenAt,_that.isScheduled,_that.scheduledAt);case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `when` that fallback to returning `null`
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String? id, @JsonKey(name: 'user_id') String? userId, Recipient? recipient, String? title, String? message, String? link, String? image, String? priority, String? type, @JsonKey(name: 'event_type') String? eventType, String? status, Map<String, dynamic>? methods, Map<String, dynamic>? metadata, @JsonKey(name: 'schedule_at') int? scheduleAt, @JsonKey(name: 'created_at') int? createdAt, @JsonKey(name: 'updated_at') int? updatedAt, bool? seen, @JsonKey(name: 'seen_at') int? seenAt, @JsonKey(name: 'is_scheduled') bool? isScheduled, @JsonKey(name: 'scheduled_at') int? scheduledAt)? $default,) {final _that = this;
switch (_that) {
case _NotificationItem() when $default != null:
return $default(_that.id,_that.userId,_that.recipient,_that.title,_that.message,_that.link,_that.image,_that.priority,_that.type,_that.eventType,_that.status,_that.methods,_that.metadata,_that.scheduleAt,_that.createdAt,_that.updatedAt,_that.seen,_that.seenAt,_that.isScheduled,_that.scheduledAt);case _:
return null;
}
}
}
/// @nodoc
@JsonSerializable()
class _NotificationItem implements NotificationItem {
const _NotificationItem({required this.id, @JsonKey(name: 'user_id') required this.userId, required this.recipient, required this.title, required this.message, required this.link, required this.image, required this.priority, required this.type, @JsonKey(name: 'event_type') required this.eventType, required this.status, required final Map<String, dynamic>? methods, required final Map<String, dynamic>? metadata, @JsonKey(name: 'schedule_at') required this.scheduleAt, @JsonKey(name: 'created_at') required this.createdAt, @JsonKey(name: 'updated_at') required this.updatedAt, required this.seen, @JsonKey(name: 'seen_at') required this.seenAt, @JsonKey(name: 'is_scheduled') required this.isScheduled, @JsonKey(name: 'scheduled_at') required this.scheduledAt}): _methods = methods,_metadata = metadata;
factory _NotificationItem.fromJson(Map<String, dynamic> json) => _$NotificationItemFromJson(json);
@override final String? id;
@override@JsonKey(name: 'user_id') final String? userId;
@override final Recipient? recipient;
// ✅ اضافه شد
@override final String? title;
@override final String? message;
@override final String? link;
@override final String? image;
@override final String? priority;
@override final String? type;
@override@JsonKey(name: 'event_type') final String? eventType;
@override final String? status;
final Map<String, dynamic>? _methods;
@override Map<String, dynamic>? get methods {
final value = _methods;
if (value == null) return null;
if (_methods is EqualUnmodifiableMapView) return _methods;
// ignore: implicit_dynamic_type
return EqualUnmodifiableMapView(value);
}
final Map<String, dynamic>? _metadata;
@override Map<String, dynamic>? get metadata {
final value = _metadata;
if (value == null) return null;
if (_metadata is EqualUnmodifiableMapView) return _metadata;
// ignore: implicit_dynamic_type
return EqualUnmodifiableMapView(value);
}
@override@JsonKey(name: 'schedule_at') final int? scheduleAt;
@override@JsonKey(name: 'created_at') final int? createdAt;
@override@JsonKey(name: 'updated_at') final int? updatedAt;
@override final bool? seen;
@override@JsonKey(name: 'seen_at') final int? seenAt;
@override@JsonKey(name: 'is_scheduled') final bool? isScheduled;
@override@JsonKey(name: 'scheduled_at') final int? scheduledAt;
/// Create a copy of NotificationItem
/// with the given fields replaced by the non-null parameter values.
@override @JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
_$NotificationItemCopyWith<_NotificationItem> get copyWith => __$NotificationItemCopyWithImpl<_NotificationItem>(this, _$identity);
@override
Map<String, dynamic> toJson() {
return _$NotificationItemToJson(this, );
}
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _NotificationItem&&(identical(other.id, id) || other.id == id)&&(identical(other.userId, userId) || other.userId == userId)&&(identical(other.recipient, recipient) || other.recipient == recipient)&&(identical(other.title, title) || other.title == title)&&(identical(other.message, message) || other.message == message)&&(identical(other.link, link) || other.link == link)&&(identical(other.image, image) || other.image == image)&&(identical(other.priority, priority) || other.priority == priority)&&(identical(other.type, type) || other.type == type)&&(identical(other.eventType, eventType) || other.eventType == eventType)&&(identical(other.status, status) || other.status == status)&&const DeepCollectionEquality().equals(other._methods, _methods)&&const DeepCollectionEquality().equals(other._metadata, _metadata)&&(identical(other.scheduleAt, scheduleAt) || other.scheduleAt == scheduleAt)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.updatedAt, updatedAt) || other.updatedAt == updatedAt)&&(identical(other.seen, seen) || other.seen == seen)&&(identical(other.seenAt, seenAt) || other.seenAt == seenAt)&&(identical(other.isScheduled, isScheduled) || other.isScheduled == isScheduled)&&(identical(other.scheduledAt, scheduledAt) || other.scheduledAt == scheduledAt));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hashAll([runtimeType,id,userId,recipient,title,message,link,image,priority,type,eventType,status,const DeepCollectionEquality().hash(_methods),const DeepCollectionEquality().hash(_metadata),scheduleAt,createdAt,updatedAt,seen,seenAt,isScheduled,scheduledAt]);
@override
String toString() {
return 'NotificationItem(id: $id, userId: $userId, recipient: $recipient, title: $title, message: $message, link: $link, image: $image, priority: $priority, type: $type, eventType: $eventType, status: $status, methods: $methods, metadata: $metadata, scheduleAt: $scheduleAt, createdAt: $createdAt, updatedAt: $updatedAt, seen: $seen, seenAt: $seenAt, isScheduled: $isScheduled, scheduledAt: $scheduledAt)';
}
}
/// @nodoc
abstract mixin class _$NotificationItemCopyWith<$Res> implements $NotificationItemCopyWith<$Res> {
factory _$NotificationItemCopyWith(_NotificationItem value, $Res Function(_NotificationItem) _then) = __$NotificationItemCopyWithImpl;
@override @useResult
$Res call({
String? id,@JsonKey(name: 'user_id') String? userId, Recipient? recipient, String? title, String? message, String? link, String? image, String? priority, String? type,@JsonKey(name: 'event_type') String? eventType, String? status, Map<String, dynamic>? methods, Map<String, dynamic>? metadata,@JsonKey(name: 'schedule_at') int? scheduleAt,@JsonKey(name: 'created_at') int? createdAt,@JsonKey(name: 'updated_at') int? updatedAt, bool? seen,@JsonKey(name: 'seen_at') int? seenAt,@JsonKey(name: 'is_scheduled') bool? isScheduled,@JsonKey(name: 'scheduled_at') int? scheduledAt
});
@override $RecipientCopyWith<$Res>? get recipient;
}
/// @nodoc
class __$NotificationItemCopyWithImpl<$Res>
implements _$NotificationItemCopyWith<$Res> {
__$NotificationItemCopyWithImpl(this._self, this._then);
final _NotificationItem _self;
final $Res Function(_NotificationItem) _then;
/// Create a copy of NotificationItem
/// with the given fields replaced by the non-null parameter values.
@override @pragma('vm:prefer-inline') $Res call({Object? id = freezed,Object? userId = freezed,Object? recipient = freezed,Object? title = freezed,Object? message = freezed,Object? link = freezed,Object? image = freezed,Object? priority = freezed,Object? type = freezed,Object? eventType = freezed,Object? status = freezed,Object? methods = freezed,Object? metadata = freezed,Object? scheduleAt = freezed,Object? createdAt = freezed,Object? updatedAt = freezed,Object? seen = freezed,Object? seenAt = freezed,Object? isScheduled = freezed,Object? scheduledAt = freezed,}) {
return _then(_NotificationItem(
id: freezed == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
as String?,userId: freezed == userId ? _self.userId : userId // ignore: cast_nullable_to_non_nullable
as String?,recipient: freezed == recipient ? _self.recipient : recipient // ignore: cast_nullable_to_non_nullable
as Recipient?,title: freezed == title ? _self.title : title // ignore: cast_nullable_to_non_nullable
as String?,message: freezed == message ? _self.message : message // ignore: cast_nullable_to_non_nullable
as String?,link: freezed == link ? _self.link : link // ignore: cast_nullable_to_non_nullable
as String?,image: freezed == image ? _self.image : image // ignore: cast_nullable_to_non_nullable
as String?,priority: freezed == priority ? _self.priority : priority // ignore: cast_nullable_to_non_nullable
as String?,type: freezed == type ? _self.type : type // ignore: cast_nullable_to_non_nullable
as String?,eventType: freezed == eventType ? _self.eventType : eventType // ignore: cast_nullable_to_non_nullable
as String?,status: freezed == status ? _self.status : status // ignore: cast_nullable_to_non_nullable
as String?,methods: freezed == methods ? _self._methods : methods // ignore: cast_nullable_to_non_nullable
as Map<String, dynamic>?,metadata: freezed == metadata ? _self._metadata : metadata // ignore: cast_nullable_to_non_nullable
as Map<String, dynamic>?,scheduleAt: freezed == scheduleAt ? _self.scheduleAt : scheduleAt // ignore: cast_nullable_to_non_nullable
as int?,createdAt: freezed == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable
as int?,updatedAt: freezed == updatedAt ? _self.updatedAt : updatedAt // ignore: cast_nullable_to_non_nullable
as int?,seen: freezed == seen ? _self.seen : seen // ignore: cast_nullable_to_non_nullable
as bool?,seenAt: freezed == seenAt ? _self.seenAt : seenAt // ignore: cast_nullable_to_non_nullable
as int?,isScheduled: freezed == isScheduled ? _self.isScheduled : isScheduled // ignore: cast_nullable_to_non_nullable
as bool?,scheduledAt: freezed == scheduledAt ? _self.scheduledAt : scheduledAt // ignore: cast_nullable_to_non_nullable
as int?,
));
}
/// Create a copy of NotificationItem
/// with the given fields replaced by the non-null parameter values.
@override
@pragma('vm:prefer-inline')
$RecipientCopyWith<$Res>? get recipient {
if (_self.recipient == null) {
return null;
}
return $RecipientCopyWith<$Res>(_self.recipient!, (value) {
return _then(_self.copyWith(recipient: value));
});
} }
} }
@@ -12,13 +12,17 @@ _NotificationResponseModel _$NotificationResponseModelFromJson(
success: json['success'] as bool?, success: json['success'] as bool?,
message: json['message'] as String?, message: json['message'] as String?,
data: data:
json['data'] == null (json['data'] as List<dynamic>?)
? null ?.map((e) => NotificationItem.fromJson(e as Map<String, dynamic>))
: NotificationData.fromJson(json['data'] as Map<String, dynamic>), .toList(),
error: error:
json['error'] == null json['error'] == null
? null ? null
: ErrorModel.fromJson(json['error'] as Map<String, dynamic>), : ErrorModel.fromJson(json['error'] as Map<String, dynamic>),
meta:
json['meta'] == null
? null
: Meta.fromJson(json['meta'] as Map<String, dynamic>),
); );
Map<String, dynamic> _$NotificationResponseModelToJson( Map<String, dynamic> _$NotificationResponseModelToJson(
@@ -28,4 +32,56 @@ Map<String, dynamic> _$NotificationResponseModelToJson(
'message': instance.message, 'message': instance.message,
'data': instance.data, 'data': instance.data,
'error': instance.error, 'error': instance.error,
'meta': instance.meta,
}; };
_NotificationItem _$NotificationItemFromJson(Map<String, dynamic> json) =>
_NotificationItem(
id: json['id'] as String?,
userId: json['user_id'] as String?,
recipient:
json['recipient'] == null
? null
: Recipient.fromJson(json['recipient'] as Map<String, dynamic>),
title: json['title'] as String?,
message: json['message'] as String?,
link: json['link'] as String?,
image: json['image'] as String?,
priority: json['priority'] as String?,
type: json['type'] as String?,
eventType: json['event_type'] as String?,
status: json['status'] as String?,
methods: json['methods'] as Map<String, dynamic>?,
metadata: json['metadata'] as Map<String, dynamic>?,
scheduleAt: (json['schedule_at'] as num?)?.toInt(),
createdAt: (json['created_at'] as num?)?.toInt(),
updatedAt: (json['updated_at'] as num?)?.toInt(),
seen: json['seen'] as bool?,
seenAt: (json['seen_at'] as num?)?.toInt(),
isScheduled: json['is_scheduled'] as bool?,
scheduledAt: (json['scheduled_at'] as num?)?.toInt(),
);
Map<String, dynamic> _$NotificationItemToJson(_NotificationItem instance) =>
<String, dynamic>{
'id': instance.id,
'user_id': instance.userId,
'recipient': instance.recipient,
'title': instance.title,
'message': instance.message,
'link': instance.link,
'image': instance.image,
'priority': instance.priority,
'type': instance.type,
'event_type': instance.eventType,
'status': instance.status,
'methods': instance.methods,
'metadata': instance.metadata,
'schedule_at': instance.scheduleAt,
'created_at': instance.createdAt,
'updated_at': instance.updatedAt,
'seen': instance.seen,
'seen_at': instance.seenAt,
'is_scheduled': instance.isScheduled,
'scheduled_at': instance.scheduledAt,
};
@@ -1,46 +0,0 @@
// ignore_for_file: invalid_annotation_target
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:tm_app/data/services/model/meta/meta.dart';
part 'notification_data.freezed.dart';
part 'notification_data.g.dart';
@freezed
abstract class NotificationData with _$NotificationData {
const factory NotificationData({
required List<NotificationItem>? notifications,
required Meta? meta,
}) = _NotificationData;
factory NotificationData.fromJson(Map<String, Object?> json) =>
_$NotificationDataFromJson(json);
}
@freezed
abstract class NotificationItem with _$NotificationItem {
const factory NotificationItem({
required String? id,
@JsonKey(name: 'user_id') required String? userId,
required String? title,
required String? message,
required String? link,
required String? image,
required String? priority,
required String? type,
@JsonKey(name: 'event_type') required String? eventType,
required String? status,
required Map<String, dynamic>? methods,
required Map<String, dynamic>? metadata,
@JsonKey(name: 'schedule_at') required int? scheduleAt,
@JsonKey(name: 'created_at') required String? createdAt,
@JsonKey(name: 'updated_at') required String? updatedAt,
required bool? seen,
@JsonKey(name: 'seen_at') required int? seenAt,
@JsonKey(name: 'is_scheduled') required bool? isScheduled,
@JsonKey(name: 'scheduled_at') required int? scheduledAt,
}) = _NotificationItem;
factory NotificationItem.fromJson(Map<String, Object?> json) =>
_$NotificationItemFromJson(json);
}
@@ -1,645 +0,0 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
// coverage:ignore-file
// ignore_for_file: type=lint
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
part of 'notification_data.dart';
// **************************************************************************
// FreezedGenerator
// **************************************************************************
// dart format off
T _$identity<T>(T value) => value;
/// @nodoc
mixin _$NotificationData {
List<NotificationItem>? get notifications; Meta? get meta;
/// Create a copy of NotificationData
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
$NotificationDataCopyWith<NotificationData> get copyWith => _$NotificationDataCopyWithImpl<NotificationData>(this as NotificationData, _$identity);
/// Serializes this NotificationData to a JSON map.
Map<String, dynamic> toJson();
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is NotificationData&&const DeepCollectionEquality().equals(other.notifications, notifications)&&(identical(other.meta, meta) || other.meta == meta));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(runtimeType,const DeepCollectionEquality().hash(notifications),meta);
@override
String toString() {
return 'NotificationData(notifications: $notifications, meta: $meta)';
}
}
/// @nodoc
abstract mixin class $NotificationDataCopyWith<$Res> {
factory $NotificationDataCopyWith(NotificationData value, $Res Function(NotificationData) _then) = _$NotificationDataCopyWithImpl;
@useResult
$Res call({
List<NotificationItem>? notifications, Meta? meta
});
$MetaCopyWith<$Res>? get meta;
}
/// @nodoc
class _$NotificationDataCopyWithImpl<$Res>
implements $NotificationDataCopyWith<$Res> {
_$NotificationDataCopyWithImpl(this._self, this._then);
final NotificationData _self;
final $Res Function(NotificationData) _then;
/// Create a copy of NotificationData
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @override $Res call({Object? notifications = freezed,Object? meta = freezed,}) {
return _then(_self.copyWith(
notifications: freezed == notifications ? _self.notifications : notifications // ignore: cast_nullable_to_non_nullable
as List<NotificationItem>?,meta: freezed == meta ? _self.meta : meta // ignore: cast_nullable_to_non_nullable
as Meta?,
));
}
/// Create a copy of NotificationData
/// with the given fields replaced by the non-null parameter values.
@override
@pragma('vm:prefer-inline')
$MetaCopyWith<$Res>? get meta {
if (_self.meta == null) {
return null;
}
return $MetaCopyWith<$Res>(_self.meta!, (value) {
return _then(_self.copyWith(meta: value));
});
}
}
/// Adds pattern-matching-related methods to [NotificationData].
extension NotificationDataPatterns on NotificationData {
/// A variant of `map` that fallback to returning `orElse`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs TResult maybeMap<TResult extends Object?>(TResult Function( _NotificationData value)? $default,{required TResult orElse(),}){
final _that = this;
switch (_that) {
case _NotificationData() when $default != null:
return $default(_that);case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// Callbacks receives the raw object, upcasted.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case final Subclass2 value:
/// return ...;
/// }
/// ```
@optionalTypeArgs TResult map<TResult extends Object?>(TResult Function( _NotificationData value) $default,){
final _that = this;
switch (_that) {
case _NotificationData():
return $default(_that);case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `map` that fallback to returning `null`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>(TResult? Function( _NotificationData value)? $default,){
final _that = this;
switch (_that) {
case _NotificationData() when $default != null:
return $default(_that);case _:
return null;
}
}
/// A variant of `when` that fallback to an `orElse` callback.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( List<NotificationItem>? notifications, Meta? meta)? $default,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _NotificationData() when $default != null:
return $default(_that.notifications,_that.meta);case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// As opposed to `map`, this offers destructuring.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case Subclass2(:final field2):
/// return ...;
/// }
/// ```
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( List<NotificationItem>? notifications, Meta? meta) $default,) {final _that = this;
switch (_that) {
case _NotificationData():
return $default(_that.notifications,_that.meta);case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `when` that fallback to returning `null`
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( List<NotificationItem>? notifications, Meta? meta)? $default,) {final _that = this;
switch (_that) {
case _NotificationData() when $default != null:
return $default(_that.notifications,_that.meta);case _:
return null;
}
}
}
/// @nodoc
@JsonSerializable()
class _NotificationData implements NotificationData {
const _NotificationData({required final List<NotificationItem>? notifications, required this.meta}): _notifications = notifications;
factory _NotificationData.fromJson(Map<String, dynamic> json) => _$NotificationDataFromJson(json);
final List<NotificationItem>? _notifications;
@override List<NotificationItem>? get notifications {
final value = _notifications;
if (value == null) return null;
if (_notifications is EqualUnmodifiableListView) return _notifications;
// ignore: implicit_dynamic_type
return EqualUnmodifiableListView(value);
}
@override final Meta? meta;
/// Create a copy of NotificationData
/// with the given fields replaced by the non-null parameter values.
@override @JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
_$NotificationDataCopyWith<_NotificationData> get copyWith => __$NotificationDataCopyWithImpl<_NotificationData>(this, _$identity);
@override
Map<String, dynamic> toJson() {
return _$NotificationDataToJson(this, );
}
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _NotificationData&&const DeepCollectionEquality().equals(other._notifications, _notifications)&&(identical(other.meta, meta) || other.meta == meta));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(runtimeType,const DeepCollectionEquality().hash(_notifications),meta);
@override
String toString() {
return 'NotificationData(notifications: $notifications, meta: $meta)';
}
}
/// @nodoc
abstract mixin class _$NotificationDataCopyWith<$Res> implements $NotificationDataCopyWith<$Res> {
factory _$NotificationDataCopyWith(_NotificationData value, $Res Function(_NotificationData) _then) = __$NotificationDataCopyWithImpl;
@override @useResult
$Res call({
List<NotificationItem>? notifications, Meta? meta
});
@override $MetaCopyWith<$Res>? get meta;
}
/// @nodoc
class __$NotificationDataCopyWithImpl<$Res>
implements _$NotificationDataCopyWith<$Res> {
__$NotificationDataCopyWithImpl(this._self, this._then);
final _NotificationData _self;
final $Res Function(_NotificationData) _then;
/// Create a copy of NotificationData
/// with the given fields replaced by the non-null parameter values.
@override @pragma('vm:prefer-inline') $Res call({Object? notifications = freezed,Object? meta = freezed,}) {
return _then(_NotificationData(
notifications: freezed == notifications ? _self._notifications : notifications // ignore: cast_nullable_to_non_nullable
as List<NotificationItem>?,meta: freezed == meta ? _self.meta : meta // ignore: cast_nullable_to_non_nullable
as Meta?,
));
}
/// Create a copy of NotificationData
/// with the given fields replaced by the non-null parameter values.
@override
@pragma('vm:prefer-inline')
$MetaCopyWith<$Res>? get meta {
if (_self.meta == null) {
return null;
}
return $MetaCopyWith<$Res>(_self.meta!, (value) {
return _then(_self.copyWith(meta: value));
});
}
}
/// @nodoc
mixin _$NotificationItem {
String? get id;@JsonKey(name: 'user_id') String? get userId; String? get title; String? get message; String? get link; String? get image; String? get priority; String? get type;@JsonKey(name: 'event_type') String? get eventType; String? get status; Map<String, dynamic>? get methods; Map<String, dynamic>? get metadata;@JsonKey(name: 'schedule_at') int? get scheduleAt;@JsonKey(name: 'created_at') String? get createdAt;@JsonKey(name: 'updated_at') String? get updatedAt; bool? get seen;@JsonKey(name: 'seen_at') int? get seenAt;@JsonKey(name: 'is_scheduled') bool? get isScheduled;@JsonKey(name: 'scheduled_at') int? get scheduledAt;
/// Create a copy of NotificationItem
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
$NotificationItemCopyWith<NotificationItem> get copyWith => _$NotificationItemCopyWithImpl<NotificationItem>(this as NotificationItem, _$identity);
/// Serializes this NotificationItem to a JSON map.
Map<String, dynamic> toJson();
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is NotificationItem&&(identical(other.id, id) || other.id == id)&&(identical(other.userId, userId) || other.userId == userId)&&(identical(other.title, title) || other.title == title)&&(identical(other.message, message) || other.message == message)&&(identical(other.link, link) || other.link == link)&&(identical(other.image, image) || other.image == image)&&(identical(other.priority, priority) || other.priority == priority)&&(identical(other.type, type) || other.type == type)&&(identical(other.eventType, eventType) || other.eventType == eventType)&&(identical(other.status, status) || other.status == status)&&const DeepCollectionEquality().equals(other.methods, methods)&&const DeepCollectionEquality().equals(other.metadata, metadata)&&(identical(other.scheduleAt, scheduleAt) || other.scheduleAt == scheduleAt)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.updatedAt, updatedAt) || other.updatedAt == updatedAt)&&(identical(other.seen, seen) || other.seen == seen)&&(identical(other.seenAt, seenAt) || other.seenAt == seenAt)&&(identical(other.isScheduled, isScheduled) || other.isScheduled == isScheduled)&&(identical(other.scheduledAt, scheduledAt) || other.scheduledAt == scheduledAt));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hashAll([runtimeType,id,userId,title,message,link,image,priority,type,eventType,status,const DeepCollectionEquality().hash(methods),const DeepCollectionEquality().hash(metadata),scheduleAt,createdAt,updatedAt,seen,seenAt,isScheduled,scheduledAt]);
@override
String toString() {
return 'NotificationItem(id: $id, userId: $userId, title: $title, message: $message, link: $link, image: $image, priority: $priority, type: $type, eventType: $eventType, status: $status, methods: $methods, metadata: $metadata, scheduleAt: $scheduleAt, createdAt: $createdAt, updatedAt: $updatedAt, seen: $seen, seenAt: $seenAt, isScheduled: $isScheduled, scheduledAt: $scheduledAt)';
}
}
/// @nodoc
abstract mixin class $NotificationItemCopyWith<$Res> {
factory $NotificationItemCopyWith(NotificationItem value, $Res Function(NotificationItem) _then) = _$NotificationItemCopyWithImpl;
@useResult
$Res call({
String? id,@JsonKey(name: 'user_id') String? userId, String? title, String? message, String? link, String? image, String? priority, String? type,@JsonKey(name: 'event_type') String? eventType, String? status, Map<String, dynamic>? methods, Map<String, dynamic>? metadata,@JsonKey(name: 'schedule_at') int? scheduleAt,@JsonKey(name: 'created_at') String? createdAt,@JsonKey(name: 'updated_at') String? updatedAt, bool? seen,@JsonKey(name: 'seen_at') int? seenAt,@JsonKey(name: 'is_scheduled') bool? isScheduled,@JsonKey(name: 'scheduled_at') int? scheduledAt
});
}
/// @nodoc
class _$NotificationItemCopyWithImpl<$Res>
implements $NotificationItemCopyWith<$Res> {
_$NotificationItemCopyWithImpl(this._self, this._then);
final NotificationItem _self;
final $Res Function(NotificationItem) _then;
/// Create a copy of NotificationItem
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @override $Res call({Object? id = freezed,Object? userId = freezed,Object? title = freezed,Object? message = freezed,Object? link = freezed,Object? image = freezed,Object? priority = freezed,Object? type = freezed,Object? eventType = freezed,Object? status = freezed,Object? methods = freezed,Object? metadata = freezed,Object? scheduleAt = freezed,Object? createdAt = freezed,Object? updatedAt = freezed,Object? seen = freezed,Object? seenAt = freezed,Object? isScheduled = freezed,Object? scheduledAt = freezed,}) {
return _then(_self.copyWith(
id: freezed == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
as String?,userId: freezed == userId ? _self.userId : userId // ignore: cast_nullable_to_non_nullable
as String?,title: freezed == title ? _self.title : title // ignore: cast_nullable_to_non_nullable
as String?,message: freezed == message ? _self.message : message // ignore: cast_nullable_to_non_nullable
as String?,link: freezed == link ? _self.link : link // ignore: cast_nullable_to_non_nullable
as String?,image: freezed == image ? _self.image : image // ignore: cast_nullable_to_non_nullable
as String?,priority: freezed == priority ? _self.priority : priority // ignore: cast_nullable_to_non_nullable
as String?,type: freezed == type ? _self.type : type // ignore: cast_nullable_to_non_nullable
as String?,eventType: freezed == eventType ? _self.eventType : eventType // ignore: cast_nullable_to_non_nullable
as String?,status: freezed == status ? _self.status : status // ignore: cast_nullable_to_non_nullable
as String?,methods: freezed == methods ? _self.methods : methods // ignore: cast_nullable_to_non_nullable
as Map<String, dynamic>?,metadata: freezed == metadata ? _self.metadata : metadata // ignore: cast_nullable_to_non_nullable
as Map<String, dynamic>?,scheduleAt: freezed == scheduleAt ? _self.scheduleAt : scheduleAt // ignore: cast_nullable_to_non_nullable
as int?,createdAt: freezed == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable
as String?,updatedAt: freezed == updatedAt ? _self.updatedAt : updatedAt // ignore: cast_nullable_to_non_nullable
as String?,seen: freezed == seen ? _self.seen : seen // ignore: cast_nullable_to_non_nullable
as bool?,seenAt: freezed == seenAt ? _self.seenAt : seenAt // ignore: cast_nullable_to_non_nullable
as int?,isScheduled: freezed == isScheduled ? _self.isScheduled : isScheduled // ignore: cast_nullable_to_non_nullable
as bool?,scheduledAt: freezed == scheduledAt ? _self.scheduledAt : scheduledAt // ignore: cast_nullable_to_non_nullable
as int?,
));
}
}
/// Adds pattern-matching-related methods to [NotificationItem].
extension NotificationItemPatterns on NotificationItem {
/// A variant of `map` that fallback to returning `orElse`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs TResult maybeMap<TResult extends Object?>(TResult Function( _NotificationItem value)? $default,{required TResult orElse(),}){
final _that = this;
switch (_that) {
case _NotificationItem() when $default != null:
return $default(_that);case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// Callbacks receives the raw object, upcasted.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case final Subclass2 value:
/// return ...;
/// }
/// ```
@optionalTypeArgs TResult map<TResult extends Object?>(TResult Function( _NotificationItem value) $default,){
final _that = this;
switch (_that) {
case _NotificationItem():
return $default(_that);case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `map` that fallback to returning `null`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>(TResult? Function( _NotificationItem value)? $default,){
final _that = this;
switch (_that) {
case _NotificationItem() when $default != null:
return $default(_that);case _:
return null;
}
}
/// A variant of `when` that fallback to an `orElse` callback.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String? id, @JsonKey(name: 'user_id') String? userId, String? title, String? message, String? link, String? image, String? priority, String? type, @JsonKey(name: 'event_type') String? eventType, String? status, Map<String, dynamic>? methods, Map<String, dynamic>? metadata, @JsonKey(name: 'schedule_at') int? scheduleAt, @JsonKey(name: 'created_at') String? createdAt, @JsonKey(name: 'updated_at') String? updatedAt, bool? seen, @JsonKey(name: 'seen_at') int? seenAt, @JsonKey(name: 'is_scheduled') bool? isScheduled, @JsonKey(name: 'scheduled_at') int? scheduledAt)? $default,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _NotificationItem() when $default != null:
return $default(_that.id,_that.userId,_that.title,_that.message,_that.link,_that.image,_that.priority,_that.type,_that.eventType,_that.status,_that.methods,_that.metadata,_that.scheduleAt,_that.createdAt,_that.updatedAt,_that.seen,_that.seenAt,_that.isScheduled,_that.scheduledAt);case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// As opposed to `map`, this offers destructuring.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case Subclass2(:final field2):
/// return ...;
/// }
/// ```
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String? id, @JsonKey(name: 'user_id') String? userId, String? title, String? message, String? link, String? image, String? priority, String? type, @JsonKey(name: 'event_type') String? eventType, String? status, Map<String, dynamic>? methods, Map<String, dynamic>? metadata, @JsonKey(name: 'schedule_at') int? scheduleAt, @JsonKey(name: 'created_at') String? createdAt, @JsonKey(name: 'updated_at') String? updatedAt, bool? seen, @JsonKey(name: 'seen_at') int? seenAt, @JsonKey(name: 'is_scheduled') bool? isScheduled, @JsonKey(name: 'scheduled_at') int? scheduledAt) $default,) {final _that = this;
switch (_that) {
case _NotificationItem():
return $default(_that.id,_that.userId,_that.title,_that.message,_that.link,_that.image,_that.priority,_that.type,_that.eventType,_that.status,_that.methods,_that.metadata,_that.scheduleAt,_that.createdAt,_that.updatedAt,_that.seen,_that.seenAt,_that.isScheduled,_that.scheduledAt);case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `when` that fallback to returning `null`
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String? id, @JsonKey(name: 'user_id') String? userId, String? title, String? message, String? link, String? image, String? priority, String? type, @JsonKey(name: 'event_type') String? eventType, String? status, Map<String, dynamic>? methods, Map<String, dynamic>? metadata, @JsonKey(name: 'schedule_at') int? scheduleAt, @JsonKey(name: 'created_at') String? createdAt, @JsonKey(name: 'updated_at') String? updatedAt, bool? seen, @JsonKey(name: 'seen_at') int? seenAt, @JsonKey(name: 'is_scheduled') bool? isScheduled, @JsonKey(name: 'scheduled_at') int? scheduledAt)? $default,) {final _that = this;
switch (_that) {
case _NotificationItem() when $default != null:
return $default(_that.id,_that.userId,_that.title,_that.message,_that.link,_that.image,_that.priority,_that.type,_that.eventType,_that.status,_that.methods,_that.metadata,_that.scheduleAt,_that.createdAt,_that.updatedAt,_that.seen,_that.seenAt,_that.isScheduled,_that.scheduledAt);case _:
return null;
}
}
}
/// @nodoc
@JsonSerializable()
class _NotificationItem implements NotificationItem {
const _NotificationItem({required this.id, @JsonKey(name: 'user_id') required this.userId, required this.title, required this.message, required this.link, required this.image, required this.priority, required this.type, @JsonKey(name: 'event_type') required this.eventType, required this.status, required final Map<String, dynamic>? methods, required final Map<String, dynamic>? metadata, @JsonKey(name: 'schedule_at') required this.scheduleAt, @JsonKey(name: 'created_at') required this.createdAt, @JsonKey(name: 'updated_at') required this.updatedAt, required this.seen, @JsonKey(name: 'seen_at') required this.seenAt, @JsonKey(name: 'is_scheduled') required this.isScheduled, @JsonKey(name: 'scheduled_at') required this.scheduledAt}): _methods = methods,_metadata = metadata;
factory _NotificationItem.fromJson(Map<String, dynamic> json) => _$NotificationItemFromJson(json);
@override final String? id;
@override@JsonKey(name: 'user_id') final String? userId;
@override final String? title;
@override final String? message;
@override final String? link;
@override final String? image;
@override final String? priority;
@override final String? type;
@override@JsonKey(name: 'event_type') final String? eventType;
@override final String? status;
final Map<String, dynamic>? _methods;
@override Map<String, dynamic>? get methods {
final value = _methods;
if (value == null) return null;
if (_methods is EqualUnmodifiableMapView) return _methods;
// ignore: implicit_dynamic_type
return EqualUnmodifiableMapView(value);
}
final Map<String, dynamic>? _metadata;
@override Map<String, dynamic>? get metadata {
final value = _metadata;
if (value == null) return null;
if (_metadata is EqualUnmodifiableMapView) return _metadata;
// ignore: implicit_dynamic_type
return EqualUnmodifiableMapView(value);
}
@override@JsonKey(name: 'schedule_at') final int? scheduleAt;
@override@JsonKey(name: 'created_at') final String? createdAt;
@override@JsonKey(name: 'updated_at') final String? updatedAt;
@override final bool? seen;
@override@JsonKey(name: 'seen_at') final int? seenAt;
@override@JsonKey(name: 'is_scheduled') final bool? isScheduled;
@override@JsonKey(name: 'scheduled_at') final int? scheduledAt;
/// Create a copy of NotificationItem
/// with the given fields replaced by the non-null parameter values.
@override @JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
_$NotificationItemCopyWith<_NotificationItem> get copyWith => __$NotificationItemCopyWithImpl<_NotificationItem>(this, _$identity);
@override
Map<String, dynamic> toJson() {
return _$NotificationItemToJson(this, );
}
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _NotificationItem&&(identical(other.id, id) || other.id == id)&&(identical(other.userId, userId) || other.userId == userId)&&(identical(other.title, title) || other.title == title)&&(identical(other.message, message) || other.message == message)&&(identical(other.link, link) || other.link == link)&&(identical(other.image, image) || other.image == image)&&(identical(other.priority, priority) || other.priority == priority)&&(identical(other.type, type) || other.type == type)&&(identical(other.eventType, eventType) || other.eventType == eventType)&&(identical(other.status, status) || other.status == status)&&const DeepCollectionEquality().equals(other._methods, _methods)&&const DeepCollectionEquality().equals(other._metadata, _metadata)&&(identical(other.scheduleAt, scheduleAt) || other.scheduleAt == scheduleAt)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.updatedAt, updatedAt) || other.updatedAt == updatedAt)&&(identical(other.seen, seen) || other.seen == seen)&&(identical(other.seenAt, seenAt) || other.seenAt == seenAt)&&(identical(other.isScheduled, isScheduled) || other.isScheduled == isScheduled)&&(identical(other.scheduledAt, scheduledAt) || other.scheduledAt == scheduledAt));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hashAll([runtimeType,id,userId,title,message,link,image,priority,type,eventType,status,const DeepCollectionEquality().hash(_methods),const DeepCollectionEquality().hash(_metadata),scheduleAt,createdAt,updatedAt,seen,seenAt,isScheduled,scheduledAt]);
@override
String toString() {
return 'NotificationItem(id: $id, userId: $userId, title: $title, message: $message, link: $link, image: $image, priority: $priority, type: $type, eventType: $eventType, status: $status, methods: $methods, metadata: $metadata, scheduleAt: $scheduleAt, createdAt: $createdAt, updatedAt: $updatedAt, seen: $seen, seenAt: $seenAt, isScheduled: $isScheduled, scheduledAt: $scheduledAt)';
}
}
/// @nodoc
abstract mixin class _$NotificationItemCopyWith<$Res> implements $NotificationItemCopyWith<$Res> {
factory _$NotificationItemCopyWith(_NotificationItem value, $Res Function(_NotificationItem) _then) = __$NotificationItemCopyWithImpl;
@override @useResult
$Res call({
String? id,@JsonKey(name: 'user_id') String? userId, String? title, String? message, String? link, String? image, String? priority, String? type,@JsonKey(name: 'event_type') String? eventType, String? status, Map<String, dynamic>? methods, Map<String, dynamic>? metadata,@JsonKey(name: 'schedule_at') int? scheduleAt,@JsonKey(name: 'created_at') String? createdAt,@JsonKey(name: 'updated_at') String? updatedAt, bool? seen,@JsonKey(name: 'seen_at') int? seenAt,@JsonKey(name: 'is_scheduled') bool? isScheduled,@JsonKey(name: 'scheduled_at') int? scheduledAt
});
}
/// @nodoc
class __$NotificationItemCopyWithImpl<$Res>
implements _$NotificationItemCopyWith<$Res> {
__$NotificationItemCopyWithImpl(this._self, this._then);
final _NotificationItem _self;
final $Res Function(_NotificationItem) _then;
/// Create a copy of NotificationItem
/// with the given fields replaced by the non-null parameter values.
@override @pragma('vm:prefer-inline') $Res call({Object? id = freezed,Object? userId = freezed,Object? title = freezed,Object? message = freezed,Object? link = freezed,Object? image = freezed,Object? priority = freezed,Object? type = freezed,Object? eventType = freezed,Object? status = freezed,Object? methods = freezed,Object? metadata = freezed,Object? scheduleAt = freezed,Object? createdAt = freezed,Object? updatedAt = freezed,Object? seen = freezed,Object? seenAt = freezed,Object? isScheduled = freezed,Object? scheduledAt = freezed,}) {
return _then(_NotificationItem(
id: freezed == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
as String?,userId: freezed == userId ? _self.userId : userId // ignore: cast_nullable_to_non_nullable
as String?,title: freezed == title ? _self.title : title // ignore: cast_nullable_to_non_nullable
as String?,message: freezed == message ? _self.message : message // ignore: cast_nullable_to_non_nullable
as String?,link: freezed == link ? _self.link : link // ignore: cast_nullable_to_non_nullable
as String?,image: freezed == image ? _self.image : image // ignore: cast_nullable_to_non_nullable
as String?,priority: freezed == priority ? _self.priority : priority // ignore: cast_nullable_to_non_nullable
as String?,type: freezed == type ? _self.type : type // ignore: cast_nullable_to_non_nullable
as String?,eventType: freezed == eventType ? _self.eventType : eventType // ignore: cast_nullable_to_non_nullable
as String?,status: freezed == status ? _self.status : status // ignore: cast_nullable_to_non_nullable
as String?,methods: freezed == methods ? _self._methods : methods // ignore: cast_nullable_to_non_nullable
as Map<String, dynamic>?,metadata: freezed == metadata ? _self._metadata : metadata // ignore: cast_nullable_to_non_nullable
as Map<String, dynamic>?,scheduleAt: freezed == scheduleAt ? _self.scheduleAt : scheduleAt // ignore: cast_nullable_to_non_nullable
as int?,createdAt: freezed == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable
as String?,updatedAt: freezed == updatedAt ? _self.updatedAt : updatedAt // ignore: cast_nullable_to_non_nullable
as String?,seen: freezed == seen ? _self.seen : seen // ignore: cast_nullable_to_non_nullable
as bool?,seenAt: freezed == seenAt ? _self.seenAt : seenAt // ignore: cast_nullable_to_non_nullable
as int?,isScheduled: freezed == isScheduled ? _self.isScheduled : isScheduled // ignore: cast_nullable_to_non_nullable
as bool?,scheduledAt: freezed == scheduledAt ? _self.scheduledAt : scheduledAt // ignore: cast_nullable_to_non_nullable
as int?,
));
}
}
// dart format on
@@ -1,71 +0,0 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'notification_data.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
_NotificationData _$NotificationDataFromJson(Map<String, dynamic> json) =>
_NotificationData(
notifications:
(json['notifications'] as List<dynamic>?)
?.map((e) => NotificationItem.fromJson(e as Map<String, dynamic>))
.toList(),
meta:
json['meta'] == null
? null
: Meta.fromJson(json['meta'] as Map<String, dynamic>),
);
Map<String, dynamic> _$NotificationDataToJson(_NotificationData instance) =>
<String, dynamic>{
'notifications': instance.notifications,
'meta': instance.meta,
};
_NotificationItem _$NotificationItemFromJson(Map<String, dynamic> json) =>
_NotificationItem(
id: json['id'] as String?,
userId: json['user_id'] as String?,
title: json['title'] as String?,
message: json['message'] as String?,
link: json['link'] as String?,
image: json['image'] as String?,
priority: json['priority'] as String?,
type: json['type'] as String?,
eventType: json['event_type'] as String?,
status: json['status'] as String?,
methods: json['methods'] as Map<String, dynamic>?,
metadata: json['metadata'] as Map<String, dynamic>?,
scheduleAt: (json['schedule_at'] as num?)?.toInt(),
createdAt: json['created_at'] as String?,
updatedAt: json['updated_at'] as String?,
seen: json['seen'] as bool?,
seenAt: (json['seen_at'] as num?)?.toInt(),
isScheduled: json['is_scheduled'] as bool?,
scheduledAt: (json['scheduled_at'] as num?)?.toInt(),
);
Map<String, dynamic> _$NotificationItemToJson(_NotificationItem instance) =>
<String, dynamic>{
'id': instance.id,
'user_id': instance.userId,
'title': instance.title,
'message': instance.message,
'link': instance.link,
'image': instance.image,
'priority': instance.priority,
'type': instance.type,
'event_type': instance.eventType,
'status': instance.status,
'methods': instance.methods,
'metadata': instance.metadata,
'schedule_at': instance.scheduleAt,
'created_at': instance.createdAt,
'updated_at': instance.updatedAt,
'seen': instance.seen,
'seen_at': instance.seenAt,
'is_scheduled': instance.isScheduled,
'scheduled_at': instance.scheduledAt,
};
@@ -0,0 +1,38 @@
// ignore_for_file: invalid_annotation_target
import 'package:freezed_annotation/freezed_annotation.dart';
part 'notification_recipient.freezed.dart';
part 'notification_recipient.g.dart';
@freezed
abstract class Recipient with _$Recipient {
const factory Recipient({
required String? id,
@JsonKey(name: 'full_name') required String? fullName,
required String? username,
required String? email,
required String? status,
required String? type,
required String? role,
required String? phone,
@JsonKey(name: 'updated_at') required int? updatedAt,
@JsonKey(name: 'created_at') required int? createdAt,
@JsonKey(name: 'last_login_at') required int? lastLoginAt,
required List<Company>? companies,
}) = _Recipient;
factory Recipient.fromJson(Map<String, Object?> json) =>
_$RecipientFromJson(json);
}
@freezed
abstract class Company with _$Company {
const factory Company({
required String? id,
required String? name,
}) = _Company;
factory Company.fromJson(Map<String, Object?> json) =>
_$CompanyFromJson(json);
}
@@ -0,0 +1,584 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
// coverage:ignore-file
// ignore_for_file: type=lint
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
part of 'notification_recipient.dart';
// **************************************************************************
// FreezedGenerator
// **************************************************************************
// dart format off
T _$identity<T>(T value) => value;
/// @nodoc
mixin _$Recipient {
String? get id;@JsonKey(name: 'full_name') String? get fullName; String? get username; String? get email; String? get status; String? get type; String? get role; String? get phone;@JsonKey(name: 'updated_at') int? get updatedAt;@JsonKey(name: 'created_at') int? get createdAt;@JsonKey(name: 'last_login_at') int? get lastLoginAt; List<Company>? get companies;
/// Create a copy of Recipient
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
$RecipientCopyWith<Recipient> get copyWith => _$RecipientCopyWithImpl<Recipient>(this as Recipient, _$identity);
/// Serializes this Recipient to a JSON map.
Map<String, dynamic> toJson();
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is Recipient&&(identical(other.id, id) || other.id == id)&&(identical(other.fullName, fullName) || other.fullName == fullName)&&(identical(other.username, username) || other.username == username)&&(identical(other.email, email) || other.email == email)&&(identical(other.status, status) || other.status == status)&&(identical(other.type, type) || other.type == type)&&(identical(other.role, role) || other.role == role)&&(identical(other.phone, phone) || other.phone == phone)&&(identical(other.updatedAt, updatedAt) || other.updatedAt == updatedAt)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.lastLoginAt, lastLoginAt) || other.lastLoginAt == lastLoginAt)&&const DeepCollectionEquality().equals(other.companies, companies));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(runtimeType,id,fullName,username,email,status,type,role,phone,updatedAt,createdAt,lastLoginAt,const DeepCollectionEquality().hash(companies));
@override
String toString() {
return 'Recipient(id: $id, fullName: $fullName, username: $username, email: $email, status: $status, type: $type, role: $role, phone: $phone, updatedAt: $updatedAt, createdAt: $createdAt, lastLoginAt: $lastLoginAt, companies: $companies)';
}
}
/// @nodoc
abstract mixin class $RecipientCopyWith<$Res> {
factory $RecipientCopyWith(Recipient value, $Res Function(Recipient) _then) = _$RecipientCopyWithImpl;
@useResult
$Res call({
String? id,@JsonKey(name: 'full_name') String? fullName, String? username, String? email, String? status, String? type, String? role, String? phone,@JsonKey(name: 'updated_at') int? updatedAt,@JsonKey(name: 'created_at') int? createdAt,@JsonKey(name: 'last_login_at') int? lastLoginAt, List<Company>? companies
});
}
/// @nodoc
class _$RecipientCopyWithImpl<$Res>
implements $RecipientCopyWith<$Res> {
_$RecipientCopyWithImpl(this._self, this._then);
final Recipient _self;
final $Res Function(Recipient) _then;
/// Create a copy of Recipient
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @override $Res call({Object? id = freezed,Object? fullName = freezed,Object? username = freezed,Object? email = freezed,Object? status = freezed,Object? type = freezed,Object? role = freezed,Object? phone = freezed,Object? updatedAt = freezed,Object? createdAt = freezed,Object? lastLoginAt = freezed,Object? companies = freezed,}) {
return _then(_self.copyWith(
id: freezed == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
as String?,fullName: freezed == fullName ? _self.fullName : fullName // ignore: cast_nullable_to_non_nullable
as String?,username: freezed == username ? _self.username : username // ignore: cast_nullable_to_non_nullable
as String?,email: freezed == email ? _self.email : email // ignore: cast_nullable_to_non_nullable
as String?,status: freezed == status ? _self.status : status // ignore: cast_nullable_to_non_nullable
as String?,type: freezed == type ? _self.type : type // ignore: cast_nullable_to_non_nullable
as String?,role: freezed == role ? _self.role : role // ignore: cast_nullable_to_non_nullable
as String?,phone: freezed == phone ? _self.phone : phone // ignore: cast_nullable_to_non_nullable
as String?,updatedAt: freezed == updatedAt ? _self.updatedAt : updatedAt // ignore: cast_nullable_to_non_nullable
as int?,createdAt: freezed == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable
as int?,lastLoginAt: freezed == lastLoginAt ? _self.lastLoginAt : lastLoginAt // ignore: cast_nullable_to_non_nullable
as int?,companies: freezed == companies ? _self.companies : companies // ignore: cast_nullable_to_non_nullable
as List<Company>?,
));
}
}
/// Adds pattern-matching-related methods to [Recipient].
extension RecipientPatterns on Recipient {
/// A variant of `map` that fallback to returning `orElse`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs TResult maybeMap<TResult extends Object?>(TResult Function( _Recipient value)? $default,{required TResult orElse(),}){
final _that = this;
switch (_that) {
case _Recipient() when $default != null:
return $default(_that);case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// Callbacks receives the raw object, upcasted.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case final Subclass2 value:
/// return ...;
/// }
/// ```
@optionalTypeArgs TResult map<TResult extends Object?>(TResult Function( _Recipient value) $default,){
final _that = this;
switch (_that) {
case _Recipient():
return $default(_that);case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `map` that fallback to returning `null`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>(TResult? Function( _Recipient value)? $default,){
final _that = this;
switch (_that) {
case _Recipient() when $default != null:
return $default(_that);case _:
return null;
}
}
/// A variant of `when` that fallback to an `orElse` callback.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String? id, @JsonKey(name: 'full_name') String? fullName, String? username, String? email, String? status, String? type, String? role, String? phone, @JsonKey(name: 'updated_at') int? updatedAt, @JsonKey(name: 'created_at') int? createdAt, @JsonKey(name: 'last_login_at') int? lastLoginAt, List<Company>? companies)? $default,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _Recipient() when $default != null:
return $default(_that.id,_that.fullName,_that.username,_that.email,_that.status,_that.type,_that.role,_that.phone,_that.updatedAt,_that.createdAt,_that.lastLoginAt,_that.companies);case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// As opposed to `map`, this offers destructuring.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case Subclass2(:final field2):
/// return ...;
/// }
/// ```
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String? id, @JsonKey(name: 'full_name') String? fullName, String? username, String? email, String? status, String? type, String? role, String? phone, @JsonKey(name: 'updated_at') int? updatedAt, @JsonKey(name: 'created_at') int? createdAt, @JsonKey(name: 'last_login_at') int? lastLoginAt, List<Company>? companies) $default,) {final _that = this;
switch (_that) {
case _Recipient():
return $default(_that.id,_that.fullName,_that.username,_that.email,_that.status,_that.type,_that.role,_that.phone,_that.updatedAt,_that.createdAt,_that.lastLoginAt,_that.companies);case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `when` that fallback to returning `null`
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String? id, @JsonKey(name: 'full_name') String? fullName, String? username, String? email, String? status, String? type, String? role, String? phone, @JsonKey(name: 'updated_at') int? updatedAt, @JsonKey(name: 'created_at') int? createdAt, @JsonKey(name: 'last_login_at') int? lastLoginAt, List<Company>? companies)? $default,) {final _that = this;
switch (_that) {
case _Recipient() when $default != null:
return $default(_that.id,_that.fullName,_that.username,_that.email,_that.status,_that.type,_that.role,_that.phone,_that.updatedAt,_that.createdAt,_that.lastLoginAt,_that.companies);case _:
return null;
}
}
}
/// @nodoc
@JsonSerializable()
class _Recipient implements Recipient {
const _Recipient({required this.id, @JsonKey(name: 'full_name') required this.fullName, required this.username, required this.email, required this.status, required this.type, required this.role, required this.phone, @JsonKey(name: 'updated_at') required this.updatedAt, @JsonKey(name: 'created_at') required this.createdAt, @JsonKey(name: 'last_login_at') required this.lastLoginAt, required final List<Company>? companies}): _companies = companies;
factory _Recipient.fromJson(Map<String, dynamic> json) => _$RecipientFromJson(json);
@override final String? id;
@override@JsonKey(name: 'full_name') final String? fullName;
@override final String? username;
@override final String? email;
@override final String? status;
@override final String? type;
@override final String? role;
@override final String? phone;
@override@JsonKey(name: 'updated_at') final int? updatedAt;
@override@JsonKey(name: 'created_at') final int? createdAt;
@override@JsonKey(name: 'last_login_at') final int? lastLoginAt;
final List<Company>? _companies;
@override List<Company>? get companies {
final value = _companies;
if (value == null) return null;
if (_companies is EqualUnmodifiableListView) return _companies;
// ignore: implicit_dynamic_type
return EqualUnmodifiableListView(value);
}
/// Create a copy of Recipient
/// with the given fields replaced by the non-null parameter values.
@override @JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
_$RecipientCopyWith<_Recipient> get copyWith => __$RecipientCopyWithImpl<_Recipient>(this, _$identity);
@override
Map<String, dynamic> toJson() {
return _$RecipientToJson(this, );
}
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _Recipient&&(identical(other.id, id) || other.id == id)&&(identical(other.fullName, fullName) || other.fullName == fullName)&&(identical(other.username, username) || other.username == username)&&(identical(other.email, email) || other.email == email)&&(identical(other.status, status) || other.status == status)&&(identical(other.type, type) || other.type == type)&&(identical(other.role, role) || other.role == role)&&(identical(other.phone, phone) || other.phone == phone)&&(identical(other.updatedAt, updatedAt) || other.updatedAt == updatedAt)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.lastLoginAt, lastLoginAt) || other.lastLoginAt == lastLoginAt)&&const DeepCollectionEquality().equals(other._companies, _companies));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(runtimeType,id,fullName,username,email,status,type,role,phone,updatedAt,createdAt,lastLoginAt,const DeepCollectionEquality().hash(_companies));
@override
String toString() {
return 'Recipient(id: $id, fullName: $fullName, username: $username, email: $email, status: $status, type: $type, role: $role, phone: $phone, updatedAt: $updatedAt, createdAt: $createdAt, lastLoginAt: $lastLoginAt, companies: $companies)';
}
}
/// @nodoc
abstract mixin class _$RecipientCopyWith<$Res> implements $RecipientCopyWith<$Res> {
factory _$RecipientCopyWith(_Recipient value, $Res Function(_Recipient) _then) = __$RecipientCopyWithImpl;
@override @useResult
$Res call({
String? id,@JsonKey(name: 'full_name') String? fullName, String? username, String? email, String? status, String? type, String? role, String? phone,@JsonKey(name: 'updated_at') int? updatedAt,@JsonKey(name: 'created_at') int? createdAt,@JsonKey(name: 'last_login_at') int? lastLoginAt, List<Company>? companies
});
}
/// @nodoc
class __$RecipientCopyWithImpl<$Res>
implements _$RecipientCopyWith<$Res> {
__$RecipientCopyWithImpl(this._self, this._then);
final _Recipient _self;
final $Res Function(_Recipient) _then;
/// Create a copy of Recipient
/// with the given fields replaced by the non-null parameter values.
@override @pragma('vm:prefer-inline') $Res call({Object? id = freezed,Object? fullName = freezed,Object? username = freezed,Object? email = freezed,Object? status = freezed,Object? type = freezed,Object? role = freezed,Object? phone = freezed,Object? updatedAt = freezed,Object? createdAt = freezed,Object? lastLoginAt = freezed,Object? companies = freezed,}) {
return _then(_Recipient(
id: freezed == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
as String?,fullName: freezed == fullName ? _self.fullName : fullName // ignore: cast_nullable_to_non_nullable
as String?,username: freezed == username ? _self.username : username // ignore: cast_nullable_to_non_nullable
as String?,email: freezed == email ? _self.email : email // ignore: cast_nullable_to_non_nullable
as String?,status: freezed == status ? _self.status : status // ignore: cast_nullable_to_non_nullable
as String?,type: freezed == type ? _self.type : type // ignore: cast_nullable_to_non_nullable
as String?,role: freezed == role ? _self.role : role // ignore: cast_nullable_to_non_nullable
as String?,phone: freezed == phone ? _self.phone : phone // ignore: cast_nullable_to_non_nullable
as String?,updatedAt: freezed == updatedAt ? _self.updatedAt : updatedAt // ignore: cast_nullable_to_non_nullable
as int?,createdAt: freezed == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable
as int?,lastLoginAt: freezed == lastLoginAt ? _self.lastLoginAt : lastLoginAt // ignore: cast_nullable_to_non_nullable
as int?,companies: freezed == companies ? _self._companies : companies // ignore: cast_nullable_to_non_nullable
as List<Company>?,
));
}
}
/// @nodoc
mixin _$Company {
String? get id; String? get name;
/// Create a copy of Company
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
$CompanyCopyWith<Company> get copyWith => _$CompanyCopyWithImpl<Company>(this as Company, _$identity);
/// Serializes this Company to a JSON map.
Map<String, dynamic> toJson();
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is Company&&(identical(other.id, id) || other.id == id)&&(identical(other.name, name) || other.name == name));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(runtimeType,id,name);
@override
String toString() {
return 'Company(id: $id, name: $name)';
}
}
/// @nodoc
abstract mixin class $CompanyCopyWith<$Res> {
factory $CompanyCopyWith(Company value, $Res Function(Company) _then) = _$CompanyCopyWithImpl;
@useResult
$Res call({
String? id, String? name
});
}
/// @nodoc
class _$CompanyCopyWithImpl<$Res>
implements $CompanyCopyWith<$Res> {
_$CompanyCopyWithImpl(this._self, this._then);
final Company _self;
final $Res Function(Company) _then;
/// Create a copy of Company
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @override $Res call({Object? id = freezed,Object? name = freezed,}) {
return _then(_self.copyWith(
id: freezed == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
as String?,name: freezed == name ? _self.name : name // ignore: cast_nullable_to_non_nullable
as String?,
));
}
}
/// Adds pattern-matching-related methods to [Company].
extension CompanyPatterns on Company {
/// A variant of `map` that fallback to returning `orElse`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs TResult maybeMap<TResult extends Object?>(TResult Function( _Company value)? $default,{required TResult orElse(),}){
final _that = this;
switch (_that) {
case _Company() when $default != null:
return $default(_that);case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// Callbacks receives the raw object, upcasted.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case final Subclass2 value:
/// return ...;
/// }
/// ```
@optionalTypeArgs TResult map<TResult extends Object?>(TResult Function( _Company value) $default,){
final _that = this;
switch (_that) {
case _Company():
return $default(_that);case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `map` that fallback to returning `null`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>(TResult? Function( _Company value)? $default,){
final _that = this;
switch (_that) {
case _Company() when $default != null:
return $default(_that);case _:
return null;
}
}
/// A variant of `when` that fallback to an `orElse` callback.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String? id, String? name)? $default,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _Company() when $default != null:
return $default(_that.id,_that.name);case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// As opposed to `map`, this offers destructuring.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case Subclass2(:final field2):
/// return ...;
/// }
/// ```
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String? id, String? name) $default,) {final _that = this;
switch (_that) {
case _Company():
return $default(_that.id,_that.name);case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `when` that fallback to returning `null`
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String? id, String? name)? $default,) {final _that = this;
switch (_that) {
case _Company() when $default != null:
return $default(_that.id,_that.name);case _:
return null;
}
}
}
/// @nodoc
@JsonSerializable()
class _Company implements Company {
const _Company({required this.id, required this.name});
factory _Company.fromJson(Map<String, dynamic> json) => _$CompanyFromJson(json);
@override final String? id;
@override final String? name;
/// Create a copy of Company
/// with the given fields replaced by the non-null parameter values.
@override @JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
_$CompanyCopyWith<_Company> get copyWith => __$CompanyCopyWithImpl<_Company>(this, _$identity);
@override
Map<String, dynamic> toJson() {
return _$CompanyToJson(this, );
}
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _Company&&(identical(other.id, id) || other.id == id)&&(identical(other.name, name) || other.name == name));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(runtimeType,id,name);
@override
String toString() {
return 'Company(id: $id, name: $name)';
}
}
/// @nodoc
abstract mixin class _$CompanyCopyWith<$Res> implements $CompanyCopyWith<$Res> {
factory _$CompanyCopyWith(_Company value, $Res Function(_Company) _then) = __$CompanyCopyWithImpl;
@override @useResult
$Res call({
String? id, String? name
});
}
/// @nodoc
class __$CompanyCopyWithImpl<$Res>
implements _$CompanyCopyWith<$Res> {
__$CompanyCopyWithImpl(this._self, this._then);
final _Company _self;
final $Res Function(_Company) _then;
/// Create a copy of Company
/// with the given fields replaced by the non-null parameter values.
@override @pragma('vm:prefer-inline') $Res call({Object? id = freezed,Object? name = freezed,}) {
return _then(_Company(
id: freezed == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
as String?,name: freezed == name ? _self.name : name // ignore: cast_nullable_to_non_nullable
as String?,
));
}
}
// dart format on
@@ -0,0 +1,49 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'notification_recipient.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
_Recipient _$RecipientFromJson(Map<String, dynamic> json) => _Recipient(
id: json['id'] as String?,
fullName: json['full_name'] as String?,
username: json['username'] as String?,
email: json['email'] as String?,
status: json['status'] as String?,
type: json['type'] as String?,
role: json['role'] as String?,
phone: json['phone'] as String?,
updatedAt: (json['updated_at'] as num?)?.toInt(),
createdAt: (json['created_at'] as num?)?.toInt(),
lastLoginAt: (json['last_login_at'] as num?)?.toInt(),
companies:
(json['companies'] as List<dynamic>?)
?.map((e) => Company.fromJson(e as Map<String, dynamic>))
.toList(),
);
Map<String, dynamic> _$RecipientToJson(_Recipient instance) =>
<String, dynamic>{
'id': instance.id,
'full_name': instance.fullName,
'username': instance.username,
'email': instance.email,
'status': instance.status,
'type': instance.type,
'role': instance.role,
'phone': instance.phone,
'updated_at': instance.updatedAt,
'created_at': instance.createdAt,
'last_login_at': instance.lastLoginAt,
'companies': instance.companies,
};
_Company _$CompanyFromJson(Map<String, dynamic> json) =>
_Company(id: json['id'] as String?, name: json['name'] as String?);
Map<String, dynamic> _$CompanyToJson(_Company instance) => <String, dynamic>{
'id': instance.id,
'name': instance.name,
};
+7 -1
View File
@@ -220,8 +220,14 @@ class HomeViewModel with ChangeNotifier {
break; break;
case Error<Map<String, dynamic>>(): case Error<Map<String, dynamic>>():
_hasUnreadNotification = false; _hasUnreadNotification = false;
break; break;
} }
notifyListeners(); notifyListeners();
} }
void serUnreadNotificationFalse(){
_hasUnreadNotification = false;
notifyListeners();
}
} }
+28 -36
View File
@@ -1,8 +1,10 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:tm_app/core/utils/app_toast.dart'; import 'package:tm_app/core/utils/app_toast.dart';
import 'package:tm_app/core/utils/result.dart'; import 'package:tm_app/core/utils/result.dart';
import 'package:tm_app/data/repositories/notification_repository.dart'; import 'package:tm_app/data/repositories/notification_repository.dart';
import 'package:tm_app/data/services/model/notification__response/notification_response_model.dart'; import 'package:tm_app/data/services/model/notification__response/notification_response_model.dart';
import 'package:tm_app/view_models/home_view_model.dart';
import 'package:tm_app/views/notification/strings/notification_strings.dart'; import 'package:tm_app/views/notification/strings/notification_strings.dart';
class NotificationViewModel with ChangeNotifier { class NotificationViewModel with ChangeNotifier {
@@ -87,11 +89,9 @@ class NotificationViewModel with ChangeNotifier {
case Ok<NotificationResponseModel>(): case Ok<NotificationResponseModel>():
final data = result.value; final data = result.value;
if (isPagination && allNotificationResponse != null) { if (isPagination && allNotificationResponse != null) {
final old = allNotificationResponse?.data?.notifications ?? []; final old = allNotificationResponse?.data ?? [];
final fresh = data.data?.notifications ?? []; final fresh = data.data ?? [];
allNotificationResponse = data.copyWith( allNotificationResponse = data.copyWith(data: [...old, ...fresh]);
data: data.data?.copyWith(notifications: [...old, ...fresh]),
);
} else { } else {
allNotificationResponse = data; allNotificationResponse = data;
} }
@@ -99,8 +99,8 @@ class NotificationViewModel with ChangeNotifier {
_updateImportantFromAll(); _updateImportantFromAll();
currentPageAll = page; currentPageAll = page;
totalPagesAll = data.data?.meta?.pages ?? 1; totalPagesAll = data.meta?.pages ?? 1;
hasMoreAll = (data.data?.notifications?.length ?? 0) >= _pageSize; hasMoreAll = (data.data?.length ?? 0) >= _pageSize;
break; break;
case Error<NotificationResponseModel>(): case Error<NotificationResponseModel>():
@@ -134,18 +134,16 @@ class NotificationViewModel with ChangeNotifier {
case Ok<NotificationResponseModel>(): case Ok<NotificationResponseModel>():
final data = result.value; final data = result.value;
if (isPagination && unreadNotificationResponse != null) { if (isPagination && unreadNotificationResponse != null) {
final old = unreadNotificationResponse?.data?.notifications ?? []; final old = unreadNotificationResponse?.data ?? [];
final fresh = data.data?.notifications ?? []; final fresh = data.data ?? [];
unreadNotificationResponse = data.copyWith( unreadNotificationResponse = data.copyWith(data: [...old, ...fresh]);
data: data.data?.copyWith(notifications: [...old, ...fresh]),
);
} else { } else {
unreadNotificationResponse = data; unreadNotificationResponse = data;
} }
currentPageUnread = page; currentPageUnread = page;
totalPagesUnread = data.data?.meta?.pages ?? 1; totalPagesUnread = data.meta?.pages ?? 1;
hasMoreUnread = (data.data?.notifications?.length ?? 0) >= _pageSize; hasMoreUnread = (data.data?.length ?? 0) >= _pageSize;
break; break;
case Error<NotificationResponseModel>(): case Error<NotificationResponseModel>():
@@ -180,18 +178,18 @@ class NotificationViewModel with ChangeNotifier {
case Ok<NotificationResponseModel>(): case Ok<NotificationResponseModel>():
final data = result.value; final data = result.value;
if (isPagination && importantNotificationResponse != null) { if (isPagination && importantNotificationResponse != null) {
final old = importantNotificationResponse?.data?.notifications ?? []; final old = importantNotificationResponse?.data ?? [];
final fresh = data.data?.notifications ?? []; final fresh = data.data ?? [];
importantNotificationResponse = data.copyWith( importantNotificationResponse = data.copyWith(
data: data.data?.copyWith(notifications: [...old, ...fresh]), data: [...old, ...fresh],
); );
} else { } else {
importantNotificationResponse = data; importantNotificationResponse = data;
} }
currentPageImportant = page; currentPageImportant = page;
totalPagesImportant = data.data?.meta?.pages ?? 1; totalPagesImportant = data.meta?.pages ?? 1;
hasMoreImportant = (data.data?.notifications?.length ?? 0) >= _pageSize; hasMoreImportant = (data.data?.length ?? 0) >= _pageSize;
break; break;
case Error<NotificationResponseModel>(): case Error<NotificationResponseModel>():
@@ -207,7 +205,7 @@ class NotificationViewModel with ChangeNotifier {
} }
void _updateImportantFromAll() { void _updateImportantFromAll() {
final all = allNotificationResponse?.data?.notifications ?? []; final all = allNotificationResponse?.data ?? [];
final filtered = final filtered =
(all.where((n) { (all.where((n) {
final p = n.priority ?? ''; final p = n.priority ?? '';
@@ -216,7 +214,7 @@ class NotificationViewModel with ChangeNotifier {
if (allNotificationResponse != null) { if (allNotificationResponse != null) {
importantNotificationResponse = allNotificationResponse!.copyWith( importantNotificationResponse = allNotificationResponse!.copyWith(
data: allNotificationResponse!.data!.copyWith(notifications: filtered), data: filtered,
); );
} else { } else {
importantNotificationResponse = null; importantNotificationResponse = null;
@@ -264,36 +262,28 @@ class NotificationViewModel with ChangeNotifier {
NotificationStrings.unknownResponse; NotificationStrings.unknownResponse;
if (success) { if (success) {
if (allNotificationResponse?.data?.notifications != null) { if (allNotificationResponse?.data != null) {
final updatedNotifications = final updatedNotifications =
allNotificationResponse!.data!.notifications! allNotificationResponse!.data!
.map((n) => n.copyWith(seen: true)) .map((n) => n.copyWith(seen: true))
.toList(); .toList();
allNotificationResponse = allNotificationResponse!.copyWith( allNotificationResponse = allNotificationResponse!.copyWith(
data: allNotificationResponse!.data!.copyWith( data: updatedNotifications,
notifications: updatedNotifications,
),
); );
unreadNotificationResponse = unreadNotificationResponse?.copyWith( unreadNotificationResponse = unreadNotificationResponse?.copyWith(
data: unreadNotificationResponse?.data?.copyWith( data: [],
notifications: [],
),
); );
if (importantNotificationResponse?.data?.notifications != null) { if (importantNotificationResponse?.data != null) {
final updatedImportant = final updatedImportant =
importantNotificationResponse!.data!.notifications! importantNotificationResponse!.data!
.map((n) => n.copyWith(seen: true)) .map((n) => n.copyWith(seen: true))
.toList(); .toList();
importantNotificationResponse = importantNotificationResponse! importantNotificationResponse = importantNotificationResponse!
.copyWith( .copyWith(data: updatedImportant);
data: importantNotificationResponse!.data!.copyWith(
notifications: updatedImportant,
),
);
} }
} }
@@ -303,6 +293,8 @@ class NotificationViewModel with ChangeNotifier {
NotificationStrings.allNotificationMarkedAsRead, NotificationStrings.allNotificationMarkedAsRead,
); );
} }
final homeViewModel = context.read<HomeViewModel>();
homeViewModel.serUnreadNotificationFalse();
} else { } else {
_errorMessage = message; _errorMessage = message;
if (context.mounted) { if (context.mounted) {
@@ -143,9 +143,9 @@ class _MobileNotificationPageState extends State<MobileNotificationPage>
), ),
if ((viewModel.isLoadingAll && if ((viewModel.isLoadingAll &&
(viewModel.allNotificationResponse?.data?.notifications?.isEmpty ?? true)) || (viewModel.allNotificationResponse?.data?.isEmpty ?? true)) ||
(viewModel.isLoadingUnread && (viewModel.isLoadingUnread &&
(viewModel.unreadNotificationResponse?.data?.notifications?.isEmpty ?? true))) (viewModel.unreadNotificationResponse?.data?.isEmpty ?? true)))
const Expanded( const Expanded(
child: Center( child: Center(
child: CircularProgressIndicator(color: AppColors.secondary50), child: CircularProgressIndicator(color: AppColors.secondary50),
@@ -13,7 +13,7 @@ class NotificationAllTab extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
final viewModel = context.watch<NotificationViewModel>(); final viewModel = context.watch<NotificationViewModel>();
final notifications = final notifications =
viewModel.allNotificationResponse?.data?.notifications ?? []; viewModel.allNotificationResponse?.data ?? [];
return ListView.builder( return ListView.builder(
controller: scrollController, controller: scrollController,
@@ -4,7 +4,7 @@ import 'package:provider/provider.dart';
import 'package:tm_app/core/constants/assets.dart'; import 'package:tm_app/core/constants/assets.dart';
import 'package:tm_app/core/theme/colors.dart'; import 'package:tm_app/core/theme/colors.dart';
import 'package:tm_app/core/utils/size_config.dart'; import 'package:tm_app/core/utils/size_config.dart';
import 'package:tm_app/data/services/model/notification_data/notification_data.dart'; import 'package:tm_app/data/services/model/notification__response/notification_response_model.dart';
import 'package:tm_app/view_models/notification_view_model.dart'; import 'package:tm_app/view_models/notification_view_model.dart';
import '../strings/notification_strings.dart'; import '../strings/notification_strings.dart';
@@ -102,7 +102,7 @@ class NotificationCard extends StatelessWidget {
SvgPicture.asset(AssetsManager.calendar), SvgPicture.asset(AssetsManager.calendar),
SizedBox(width: 4.0.w()), SizedBox(width: 4.0.w()),
Text( Text(
viewModel.timeAgo(notification.createdAt!), viewModel.timeAgo(notification.createdAt!.toString()),
style: TextStyle( style: TextStyle(
fontSize: 12.0.sp(), fontSize: 12.0.sp(),
fontWeight: FontWeight.w400, fontWeight: FontWeight.w400,
@@ -17,9 +17,9 @@ class NotificationImportantTab extends StatelessWidget {
return const Center(child: CircularProgressIndicator()); return const Center(child: CircularProgressIndicator());
} }
final importantFromApi = viewModel.importantNotificationResponse?.data?.notifications ?? []; final importantFromApi = viewModel.importantNotificationResponse?.data ?? [];
final allNotifications = viewModel.allNotificationResponse?.data?.notifications ?? []; final allNotifications = viewModel.allNotificationResponse?.data ?? [];
final source = importantFromApi.isNotEmpty ? importantFromApi : allNotifications; final source = importantFromApi.isNotEmpty ? importantFromApi : allNotifications;
@@ -19,7 +19,7 @@ class NotificationUnreadTab extends StatelessWidget {
} }
final notifications = final notifications =
viewModel.unreadNotificationResponse?.data?.notifications ?? []; viewModel.unreadNotificationResponse?.data ?? [];
if (notifications.isEmpty) { if (notifications.isEmpty) {
return const Center(child: Text(NotificationStrings.noUnreadNotifications,)); return const Center(child: Text(NotificationStrings.noUnreadNotifications,));
+8 -8
View File
@@ -45,10 +45,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: async name: async
sha256: "758e6d74e971c3e5aceb4110bfd6698efc7f501675bcfe0c775459a8140750eb" sha256: d2872f9c19731c2e5f10444b14686eb7cc85c76274bd6c16e1816bff9a3bab63
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "2.13.0" version: "2.12.0"
boolean_selector: boolean_selector:
dependency: transitive dependency: transitive
description: description:
@@ -269,10 +269,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: fake_async name: fake_async
sha256: "5368f224a74523e8d2e7399ea1638b37aecfca824a3cc4dfdf77bf1fa905ac44" sha256: "6a95e56b2449df2273fd8c45a662d6947ce1ebb7aafe80e550a3f68297f3cacc"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.3.3" version: "1.3.2"
ffi: ffi:
dependency: transitive dependency: transitive
description: description:
@@ -572,10 +572,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: leak_tracker name: leak_tracker
sha256: "6bb818ecbdffe216e81182c2f0714a2e62b593f4a4f13098713ff1685dfb6ab0" sha256: c35baad643ba394b40aac41080300150a4f08fd0fd6a10378f8f7c6bc161acec
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "10.0.9" version: "10.0.8"
leak_tracker_flutter_testing: leak_tracker_flutter_testing:
dependency: transitive dependency: transitive
description: description:
@@ -1049,10 +1049,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: vm_service name: vm_service
sha256: ddfa8d30d89985b96407efce8acbdd124701f96741f2d981ca860662f1c0dc02 sha256: "0968250880a6c5fe7edc067ed0a13d4bae1577fe2771dcf3010d52c4a9d3ca14"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "15.0.0" version: "14.3.1"
watcher: watcher:
dependency: transitive dependency: transitive
description: description: