fixed pagination

This commit is contained in:
Username1548
2025-03-13 02:30:10 +07:00
parent 102dc9ee55
commit 9d53760137
38 changed files with 778 additions and 294 deletions

View File

@@ -1,5 +1,6 @@
import 'package:eatvio_app/features/chat/models/chat_room_settings_model.dart';
import 'package:eatvio_app/features/chat/models/chat_user_model.dart';
import 'package:eatvio_app/features/plans/models/chosen_plan_model.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
part 'chat_room_model.freezed.dart';
@@ -11,7 +12,15 @@ class ChatRoomModel with _$ChatRoomModel {
required String id,
@JsonKey(name: 'chat_room_setting') required ChatRoomSettingsModel chatRoomSettings,
required Map<String, ChatUserModel> users,
@JsonKey(name: 'chosen_plan', fromJson: _parseChosenPlan) required ChosenPlanModel? chosenPlan,
}) = _ChatRoomModel;
factory ChatRoomModel.fromJson(Map<String, Object?> json) => _$ChatRoomModelFromJson(json);
}
ChosenPlanModel? _parseChosenPlan(json) {
if (json is Map<String, dynamic>) {
return ChosenPlanModel.fromJson(json);
}
return null;
}

View File

@@ -25,6 +25,8 @@ mixin _$ChatRoomModel {
ChatRoomSettingsModel get chatRoomSettings =>
throw _privateConstructorUsedError;
Map<String, ChatUserModel> get users => throw _privateConstructorUsedError;
@JsonKey(name: 'chosen_plan', fromJson: _parseChosenPlan)
ChosenPlanModel? get chosenPlan => throw _privateConstructorUsedError;
/// Serializes this ChatRoomModel to a JSON map.
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
@@ -46,9 +48,12 @@ abstract class $ChatRoomModelCopyWith<$Res> {
{String id,
@JsonKey(name: 'chat_room_setting')
ChatRoomSettingsModel chatRoomSettings,
Map<String, ChatUserModel> users});
Map<String, ChatUserModel> users,
@JsonKey(name: 'chosen_plan', fromJson: _parseChosenPlan)
ChosenPlanModel? chosenPlan});
$ChatRoomSettingsModelCopyWith<$Res> get chatRoomSettings;
$ChosenPlanModelCopyWith<$Res>? get chosenPlan;
}
/// @nodoc
@@ -69,6 +74,7 @@ class _$ChatRoomModelCopyWithImpl<$Res, $Val extends ChatRoomModel>
Object? id = null,
Object? chatRoomSettings = null,
Object? users = null,
Object? chosenPlan = freezed,
}) {
return _then(_value.copyWith(
id: null == id
@@ -83,6 +89,10 @@ class _$ChatRoomModelCopyWithImpl<$Res, $Val extends ChatRoomModel>
? _value.users
: users // ignore: cast_nullable_to_non_nullable
as Map<String, ChatUserModel>,
chosenPlan: freezed == chosenPlan
? _value.chosenPlan
: chosenPlan // ignore: cast_nullable_to_non_nullable
as ChosenPlanModel?,
) as $Val);
}
@@ -96,6 +106,20 @@ class _$ChatRoomModelCopyWithImpl<$Res, $Val extends ChatRoomModel>
return _then(_value.copyWith(chatRoomSettings: value) as $Val);
});
}
/// Create a copy of ChatRoomModel
/// with the given fields replaced by the non-null parameter values.
@override
@pragma('vm:prefer-inline')
$ChosenPlanModelCopyWith<$Res>? get chosenPlan {
if (_value.chosenPlan == null) {
return null;
}
return $ChosenPlanModelCopyWith<$Res>(_value.chosenPlan!, (value) {
return _then(_value.copyWith(chosenPlan: value) as $Val);
});
}
}
/// @nodoc
@@ -110,10 +134,14 @@ abstract class _$$ChatRoomModelImplCopyWith<$Res>
{String id,
@JsonKey(name: 'chat_room_setting')
ChatRoomSettingsModel chatRoomSettings,
Map<String, ChatUserModel> users});
Map<String, ChatUserModel> users,
@JsonKey(name: 'chosen_plan', fromJson: _parseChosenPlan)
ChosenPlanModel? chosenPlan});
@override
$ChatRoomSettingsModelCopyWith<$Res> get chatRoomSettings;
@override
$ChosenPlanModelCopyWith<$Res>? get chosenPlan;
}
/// @nodoc
@@ -132,6 +160,7 @@ class __$$ChatRoomModelImplCopyWithImpl<$Res>
Object? id = null,
Object? chatRoomSettings = null,
Object? users = null,
Object? chosenPlan = freezed,
}) {
return _then(_$ChatRoomModelImpl(
id: null == id
@@ -146,6 +175,10 @@ class __$$ChatRoomModelImplCopyWithImpl<$Res>
? _value._users
: users // ignore: cast_nullable_to_non_nullable
as Map<String, ChatUserModel>,
chosenPlan: freezed == chosenPlan
? _value.chosenPlan
: chosenPlan // ignore: cast_nullable_to_non_nullable
as ChosenPlanModel?,
));
}
}
@@ -156,7 +189,9 @@ class _$ChatRoomModelImpl implements _ChatRoomModel {
const _$ChatRoomModelImpl(
{required this.id,
@JsonKey(name: 'chat_room_setting') required this.chatRoomSettings,
required final Map<String, ChatUserModel> users})
required final Map<String, ChatUserModel> users,
@JsonKey(name: 'chosen_plan', fromJson: _parseChosenPlan)
required this.chosenPlan})
: _users = users;
factory _$ChatRoomModelImpl.fromJson(Map<String, dynamic> json) =>
@@ -175,9 +210,13 @@ class _$ChatRoomModelImpl implements _ChatRoomModel {
return EqualUnmodifiableMapView(_users);
}
@override
@JsonKey(name: 'chosen_plan', fromJson: _parseChosenPlan)
final ChosenPlanModel? chosenPlan;
@override
String toString() {
return 'ChatRoomModel(id: $id, chatRoomSettings: $chatRoomSettings, users: $users)';
return 'ChatRoomModel(id: $id, chatRoomSettings: $chatRoomSettings, users: $users, chosenPlan: $chosenPlan)';
}
@override
@@ -188,13 +227,15 @@ class _$ChatRoomModelImpl implements _ChatRoomModel {
(identical(other.id, id) || other.id == id) &&
(identical(other.chatRoomSettings, chatRoomSettings) ||
other.chatRoomSettings == chatRoomSettings) &&
const DeepCollectionEquality().equals(other._users, _users));
const DeepCollectionEquality().equals(other._users, _users) &&
(identical(other.chosenPlan, chosenPlan) ||
other.chosenPlan == chosenPlan));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(runtimeType, id, chatRoomSettings,
const DeepCollectionEquality().hash(_users));
const DeepCollectionEquality().hash(_users), chosenPlan);
/// Create a copy of ChatRoomModel
/// with the given fields replaced by the non-null parameter values.
@@ -217,7 +258,9 @@ abstract class _ChatRoomModel implements ChatRoomModel {
{required final String id,
@JsonKey(name: 'chat_room_setting')
required final ChatRoomSettingsModel chatRoomSettings,
required final Map<String, ChatUserModel> users}) = _$ChatRoomModelImpl;
required final Map<String, ChatUserModel> users,
@JsonKey(name: 'chosen_plan', fromJson: _parseChosenPlan)
required final ChosenPlanModel? chosenPlan}) = _$ChatRoomModelImpl;
factory _ChatRoomModel.fromJson(Map<String, dynamic> json) =
_$ChatRoomModelImpl.fromJson;
@@ -229,6 +272,9 @@ abstract class _ChatRoomModel implements ChatRoomModel {
ChatRoomSettingsModel get chatRoomSettings;
@override
Map<String, ChatUserModel> get users;
@override
@JsonKey(name: 'chosen_plan', fromJson: _parseChosenPlan)
ChosenPlanModel? get chosenPlan;
/// Create a copy of ChatRoomModel
/// with the given fields replaced by the non-null parameter values.

View File

@@ -15,6 +15,7 @@ _$ChatRoomModelImpl _$$ChatRoomModelImplFromJson(Map<String, dynamic> json) =>
(k, e) =>
MapEntry(k, ChatUserModel.fromJson(e as Map<String, dynamic>)),
),
chosenPlan: _parseChosenPlan(json['chosen_plan']),
);
Map<String, dynamic> _$$ChatRoomModelImplToJson(_$ChatRoomModelImpl instance) =>
@@ -22,4 +23,5 @@ Map<String, dynamic> _$$ChatRoomModelImplToJson(_$ChatRoomModelImpl instance) =>
'id': instance.id,
'chat_room_setting': instance.chatRoomSettings,
'users': instance.users,
'chosen_plan': instance.chosenPlan,
};

View File

@@ -1,16 +1,28 @@
import 'package:eatvio_app/features/chat/models/chat_message_model.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
part 'chat_room_preview_model.freezed.dart';
part 'chat_room_preview_model.g.dart';
part 'chat_room_pagination_model.freezed.dart';
part 'chat_room_pagination_model.g.dart';
@freezed
class ChatRoomPreviewModel with _$ChatRoomPreviewModel {
const factory ChatRoomPreviewModel({
@JsonKey(name: "chatRooms") required List<ChatRoom> chatRooms,
class ChatRoomPaginationModel with _$ChatRoomPaginationModel {
const factory ChatRoomPaginationModel({
@JsonKey(name: "chatRooms") required ChatRooms chatRooms,
@JsonKey(name: "number_of_unread_chat_rooms") required int unreadChatsCount,
}) = _ChatRoomPreviewModel;
factory ChatRoomPreviewModel.fromJson(Map<String, dynamic> json) => _$ChatRoomPreviewModelFromJson(json);
factory ChatRoomPaginationModel.fromJson(Map<String, dynamic> json) => _$ChatRoomPaginationModelFromJson(json);
}
@freezed
class ChatRooms with _$ChatRooms {
const factory ChatRooms({
@JsonKey(name: "data") required List<ChatRoom> data,
@JsonKey(name: "last_page") required int lastPage,
@JsonKey(name: "current_page") required int currentPage,
}) = _ChatRooms;
factory ChatRooms.fromJson(Map<String, dynamic> json) => _$ChatRoomsFromJson(json);
}
@freezed

View File

@@ -3,7 +3,7 @@
// 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 'chat_room_preview_model.dart';
part of 'chat_room_pagination_model.dart';
// **************************************************************************
// FreezedGenerator
@@ -14,92 +14,125 @@ T _$identity<T>(T value) => value;
final _privateConstructorUsedError = UnsupportedError(
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models');
ChatRoomPreviewModel _$ChatRoomPreviewModelFromJson(Map<String, dynamic> json) {
ChatRoomPaginationModel _$ChatRoomPaginationModelFromJson(
Map<String, dynamic> json) {
return _ChatRoomPreviewModel.fromJson(json);
}
/// @nodoc
mixin _$ChatRoomPreviewModel {
mixin _$ChatRoomPaginationModel {
@JsonKey(name: "chatRooms")
List<ChatRoom> get chatRooms => throw _privateConstructorUsedError;
ChatRooms get chatRooms => throw _privateConstructorUsedError;
@JsonKey(name: "number_of_unread_chat_rooms")
int get unreadChatsCount => throw _privateConstructorUsedError;
/// Serializes this ChatRoomPreviewModel to a JSON map.
/// Serializes this ChatRoomPaginationModel to a JSON map.
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
/// Create a copy of ChatRoomPreviewModel
/// Create a copy of ChatRoomPaginationModel
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
$ChatRoomPreviewModelCopyWith<ChatRoomPreviewModel> get copyWith =>
$ChatRoomPaginationModelCopyWith<ChatRoomPaginationModel> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $ChatRoomPreviewModelCopyWith<$Res> {
factory $ChatRoomPreviewModelCopyWith(ChatRoomPreviewModel value,
$Res Function(ChatRoomPreviewModel) then) =
_$ChatRoomPreviewModelCopyWithImpl<$Res, ChatRoomPreviewModel>;
abstract class $ChatRoomPaginationModelCopyWith<$Res> {
factory $ChatRoomPaginationModelCopyWith(ChatRoomPaginationModel value,
$Res Function(ChatRoomPaginationModel) then) =
_$ChatRoomPaginationModelCopyWithImpl<$Res, ChatRoomPaginationModel>;
@useResult
$Res call({@JsonKey(name: "chatRooms") List<ChatRoom> chatRooms});
$Res call(
{@JsonKey(name: "chatRooms") ChatRooms chatRooms,
@JsonKey(name: "number_of_unread_chat_rooms") int unreadChatsCount});
$ChatRoomsCopyWith<$Res> get chatRooms;
}
/// @nodoc
class _$ChatRoomPreviewModelCopyWithImpl<$Res,
$Val extends ChatRoomPreviewModel>
implements $ChatRoomPreviewModelCopyWith<$Res> {
_$ChatRoomPreviewModelCopyWithImpl(this._value, this._then);
class _$ChatRoomPaginationModelCopyWithImpl<$Res,
$Val extends ChatRoomPaginationModel>
implements $ChatRoomPaginationModelCopyWith<$Res> {
_$ChatRoomPaginationModelCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of ChatRoomPreviewModel
/// Create a copy of ChatRoomPaginationModel
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? chatRooms = null,
Object? unreadChatsCount = null,
}) {
return _then(_value.copyWith(
chatRooms: null == chatRooms
? _value.chatRooms
: chatRooms // ignore: cast_nullable_to_non_nullable
as List<ChatRoom>,
as ChatRooms,
unreadChatsCount: null == unreadChatsCount
? _value.unreadChatsCount
: unreadChatsCount // ignore: cast_nullable_to_non_nullable
as int,
) as $Val);
}
/// Create a copy of ChatRoomPaginationModel
/// with the given fields replaced by the non-null parameter values.
@override
@pragma('vm:prefer-inline')
$ChatRoomsCopyWith<$Res> get chatRooms {
return $ChatRoomsCopyWith<$Res>(_value.chatRooms, (value) {
return _then(_value.copyWith(chatRooms: value) as $Val);
});
}
}
/// @nodoc
abstract class _$$ChatRoomPreviewModelImplCopyWith<$Res>
implements $ChatRoomPreviewModelCopyWith<$Res> {
implements $ChatRoomPaginationModelCopyWith<$Res> {
factory _$$ChatRoomPreviewModelImplCopyWith(_$ChatRoomPreviewModelImpl value,
$Res Function(_$ChatRoomPreviewModelImpl) then) =
__$$ChatRoomPreviewModelImplCopyWithImpl<$Res>;
@override
@useResult
$Res call({@JsonKey(name: "chatRooms") List<ChatRoom> chatRooms});
$Res call(
{@JsonKey(name: "chatRooms") ChatRooms chatRooms,
@JsonKey(name: "number_of_unread_chat_rooms") int unreadChatsCount});
@override
$ChatRoomsCopyWith<$Res> get chatRooms;
}
/// @nodoc
class __$$ChatRoomPreviewModelImplCopyWithImpl<$Res>
extends _$ChatRoomPreviewModelCopyWithImpl<$Res, _$ChatRoomPreviewModelImpl>
extends _$ChatRoomPaginationModelCopyWithImpl<$Res,
_$ChatRoomPreviewModelImpl>
implements _$$ChatRoomPreviewModelImplCopyWith<$Res> {
__$$ChatRoomPreviewModelImplCopyWithImpl(_$ChatRoomPreviewModelImpl _value,
$Res Function(_$ChatRoomPreviewModelImpl) _then)
: super(_value, _then);
/// Create a copy of ChatRoomPreviewModel
/// Create a copy of ChatRoomPaginationModel
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? chatRooms = null,
Object? unreadChatsCount = null,
}) {
return _then(_$ChatRoomPreviewModelImpl(
chatRooms: null == chatRooms
? _value._chatRooms
? _value.chatRooms
: chatRooms // ignore: cast_nullable_to_non_nullable
as List<ChatRoom>,
as ChatRooms,
unreadChatsCount: null == unreadChatsCount
? _value.unreadChatsCount
: unreadChatsCount // ignore: cast_nullable_to_non_nullable
as int,
));
}
}
@@ -108,24 +141,23 @@ class __$$ChatRoomPreviewModelImplCopyWithImpl<$Res>
@JsonSerializable()
class _$ChatRoomPreviewModelImpl implements _ChatRoomPreviewModel {
const _$ChatRoomPreviewModelImpl(
{@JsonKey(name: "chatRooms") required final List<ChatRoom> chatRooms})
: _chatRooms = chatRooms;
{@JsonKey(name: "chatRooms") required this.chatRooms,
@JsonKey(name: "number_of_unread_chat_rooms")
required this.unreadChatsCount});
factory _$ChatRoomPreviewModelImpl.fromJson(Map<String, dynamic> json) =>
_$$ChatRoomPreviewModelImplFromJson(json);
final List<ChatRoom> _chatRooms;
@override
@JsonKey(name: "chatRooms")
List<ChatRoom> get chatRooms {
if (_chatRooms is EqualUnmodifiableListView) return _chatRooms;
// ignore: implicit_dynamic_type
return EqualUnmodifiableListView(_chatRooms);
}
final ChatRooms chatRooms;
@override
@JsonKey(name: "number_of_unread_chat_rooms")
final int unreadChatsCount;
@override
String toString() {
return 'ChatRoomPreviewModel(chatRooms: $chatRooms)';
return 'ChatRoomPaginationModel(chatRooms: $chatRooms, unreadChatsCount: $unreadChatsCount)';
}
@override
@@ -133,16 +165,17 @@ class _$ChatRoomPreviewModelImpl implements _ChatRoomPreviewModel {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$ChatRoomPreviewModelImpl &&
const DeepCollectionEquality()
.equals(other._chatRooms, _chatRooms));
(identical(other.chatRooms, chatRooms) ||
other.chatRooms == chatRooms) &&
(identical(other.unreadChatsCount, unreadChatsCount) ||
other.unreadChatsCount == unreadChatsCount));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode =>
Object.hash(runtimeType, const DeepCollectionEquality().hash(_chatRooms));
int get hashCode => Object.hash(runtimeType, chatRooms, unreadChatsCount);
/// Create a copy of ChatRoomPreviewModel
/// Create a copy of ChatRoomPaginationModel
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@@ -160,19 +193,23 @@ class _$ChatRoomPreviewModelImpl implements _ChatRoomPreviewModel {
}
}
abstract class _ChatRoomPreviewModel implements ChatRoomPreviewModel {
abstract class _ChatRoomPreviewModel implements ChatRoomPaginationModel {
const factory _ChatRoomPreviewModel(
{@JsonKey(name: "chatRooms")
required final List<ChatRoom> chatRooms}) = _$ChatRoomPreviewModelImpl;
{@JsonKey(name: "chatRooms") required final ChatRooms chatRooms,
@JsonKey(name: "number_of_unread_chat_rooms")
required final int unreadChatsCount}) = _$ChatRoomPreviewModelImpl;
factory _ChatRoomPreviewModel.fromJson(Map<String, dynamic> json) =
_$ChatRoomPreviewModelImpl.fromJson;
@override
@JsonKey(name: "chatRooms")
List<ChatRoom> get chatRooms;
ChatRooms get chatRooms;
@override
@JsonKey(name: "number_of_unread_chat_rooms")
int get unreadChatsCount;
/// Create a copy of ChatRoomPreviewModel
/// Create a copy of ChatRoomPaginationModel
/// with the given fields replaced by the non-null parameter values.
@override
@JsonKey(includeFromJson: false, includeToJson: false)
@@ -180,6 +217,218 @@ abstract class _ChatRoomPreviewModel implements ChatRoomPreviewModel {
get copyWith => throw _privateConstructorUsedError;
}
ChatRooms _$ChatRoomsFromJson(Map<String, dynamic> json) {
return _ChatRooms.fromJson(json);
}
/// @nodoc
mixin _$ChatRooms {
@JsonKey(name: "data")
List<ChatRoom> get data => throw _privateConstructorUsedError;
@JsonKey(name: "last_page")
int get lastPage => throw _privateConstructorUsedError;
@JsonKey(name: "current_page")
int get currentPage => throw _privateConstructorUsedError;
/// Serializes this ChatRooms to a JSON map.
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
/// Create a copy of ChatRooms
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
$ChatRoomsCopyWith<ChatRooms> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $ChatRoomsCopyWith<$Res> {
factory $ChatRoomsCopyWith(ChatRooms value, $Res Function(ChatRooms) then) =
_$ChatRoomsCopyWithImpl<$Res, ChatRooms>;
@useResult
$Res call(
{@JsonKey(name: "data") List<ChatRoom> data,
@JsonKey(name: "last_page") int lastPage,
@JsonKey(name: "current_page") int currentPage});
}
/// @nodoc
class _$ChatRoomsCopyWithImpl<$Res, $Val extends ChatRooms>
implements $ChatRoomsCopyWith<$Res> {
_$ChatRoomsCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of ChatRooms
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? data = null,
Object? lastPage = null,
Object? currentPage = null,
}) {
return _then(_value.copyWith(
data: null == data
? _value.data
: data // ignore: cast_nullable_to_non_nullable
as List<ChatRoom>,
lastPage: null == lastPage
? _value.lastPage
: lastPage // ignore: cast_nullable_to_non_nullable
as int,
currentPage: null == currentPage
? _value.currentPage
: currentPage // ignore: cast_nullable_to_non_nullable
as int,
) as $Val);
}
}
/// @nodoc
abstract class _$$ChatRoomsImplCopyWith<$Res>
implements $ChatRoomsCopyWith<$Res> {
factory _$$ChatRoomsImplCopyWith(
_$ChatRoomsImpl value, $Res Function(_$ChatRoomsImpl) then) =
__$$ChatRoomsImplCopyWithImpl<$Res>;
@override
@useResult
$Res call(
{@JsonKey(name: "data") List<ChatRoom> data,
@JsonKey(name: "last_page") int lastPage,
@JsonKey(name: "current_page") int currentPage});
}
/// @nodoc
class __$$ChatRoomsImplCopyWithImpl<$Res>
extends _$ChatRoomsCopyWithImpl<$Res, _$ChatRoomsImpl>
implements _$$ChatRoomsImplCopyWith<$Res> {
__$$ChatRoomsImplCopyWithImpl(
_$ChatRoomsImpl _value, $Res Function(_$ChatRoomsImpl) _then)
: super(_value, _then);
/// Create a copy of ChatRooms
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? data = null,
Object? lastPage = null,
Object? currentPage = null,
}) {
return _then(_$ChatRoomsImpl(
data: null == data
? _value._data
: data // ignore: cast_nullable_to_non_nullable
as List<ChatRoom>,
lastPage: null == lastPage
? _value.lastPage
: lastPage // ignore: cast_nullable_to_non_nullable
as int,
currentPage: null == currentPage
? _value.currentPage
: currentPage // ignore: cast_nullable_to_non_nullable
as int,
));
}
}
/// @nodoc
@JsonSerializable()
class _$ChatRoomsImpl implements _ChatRooms {
const _$ChatRoomsImpl(
{@JsonKey(name: "data") required final List<ChatRoom> data,
@JsonKey(name: "last_page") required this.lastPage,
@JsonKey(name: "current_page") required this.currentPage})
: _data = data;
factory _$ChatRoomsImpl.fromJson(Map<String, dynamic> json) =>
_$$ChatRoomsImplFromJson(json);
final List<ChatRoom> _data;
@override
@JsonKey(name: "data")
List<ChatRoom> get data {
if (_data is EqualUnmodifiableListView) return _data;
// ignore: implicit_dynamic_type
return EqualUnmodifiableListView(_data);
}
@override
@JsonKey(name: "last_page")
final int lastPage;
@override
@JsonKey(name: "current_page")
final int currentPage;
@override
String toString() {
return 'ChatRooms(data: $data, lastPage: $lastPage, currentPage: $currentPage)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$ChatRoomsImpl &&
const DeepCollectionEquality().equals(other._data, _data) &&
(identical(other.lastPage, lastPage) ||
other.lastPage == lastPage) &&
(identical(other.currentPage, currentPage) ||
other.currentPage == currentPage));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(runtimeType,
const DeepCollectionEquality().hash(_data), lastPage, currentPage);
/// Create a copy of ChatRooms
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$ChatRoomsImplCopyWith<_$ChatRoomsImpl> get copyWith =>
__$$ChatRoomsImplCopyWithImpl<_$ChatRoomsImpl>(this, _$identity);
@override
Map<String, dynamic> toJson() {
return _$$ChatRoomsImplToJson(
this,
);
}
}
abstract class _ChatRooms implements ChatRooms {
const factory _ChatRooms(
{@JsonKey(name: "data") required final List<ChatRoom> data,
@JsonKey(name: "last_page") required final int lastPage,
@JsonKey(name: "current_page") required final int currentPage}) =
_$ChatRoomsImpl;
factory _ChatRooms.fromJson(Map<String, dynamic> json) =
_$ChatRoomsImpl.fromJson;
@override
@JsonKey(name: "data")
List<ChatRoom> get data;
@override
@JsonKey(name: "last_page")
int get lastPage;
@override
@JsonKey(name: "current_page")
int get currentPage;
/// Create a copy of ChatRooms
/// with the given fields replaced by the non-null parameter values.
@override
@JsonKey(includeFromJson: false, includeToJson: false)
_$$ChatRoomsImplCopyWith<_$ChatRoomsImpl> get copyWith =>
throw _privateConstructorUsedError;
}
ChatRoom _$ChatRoomFromJson(Map<String, dynamic> json) {
return _ChatRoom.fromJson(json);
}

View File

@@ -1,6 +1,6 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'chat_room_preview_model.dart';
part of 'chat_room_pagination_model.dart';
// **************************************************************************
// JsonSerializableGenerator
@@ -9,15 +9,31 @@ part of 'chat_room_preview_model.dart';
_$ChatRoomPreviewModelImpl _$$ChatRoomPreviewModelImplFromJson(
Map<String, dynamic> json) =>
_$ChatRoomPreviewModelImpl(
chatRooms: (json['chatRooms'] as List<dynamic>)
.map((e) => ChatRoom.fromJson(e as Map<String, dynamic>))
.toList(),
chatRooms: ChatRooms.fromJson(json['chatRooms'] as Map<String, dynamic>),
unreadChatsCount: (json['number_of_unread_chat_rooms'] as num).toInt(),
);
Map<String, dynamic> _$$ChatRoomPreviewModelImplToJson(
_$ChatRoomPreviewModelImpl instance) =>
<String, dynamic>{
'chatRooms': instance.chatRooms,
'number_of_unread_chat_rooms': instance.unreadChatsCount,
};
_$ChatRoomsImpl _$$ChatRoomsImplFromJson(Map<String, dynamic> json) =>
_$ChatRoomsImpl(
data: (json['data'] as List<dynamic>)
.map((e) => ChatRoom.fromJson(e as Map<String, dynamic>))
.toList(),
lastPage: (json['last_page'] as num).toInt(),
currentPage: (json['current_page'] as num).toInt(),
);
Map<String, dynamic> _$$ChatRoomsImplToJson(_$ChatRoomsImpl instance) =>
<String, dynamic>{
'data': instance.data,
'last_page': instance.lastPage,
'current_page': instance.currentPage,
};
_$ChatRoomImpl _$$ChatRoomImplFromJson(Map<String, dynamic> json) =>