diff --git a/packages/stream_chat/lib/src/core/api/requests.dart b/packages/stream_chat/lib/src/core/api/requests.dart index 0bc49fc7..14995b10 100644 --- a/packages/stream_chat/lib/src/core/api/requests.dart +++ b/packages/stream_chat/lib/src/core/api/requests.dart @@ -15,7 +15,7 @@ class SortOption { /// ``` const SortOption( this.field, { - this.direction = DESC, + this.direction = SortOption.DESC, this.comparator, }); diff --git a/packages/stream_chat/lib/src/core/api/requests.g.dart b/packages/stream_chat/lib/src/core/api/requests.g.dart index fd0ac624..ef995997 100644 --- a/packages/stream_chat/lib/src/core/api/requests.g.dart +++ b/packages/stream_chat/lib/src/core/api/requests.g.dart @@ -6,12 +6,11 @@ part of 'requests.dart'; // JsonSerializableGenerator // ************************************************************************** -SortOption _$SortOptionFromJson(Map json) { - return SortOption( - json['field'] as String, - direction: json['direction'] as int, - ); -} +SortOption _$SortOptionFromJson(Map json) => + SortOption( + json['field'] as String, + direction: json['direction'] as int? ?? SortOption.DESC, + ); Map _$SortOptionToJson(SortOption instance) => { @@ -19,22 +18,20 @@ Map _$SortOptionToJson(SortOption instance) => 'direction': instance.direction, }; -PaginationParams _$PaginationParamsFromJson(Map json) { - return PaginationParams( - limit: json['limit'] as int, - offset: json['offset'] as int, - next: json['next'] as String?, - greaterThan: json['id_gt'] as String?, - greaterThanOrEqual: json['id_gte'] as String?, - lessThan: json['id_lt'] as String?, - lessThanOrEqual: json['id_lte'] as String?, - ); -} +PaginationParams _$PaginationParamsFromJson(Map json) => + PaginationParams( + limit: json['limit'] as int? ?? 10, + offset: json['offset'] as int?, + next: json['next'] as String?, + greaterThan: json['id_gt'] as String?, + greaterThanOrEqual: json['id_gte'] as String?, + lessThan: json['id_lt'] as String?, + lessThanOrEqual: json['id_lte'] as String?, + ); Map _$PaginationParamsToJson(PaginationParams instance) { final val = { 'limit': instance.limit, - 'offset': instance.offset, }; void writeNotNull(String key, dynamic value) { @@ -43,6 +40,7 @@ Map _$PaginationParamsToJson(PaginationParams instance) { } } + writeNotNull('offset', instance.offset); writeNotNull('next', instance.next); writeNotNull('id_gt', instance.greaterThan); writeNotNull('id_gte', instance.greaterThanOrEqual); diff --git a/packages/stream_chat/lib/src/core/api/responses.g.dart b/packages/stream_chat/lib/src/core/api/responses.g.dart index 10d96682..13d7d77b 100644 --- a/packages/stream_chat/lib/src/core/api/responses.g.dart +++ b/packages/stream_chat/lib/src/core/api/responses.g.dart @@ -6,14 +6,13 @@ part of 'responses.dart'; // JsonSerializableGenerator // ************************************************************************** -ErrorResponse _$ErrorResponseFromJson(Map json) { - return ErrorResponse() - ..duration = json['duration'] as String? - ..code = json['code'] as int? - ..message = json['message'] as String? - ..statusCode = json['StatusCode'] as int? - ..moreInfo = json['more_info'] as String?; -} +ErrorResponse _$ErrorResponseFromJson(Map json) => + ErrorResponse() + ..duration = json['duration'] as String? + ..code = json['code'] as int? + ..message = json['message'] as String? + ..statusCode = json['StatusCode'] as int? + ..moreInfo = json['more_info'] as String?; Map _$ErrorResponseToJson(ErrorResponse instance) => { @@ -24,275 +23,253 @@ Map _$ErrorResponseToJson(ErrorResponse instance) => 'more_info': instance.moreInfo, }; -SyncResponse _$SyncResponseFromJson(Map json) { - return SyncResponse() - ..duration = json['duration'] as String? - ..events = (json['events'] as List?) - ?.map((e) => Event.fromJson(e as Map)) - .toList() ?? - []; -} +SyncResponse _$SyncResponseFromJson(Map json) => SyncResponse() + ..duration = json['duration'] as String? + ..events = (json['events'] as List?) + ?.map((e) => Event.fromJson(e as Map)) + .toList() ?? + []; QueryChannelsResponse _$QueryChannelsResponseFromJson( - Map json) { - return QueryChannelsResponse() - ..duration = json['duration'] as String? - ..channels = (json['channels'] as List?) - ?.map((e) => ChannelState.fromJson(e as Map)) - .toList() ?? - []; -} + Map json) => + QueryChannelsResponse() + ..duration = json['duration'] as String? + ..channels = (json['channels'] as List?) + ?.map((e) => ChannelState.fromJson(e as Map)) + .toList() ?? + []; TranslateMessageResponse _$TranslateMessageResponseFromJson( - Map json) { - return TranslateMessageResponse() - ..duration = json['duration'] as String? - ..message = Message.fromJson(json['message'] as Map); -} + Map json) => + TranslateMessageResponse() + ..duration = json['duration'] as String? + ..message = Message.fromJson(json['message'] as Map); -QueryMembersResponse _$QueryMembersResponseFromJson(Map json) { - return QueryMembersResponse() - ..duration = json['duration'] as String? - ..members = (json['members'] as List?) - ?.map((e) => Member.fromJson(e as Map)) - .toList() ?? - []; -} +QueryMembersResponse _$QueryMembersResponseFromJson( + Map json) => + QueryMembersResponse() + ..duration = json['duration'] as String? + ..members = (json['members'] as List?) + ?.map((e) => Member.fromJson(e as Map)) + .toList() ?? + []; -QueryUsersResponse _$QueryUsersResponseFromJson(Map json) { - return QueryUsersResponse() - ..duration = json['duration'] as String? - ..users = (json['users'] as List?) - ?.map((e) => User.fromJson(e as Map)) - .toList() ?? - []; -} +QueryUsersResponse _$QueryUsersResponseFromJson(Map json) => + QueryUsersResponse() + ..duration = json['duration'] as String? + ..users = (json['users'] as List?) + ?.map((e) => User.fromJson(e as Map)) + .toList() ?? + []; QueryReactionsResponse _$QueryReactionsResponseFromJson( - Map json) { - return QueryReactionsResponse() - ..duration = json['duration'] as String? - ..reactions = (json['reactions'] as List?) - ?.map((e) => Reaction.fromJson(e as Map)) - .toList() ?? - []; -} + Map json) => + QueryReactionsResponse() + ..duration = json['duration'] as String? + ..reactions = (json['reactions'] as List?) + ?.map((e) => Reaction.fromJson(e as Map)) + .toList() ?? + []; -QueryRepliesResponse _$QueryRepliesResponseFromJson(Map json) { - return QueryRepliesResponse() - ..duration = json['duration'] as String? - ..messages = (json['messages'] as List?) - ?.map((e) => Message.fromJson(e as Map)) - .toList() ?? - []; -} +QueryRepliesResponse _$QueryRepliesResponseFromJson( + Map json) => + QueryRepliesResponse() + ..duration = json['duration'] as String? + ..messages = (json['messages'] as List?) + ?.map((e) => Message.fromJson(e as Map)) + .toList() ?? + []; -ListDevicesResponse _$ListDevicesResponseFromJson(Map json) { - return ListDevicesResponse() - ..duration = json['duration'] as String? - ..devices = (json['devices'] as List?) - ?.map((e) => Device.fromJson(e as Map)) - .toList() ?? - []; -} +ListDevicesResponse _$ListDevicesResponseFromJson(Map json) => + ListDevicesResponse() + ..duration = json['duration'] as String? + ..devices = (json['devices'] as List?) + ?.map((e) => Device.fromJson(e as Map)) + .toList() ?? + []; -SendFileResponse _$SendFileResponseFromJson(Map json) { - return SendFileResponse() - ..duration = json['duration'] as String? - ..file = json['file'] as String; -} +SendFileResponse _$SendFileResponseFromJson(Map json) => + SendFileResponse() + ..duration = json['duration'] as String? + ..file = json['file'] as String; -SendImageResponse _$SendImageResponseFromJson(Map json) { - return SendImageResponse() - ..duration = json['duration'] as String? - ..file = json['file'] as String; -} +SendImageResponse _$SendImageResponseFromJson(Map json) => + SendImageResponse() + ..duration = json['duration'] as String? + ..file = json['file'] as String; -SendReactionResponse _$SendReactionResponseFromJson(Map json) { - return SendReactionResponse() - ..duration = json['duration'] as String? - ..message = Message.fromJson(json['message'] as Map) - ..reaction = Reaction.fromJson(json['reaction'] as Map); -} +SendReactionResponse _$SendReactionResponseFromJson( + Map json) => + SendReactionResponse() + ..duration = json['duration'] as String? + ..message = Message.fromJson(json['message'] as Map) + ..reaction = Reaction.fromJson(json['reaction'] as Map); ConnectGuestUserResponse _$ConnectGuestUserResponseFromJson( - Map json) { - return ConnectGuestUserResponse() - ..duration = json['duration'] as String? - ..accessToken = json['access_token'] as String - ..user = User.fromJson(json['user'] as Map); -} + Map json) => + ConnectGuestUserResponse() + ..duration = json['duration'] as String? + ..accessToken = json['access_token'] as String + ..user = User.fromJson(json['user'] as Map); -UpdateUsersResponse _$UpdateUsersResponseFromJson(Map json) { - return UpdateUsersResponse() - ..duration = json['duration'] as String? - ..users = (json['users'] as Map?)?.map( - (k, e) => MapEntry(k, User.fromJson(e as Map)), - ) ?? - {}; -} +UpdateUsersResponse _$UpdateUsersResponseFromJson(Map json) => + UpdateUsersResponse() + ..duration = json['duration'] as String? + ..users = (json['users'] as Map?)?.map( + (k, e) => MapEntry(k, User.fromJson(e as Map)), + ) ?? + {}; UpdateMessageResponse _$UpdateMessageResponseFromJson( - Map json) { - return UpdateMessageResponse() - ..duration = json['duration'] as String? - ..message = Message.fromJson(json['message'] as Map); -} + Map json) => + UpdateMessageResponse() + ..duration = json['duration'] as String? + ..message = Message.fromJson(json['message'] as Map); -SendMessageResponse _$SendMessageResponseFromJson(Map json) { - return SendMessageResponse() - ..duration = json['duration'] as String? - ..message = Message.fromJson(json['message'] as Map); -} +SendMessageResponse _$SendMessageResponseFromJson(Map json) => + SendMessageResponse() + ..duration = json['duration'] as String? + ..message = Message.fromJson(json['message'] as Map); -GetMessageResponse _$GetMessageResponseFromJson(Map json) { - return GetMessageResponse() - ..duration = json['duration'] as String? - ..message = Message.fromJson(json['message'] as Map) - ..channel = json['channel'] == null - ? null - : ChannelModel.fromJson(json['channel'] as Map); -} +GetMessageResponse _$GetMessageResponseFromJson(Map json) => + GetMessageResponse() + ..duration = json['duration'] as String? + ..message = Message.fromJson(json['message'] as Map) + ..channel = json['channel'] == null + ? null + : ChannelModel.fromJson(json['channel'] as Map); SearchMessagesResponse _$SearchMessagesResponseFromJson( - Map json) { - return SearchMessagesResponse() - ..duration = json['duration'] as String? - ..results = (json['results'] as List?) - ?.map((e) => GetMessageResponse.fromJson(e as Map)) - .toList() ?? - [] - ..next = json['next'] as String? - ..previous = json['previous'] as String?; -} + Map json) => + SearchMessagesResponse() + ..duration = json['duration'] as String? + ..results = (json['results'] as List?) + ?.map( + (e) => GetMessageResponse.fromJson(e as Map)) + .toList() ?? + [] + ..next = json['next'] as String? + ..previous = json['previous'] as String?; GetMessagesByIdResponse _$GetMessagesByIdResponseFromJson( - Map json) { - return GetMessagesByIdResponse() - ..duration = json['duration'] as String? - ..messages = (json['messages'] as List?) - ?.map((e) => Message.fromJson(e as Map)) - .toList() ?? - []; -} + Map json) => + GetMessagesByIdResponse() + ..duration = json['duration'] as String? + ..messages = (json['messages'] as List?) + ?.map((e) => Message.fromJson(e as Map)) + .toList() ?? + []; UpdateChannelResponse _$UpdateChannelResponseFromJson( - Map json) { - return UpdateChannelResponse() - ..duration = json['duration'] as String? - ..channel = ChannelModel.fromJson(json['channel'] as Map) - ..members = (json['members'] as List?) - ?.map((e) => Member.fromJson(e as Map)) - .toList() - ..message = json['message'] == null - ? null - : Message.fromJson(json['message'] as Map); -} + Map json) => + UpdateChannelResponse() + ..duration = json['duration'] as String? + ..channel = ChannelModel.fromJson(json['channel'] as Map) + ..members = (json['members'] as List?) + ?.map((e) => Member.fromJson(e as Map)) + .toList() + ..message = json['message'] == null + ? null + : Message.fromJson(json['message'] as Map); PartialUpdateChannelResponse _$PartialUpdateChannelResponseFromJson( - Map json) { - return PartialUpdateChannelResponse() - ..duration = json['duration'] as String? - ..channel = ChannelModel.fromJson(json['channel'] as Map) - ..members = (json['members'] as List?) - ?.map((e) => Member.fromJson(e as Map)) - .toList(); -} + Map json) => + PartialUpdateChannelResponse() + ..duration = json['duration'] as String? + ..channel = ChannelModel.fromJson(json['channel'] as Map) + ..members = (json['members'] as List?) + ?.map((e) => Member.fromJson(e as Map)) + .toList(); InviteMembersResponse _$InviteMembersResponseFromJson( - Map json) { - return InviteMembersResponse() - ..duration = json['duration'] as String? - ..channel = ChannelModel.fromJson(json['channel'] as Map) - ..members = (json['members'] as List?) - ?.map((e) => Member.fromJson(e as Map)) - .toList() ?? - [] - ..message = json['message'] == null - ? null - : Message.fromJson(json['message'] as Map); -} + Map json) => + InviteMembersResponse() + ..duration = json['duration'] as String? + ..channel = ChannelModel.fromJson(json['channel'] as Map) + ..members = (json['members'] as List?) + ?.map((e) => Member.fromJson(e as Map)) + .toList() ?? + [] + ..message = json['message'] == null + ? null + : Message.fromJson(json['message'] as Map); RemoveMembersResponse _$RemoveMembersResponseFromJson( - Map json) { - return RemoveMembersResponse() - ..duration = json['duration'] as String? - ..channel = ChannelModel.fromJson(json['channel'] as Map) - ..members = (json['members'] as List?) - ?.map((e) => Member.fromJson(e as Map)) - .toList() ?? - [] - ..message = json['message'] == null - ? null - : Message.fromJson(json['message'] as Map); -} + Map json) => + RemoveMembersResponse() + ..duration = json['duration'] as String? + ..channel = ChannelModel.fromJson(json['channel'] as Map) + ..members = (json['members'] as List?) + ?.map((e) => Member.fromJson(e as Map)) + .toList() ?? + [] + ..message = json['message'] == null + ? null + : Message.fromJson(json['message'] as Map); -SendActionResponse _$SendActionResponseFromJson(Map json) { - return SendActionResponse() - ..duration = json['duration'] as String? - ..message = json['message'] == null - ? null - : Message.fromJson(json['message'] as Map); -} +SendActionResponse _$SendActionResponseFromJson(Map json) => + SendActionResponse() + ..duration = json['duration'] as String? + ..message = json['message'] == null + ? null + : Message.fromJson(json['message'] as Map); -AddMembersResponse _$AddMembersResponseFromJson(Map json) { - return AddMembersResponse() - ..duration = json['duration'] as String? - ..channel = ChannelModel.fromJson(json['channel'] as Map) - ..members = (json['members'] as List?) - ?.map((e) => Member.fromJson(e as Map)) - .toList() ?? - [] - ..message = json['message'] == null - ? null - : Message.fromJson(json['message'] as Map); -} +AddMembersResponse _$AddMembersResponseFromJson(Map json) => + AddMembersResponse() + ..duration = json['duration'] as String? + ..channel = ChannelModel.fromJson(json['channel'] as Map) + ..members = (json['members'] as List?) + ?.map((e) => Member.fromJson(e as Map)) + .toList() ?? + [] + ..message = json['message'] == null + ? null + : Message.fromJson(json['message'] as Map); -AcceptInviteResponse _$AcceptInviteResponseFromJson(Map json) { - return AcceptInviteResponse() - ..duration = json['duration'] as String? - ..channel = ChannelModel.fromJson(json['channel'] as Map) - ..members = (json['members'] as List?) - ?.map((e) => Member.fromJson(e as Map)) - .toList() ?? - [] - ..message = json['message'] == null - ? null - : Message.fromJson(json['message'] as Map); -} +AcceptInviteResponse _$AcceptInviteResponseFromJson( + Map json) => + AcceptInviteResponse() + ..duration = json['duration'] as String? + ..channel = ChannelModel.fromJson(json['channel'] as Map) + ..members = (json['members'] as List?) + ?.map((e) => Member.fromJson(e as Map)) + .toList() ?? + [] + ..message = json['message'] == null + ? null + : Message.fromJson(json['message'] as Map); -RejectInviteResponse _$RejectInviteResponseFromJson(Map json) { - return RejectInviteResponse() - ..duration = json['duration'] as String? - ..channel = ChannelModel.fromJson(json['channel'] as Map) - ..members = (json['members'] as List?) - ?.map((e) => Member.fromJson(e as Map)) - .toList() ?? - [] - ..message = json['message'] == null - ? null - : Message.fromJson(json['message'] as Map); -} +RejectInviteResponse _$RejectInviteResponseFromJson( + Map json) => + RejectInviteResponse() + ..duration = json['duration'] as String? + ..channel = ChannelModel.fromJson(json['channel'] as Map) + ..members = (json['members'] as List?) + ?.map((e) => Member.fromJson(e as Map)) + .toList() ?? + [] + ..message = json['message'] == null + ? null + : Message.fromJson(json['message'] as Map); -EmptyResponse _$EmptyResponseFromJson(Map json) { - return EmptyResponse()..duration = json['duration'] as String?; -} +EmptyResponse _$EmptyResponseFromJson(Map json) => + EmptyResponse()..duration = json['duration'] as String?; -ChannelStateResponse _$ChannelStateResponseFromJson(Map json) { - return ChannelStateResponse() - ..duration = json['duration'] as String? - ..channel = ChannelModel.fromJson(json['channel'] as Map) - ..messages = (json['messages'] as List?) - ?.map((e) => Message.fromJson(e as Map)) - .toList() ?? - [] - ..members = (json['members'] as List?) - ?.map((e) => Member.fromJson(e as Map)) - .toList() ?? - [] - ..watcherCount = json['watcher_count'] as int? ?? 0 - ..read = (json['read'] as List?) - ?.map((e) => Read.fromJson(e as Map)) - .toList() ?? - []; -} +ChannelStateResponse _$ChannelStateResponseFromJson( + Map json) => + ChannelStateResponse() + ..duration = json['duration'] as String? + ..channel = ChannelModel.fromJson(json['channel'] as Map) + ..messages = (json['messages'] as List?) + ?.map((e) => Message.fromJson(e as Map)) + .toList() ?? + [] + ..members = (json['members'] as List?) + ?.map((e) => Member.fromJson(e as Map)) + .toList() ?? + [] + ..watcherCount = json['watcher_count'] as int? ?? 0 + ..read = (json['read'] as List?) + ?.map((e) => Read.fromJson(e as Map)) + .toList() ?? + []; diff --git a/packages/stream_chat/lib/src/core/models/action.dart b/packages/stream_chat/lib/src/core/models/action.dart index 16a307e7..709fbfe0 100644 --- a/packages/stream_chat/lib/src/core/models/action.dart +++ b/packages/stream_chat/lib/src/core/models/action.dart @@ -21,7 +21,6 @@ class Action { final String name; /// The style of the action - @JsonKey(defaultValue: 'default') final String style; /// The test of the action diff --git a/packages/stream_chat/lib/src/core/models/action.g.dart b/packages/stream_chat/lib/src/core/models/action.g.dart index 9ae999ed..2c9148d9 100644 --- a/packages/stream_chat/lib/src/core/models/action.g.dart +++ b/packages/stream_chat/lib/src/core/models/action.g.dart @@ -6,15 +6,13 @@ part of 'action.dart'; // JsonSerializableGenerator // ************************************************************************** -Action _$ActionFromJson(Map json) { - return Action( - name: json['name'] as String, - style: json['style'] as String? ?? 'default', - text: json['text'] as String, - type: json['type'] as String, - value: json['value'] as String?, - ); -} +Action _$ActionFromJson(Map json) => Action( + name: json['name'] as String, + style: json['style'] as String? ?? 'default', + text: json['text'] as String, + type: json['type'] as String, + value: json['value'] as String?, + ); Map _$ActionToJson(Action instance) => { 'name': instance.name, diff --git a/packages/stream_chat/lib/src/core/models/attachment.dart b/packages/stream_chat/lib/src/core/models/attachment.dart index 0ef9db7a..ca7e0afc 100644 --- a/packages/stream_chat/lib/src/core/models/attachment.dart +++ b/packages/stream_chat/lib/src/core/models/attachment.dart @@ -117,10 +117,7 @@ class Attachment extends Equatable { late final UploadState uploadState; /// Map of custom channel extraData - @JsonKey( - includeIfNull: false, - defaultValue: {}, - ) + @JsonKey(includeIfNull: false) final Map extraData; /// The attachment ID. diff --git a/packages/stream_chat/lib/src/core/models/attachment.g.dart b/packages/stream_chat/lib/src/core/models/attachment.g.dart index de129ab6..381eb99c 100644 --- a/packages/stream_chat/lib/src/core/models/attachment.g.dart +++ b/packages/stream_chat/lib/src/core/models/attachment.g.dart @@ -6,39 +6,37 @@ part of 'attachment.dart'; // JsonSerializableGenerator // ************************************************************************** -Attachment _$AttachmentFromJson(Map json) { - return Attachment( - id: json['id'] as String?, - type: json['type'] as String?, - titleLink: json['title_link'] as String?, - title: json['title'] as String?, - thumbUrl: json['thumb_url'] as String?, - text: json['text'] as String?, - pretext: json['pretext'] as String?, - ogScrapeUrl: json['og_scrape_url'] as String?, - imageUrl: json['image_url'] as String?, - footerIcon: json['footer_icon'] as String?, - footer: json['footer'] as String?, - fields: json['fields'], - fallback: json['fallback'] as String?, - color: json['color'] as String?, - authorName: json['author_name'] as String?, - authorLink: json['author_link'] as String?, - authorIcon: json['author_icon'] as String?, - assetUrl: json['asset_url'] as String?, - actions: (json['actions'] as List?) - ?.map((e) => Action.fromJson(e as Map)) - .toList() ?? - [], - extraData: json['extra_data'] as Map? ?? {}, - file: json['file'] == null - ? null - : AttachmentFile.fromJson(json['file'] as Map), - uploadState: json['upload_state'] == null - ? null - : UploadState.fromJson(json['upload_state'] as Map), - ); -} +Attachment _$AttachmentFromJson(Map json) => Attachment( + id: json['id'] as String?, + type: json['type'] as String?, + titleLink: json['title_link'] as String?, + title: json['title'] as String?, + thumbUrl: json['thumb_url'] as String?, + text: json['text'] as String?, + pretext: json['pretext'] as String?, + ogScrapeUrl: json['og_scrape_url'] as String?, + imageUrl: json['image_url'] as String?, + footerIcon: json['footer_icon'] as String?, + footer: json['footer'] as String?, + fields: json['fields'], + fallback: json['fallback'] as String?, + color: json['color'] as String?, + authorName: json['author_name'] as String?, + authorLink: json['author_link'] as String?, + authorIcon: json['author_icon'] as String?, + assetUrl: json['asset_url'] as String?, + actions: (json['actions'] as List?) + ?.map((e) => Action.fromJson(e as Map)) + .toList() ?? + [], + extraData: json['extra_data'] as Map? ?? const {}, + file: json['file'] == null + ? null + : AttachmentFile.fromJson(json['file'] as Map), + uploadState: json['upload_state'] == null + ? null + : UploadState.fromJson(json['upload_state'] as Map), + ); Map _$AttachmentToJson(Attachment instance) { final val = {}; diff --git a/packages/stream_chat/lib/src/core/models/attachment_file.freezed.dart b/packages/stream_chat/lib/src/core/models/attachment_file.freezed.dart index 5d7075c3..4956274a 100644 --- a/packages/stream_chat/lib/src/core/models/attachment_file.freezed.dart +++ b/packages/stream_chat/lib/src/core/models/attachment_file.freezed.dart @@ -1,5 +1,6 @@ +// coverage:ignore-file // GENERATED CODE - DO NOT MODIFY BY HAND -// 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 +// 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 part of 'attachment_file.dart'; @@ -13,7 +14,7 @@ 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 informations: https://github.com/rrousselGit/freezed#custom-getters-and-methods'); UploadState _$UploadStateFromJson(Map json) { - switch (json['runtimeType'] as String) { + switch (json['runtimeType'] as String?) { case 'preparing': return Preparing.fromJson(json); case 'inProgress': @@ -24,7 +25,8 @@ UploadState _$UploadStateFromJson(Map json) { return Failed.fromJson(json); default: - throw FallThroughError(); + throw CheckedFromJsonException(json, 'runtimeType', 'UploadState', + 'Invalid union type "${json['runtimeType']}"!'); } } @@ -72,6 +74,14 @@ mixin _$UploadState { }) => throw _privateConstructorUsedError; @optionalTypeArgs + TResult? whenOrNull({ + TResult Function()? preparing, + TResult Function(int uploaded, int total)? inProgress, + TResult Function()? success, + TResult Function(String error)? failed, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs TResult maybeWhen({ TResult Function()? preparing, TResult Function(int uploaded, int total)? inProgress, @@ -89,6 +99,14 @@ mixin _$UploadState { }) => throw _privateConstructorUsedError; @optionalTypeArgs + TResult? mapOrNull({ + TResult Function(Preparing value)? preparing, + TResult Function(InProgress value)? inProgress, + TResult Function(Success value)? success, + TResult Function(Failed value)? failed, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs TResult maybeMap({ TResult Function(Preparing value)? preparing, TResult Function(InProgress value)? inProgress, @@ -138,7 +156,7 @@ class _$Preparing implements Preparing { const _$Preparing(); factory _$Preparing.fromJson(Map json) => - _$_$PreparingFromJson(json); + _$$PreparingFromJson(json); @override String toString() { @@ -164,6 +182,17 @@ class _$Preparing implements Preparing { return preparing(); } + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult Function()? preparing, + TResult Function(int uploaded, int total)? inProgress, + TResult Function()? success, + TResult Function(String error)? failed, + }) { + return preparing?.call(); + } + @override @optionalTypeArgs TResult maybeWhen({ @@ -190,6 +219,17 @@ class _$Preparing implements Preparing { return preparing(this); } + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult Function(Preparing value)? preparing, + TResult Function(InProgress value)? inProgress, + TResult Function(Success value)? success, + TResult Function(Failed value)? failed, + }) { + return preparing?.call(this); + } + @override @optionalTypeArgs TResult maybeMap({ @@ -207,7 +247,7 @@ class _$Preparing implements Preparing { @override Map toJson() { - return _$_$PreparingToJson(this)..['runtimeType'] = 'preparing'; + return _$$PreparingToJson(this)..['runtimeType'] = 'preparing'; } } @@ -258,7 +298,7 @@ class _$InProgress implements InProgress { const _$InProgress({required this.uploaded, required this.total}); factory _$InProgress.fromJson(Map json) => - _$_$InProgressFromJson(json); + _$$InProgressFromJson(json); @override final int uploaded; @@ -303,6 +343,17 @@ class _$InProgress implements InProgress { return inProgress(uploaded, total); } + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult Function()? preparing, + TResult Function(int uploaded, int total)? inProgress, + TResult Function()? success, + TResult Function(String error)? failed, + }) { + return inProgress?.call(uploaded, total); + } + @override @optionalTypeArgs TResult maybeWhen({ @@ -329,6 +380,17 @@ class _$InProgress implements InProgress { return inProgress(this); } + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult Function(Preparing value)? preparing, + TResult Function(InProgress value)? inProgress, + TResult Function(Success value)? success, + TResult Function(Failed value)? failed, + }) { + return inProgress?.call(this); + } + @override @optionalTypeArgs TResult maybeMap({ @@ -346,7 +408,7 @@ class _$InProgress implements InProgress { @override Map toJson() { - return _$_$InProgressToJson(this)..['runtimeType'] = 'inProgress'; + return _$$InProgressToJson(this)..['runtimeType'] = 'inProgress'; } } @@ -386,7 +448,7 @@ class _$Success implements Success { const _$Success(); factory _$Success.fromJson(Map json) => - _$_$SuccessFromJson(json); + _$$SuccessFromJson(json); @override String toString() { @@ -412,6 +474,17 @@ class _$Success implements Success { return success(); } + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult Function()? preparing, + TResult Function(int uploaded, int total)? inProgress, + TResult Function()? success, + TResult Function(String error)? failed, + }) { + return success?.call(); + } + @override @optionalTypeArgs TResult maybeWhen({ @@ -438,6 +511,17 @@ class _$Success implements Success { return success(this); } + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult Function(Preparing value)? preparing, + TResult Function(InProgress value)? inProgress, + TResult Function(Success value)? success, + TResult Function(Failed value)? failed, + }) { + return success?.call(this); + } + @override @optionalTypeArgs TResult maybeMap({ @@ -455,7 +539,7 @@ class _$Success implements Success { @override Map toJson() { - return _$_$SuccessToJson(this)..['runtimeType'] = 'success'; + return _$$SuccessToJson(this)..['runtimeType'] = 'success'; } } @@ -500,7 +584,7 @@ class _$Failed implements Failed { const _$Failed({required this.error}); factory _$Failed.fromJson(Map json) => - _$_$FailedFromJson(json); + _$$FailedFromJson(json); @override final String error; @@ -538,6 +622,17 @@ class _$Failed implements Failed { return failed(error); } + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult Function()? preparing, + TResult Function(int uploaded, int total)? inProgress, + TResult Function()? success, + TResult Function(String error)? failed, + }) { + return failed?.call(error); + } + @override @optionalTypeArgs TResult maybeWhen({ @@ -564,6 +659,17 @@ class _$Failed implements Failed { return failed(this); } + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult Function(Preparing value)? preparing, + TResult Function(InProgress value)? inProgress, + TResult Function(Success value)? success, + TResult Function(Failed value)? failed, + }) { + return failed?.call(this); + } + @override @optionalTypeArgs TResult maybeMap({ @@ -581,7 +687,7 @@ class _$Failed implements Failed { @override Map toJson() { - return _$_$FailedToJson(this)..['runtimeType'] = 'failed'; + return _$$FailedToJson(this)..['runtimeType'] = 'failed'; } } diff --git a/packages/stream_chat/lib/src/core/models/attachment_file.g.dart b/packages/stream_chat/lib/src/core/models/attachment_file.g.dart index 5844ae16..f36c269d 100644 --- a/packages/stream_chat/lib/src/core/models/attachment_file.g.dart +++ b/packages/stream_chat/lib/src/core/models/attachment_file.g.dart @@ -6,14 +6,13 @@ part of 'attachment_file.dart'; // JsonSerializableGenerator // ************************************************************************** -AttachmentFile _$AttachmentFileFromJson(Map json) { - return AttachmentFile( - size: json['size'] as int?, - path: json['path'] as String?, - name: json['name'] as String?, - bytes: _fromString(json['bytes'] as String?), - ); -} +AttachmentFile _$AttachmentFileFromJson(Map json) => + AttachmentFile( + size: json['size'] as int?, + path: json['path'] as String?, + name: json['name'] as String?, + bytes: _fromString(json['bytes'] as String?), + ); Map _$AttachmentFileToJson(AttachmentFile instance) => { @@ -23,39 +22,31 @@ Map _$AttachmentFileToJson(AttachmentFile instance) => 'size': instance.size, }; -_$Preparing _$_$PreparingFromJson(Map json) { - return _$Preparing(); -} +_$Preparing _$$PreparingFromJson(Map json) => _$Preparing(); -Map _$_$PreparingToJson(_$Preparing instance) => +Map _$$PreparingToJson(_$Preparing instance) => {}; -_$InProgress _$_$InProgressFromJson(Map json) { - return _$InProgress( - uploaded: json['uploaded'] as int, - total: json['total'] as int, - ); -} +_$InProgress _$$InProgressFromJson(Map json) => _$InProgress( + uploaded: json['uploaded'] as int, + total: json['total'] as int, + ); -Map _$_$InProgressToJson(_$InProgress instance) => +Map _$$InProgressToJson(_$InProgress instance) => { 'uploaded': instance.uploaded, 'total': instance.total, }; -_$Success _$_$SuccessFromJson(Map json) { - return _$Success(); -} +_$Success _$$SuccessFromJson(Map json) => _$Success(); -Map _$_$SuccessToJson(_$Success instance) => +Map _$$SuccessToJson(_$Success instance) => {}; -_$Failed _$_$FailedFromJson(Map json) { - return _$Failed( - error: json['error'] as String, - ); -} +_$Failed _$$FailedFromJson(Map json) => _$Failed( + error: json['error'] as String, + ); -Map _$_$FailedToJson(_$Failed instance) => { +Map _$$FailedToJson(_$Failed instance) => { 'error': instance.error, }; diff --git a/packages/stream_chat/lib/src/core/models/channel_config.dart b/packages/stream_chat/lib/src/core/models/channel_config.dart index 2d5182b3..158738e6 100644 --- a/packages/stream_chat/lib/src/core/models/channel_config.dart +++ b/packages/stream_chat/lib/src/core/models/channel_config.dart @@ -31,15 +31,12 @@ class ChannelConfig { _$ChannelConfigFromJson(json); /// Moderation configuration - @JsonKey(defaultValue: 'flag') final String automod; /// List of available commands - @JsonKey(defaultValue: []) final List commands; /// True if the channel should send connect events - @JsonKey(defaultValue: false) final bool connectEvents; /// Date of channel creation @@ -49,43 +46,33 @@ class ChannelConfig { final DateTime updatedAt; /// Max channel message length - @JsonKey(defaultValue: 0) final int maxMessageLength; /// Duration of message retention - @JsonKey(defaultValue: '') final String messageRetention; /// True if users can be muted - @JsonKey(defaultValue: false) final bool mutes; /// True if reaction are active for this channel - @JsonKey(defaultValue: false) final bool reactions; /// True if readEvents are active for this channel - @JsonKey(defaultValue: false) final bool readEvents; /// True if reply message are active for this channel - @JsonKey(defaultValue: false) final bool replies; /// True if it's possible to perform a search in this channel - @JsonKey(defaultValue: false) final bool search; /// True if typing events should be sent for this channel - @JsonKey(defaultValue: false) final bool typingEvents; /// True if it's possible to upload files to this channel - @JsonKey(defaultValue: false) final bool uploads; /// True if urls appears as attachments - @JsonKey(defaultValue: false) final bool urlEnrichment; /// Serialize to json diff --git a/packages/stream_chat/lib/src/core/models/channel_config.g.dart b/packages/stream_chat/lib/src/core/models/channel_config.g.dart index 723281c0..48b2a739 100644 --- a/packages/stream_chat/lib/src/core/models/channel_config.g.dart +++ b/packages/stream_chat/lib/src/core/models/channel_config.g.dart @@ -6,32 +6,31 @@ part of 'channel_config.dart'; // JsonSerializableGenerator // ************************************************************************** -ChannelConfig _$ChannelConfigFromJson(Map json) { - return ChannelConfig( - automod: json['automod'] as String? ?? 'flag', - commands: (json['commands'] as List?) - ?.map((e) => Command.fromJson(e as Map)) - .toList() ?? - [], - connectEvents: json['connect_events'] as bool? ?? false, - createdAt: json['created_at'] == null - ? null - : DateTime.parse(json['created_at'] as String), - updatedAt: json['updated_at'] == null - ? null - : DateTime.parse(json['updated_at'] as String), - maxMessageLength: json['max_message_length'] as int? ?? 0, - messageRetention: json['message_retention'] as String? ?? '', - mutes: json['mutes'] as bool? ?? false, - reactions: json['reactions'] as bool? ?? false, - readEvents: json['read_events'] as bool? ?? false, - replies: json['replies'] as bool? ?? false, - search: json['search'] as bool? ?? false, - typingEvents: json['typing_events'] as bool? ?? false, - uploads: json['uploads'] as bool? ?? false, - urlEnrichment: json['url_enrichment'] as bool? ?? false, - ); -} +ChannelConfig _$ChannelConfigFromJson(Map json) => + ChannelConfig( + automod: json['automod'] as String? ?? 'flag', + commands: (json['commands'] as List?) + ?.map((e) => Command.fromJson(e as Map)) + .toList() ?? + const [], + connectEvents: json['connect_events'] as bool? ?? false, + createdAt: json['created_at'] == null + ? null + : DateTime.parse(json['created_at'] as String), + updatedAt: json['updated_at'] == null + ? null + : DateTime.parse(json['updated_at'] as String), + maxMessageLength: json['max_message_length'] as int? ?? 0, + messageRetention: json['message_retention'] as String? ?? '', + mutes: json['mutes'] as bool? ?? false, + reactions: json['reactions'] as bool? ?? false, + readEvents: json['read_events'] as bool? ?? false, + replies: json['replies'] as bool? ?? false, + search: json['search'] as bool? ?? false, + typingEvents: json['typing_events'] as bool? ?? false, + uploads: json['uploads'] as bool? ?? false, + urlEnrichment: json['url_enrichment'] as bool? ?? false, + ); Map _$ChannelConfigToJson(ChannelConfig instance) => { diff --git a/packages/stream_chat/lib/src/core/models/channel_model.dart b/packages/stream_chat/lib/src/core/models/channel_model.dart index 31ac4923..7892cc10 100644 --- a/packages/stream_chat/lib/src/core/models/channel_model.dart +++ b/packages/stream_chat/lib/src/core/models/channel_model.dart @@ -59,7 +59,7 @@ class ChannelModel { final User? createdBy; /// True if this channel is frozen - @JsonKey(includeIfNull: false, defaultValue: false) + @JsonKey(includeIfNull: false) final bool frozen; /// The date of the last message @@ -79,18 +79,15 @@ class ChannelModel { final DateTime? deletedAt; /// The count of this channel members - @JsonKey(includeIfNull: false, toJson: Serializer.readOnly, defaultValue: 0) + @JsonKey(includeIfNull: false, toJson: Serializer.readOnly) final int memberCount; /// The number of seconds in a cooldown - @JsonKey(includeIfNull: false, defaultValue: 0) + @JsonKey(includeIfNull: false) final int cooldown; /// Map of custom channel extraData - @JsonKey( - includeIfNull: false, - defaultValue: {}, - ) + @JsonKey(includeIfNull: false) final Map extraData; /// The team the channel belongs to diff --git a/packages/stream_chat/lib/src/core/models/channel_model.g.dart b/packages/stream_chat/lib/src/core/models/channel_model.g.dart index d9adf94b..94d9a81a 100644 --- a/packages/stream_chat/lib/src/core/models/channel_model.g.dart +++ b/packages/stream_chat/lib/src/core/models/channel_model.g.dart @@ -6,36 +6,34 @@ part of 'channel_model.dart'; // JsonSerializableGenerator // ************************************************************************** -ChannelModel _$ChannelModelFromJson(Map json) { - return ChannelModel( - id: json['id'] as String?, - type: json['type'] as String?, - cid: json['cid'] as String?, - config: json['config'] == null - ? null - : ChannelConfig.fromJson(json['config'] as Map), - createdBy: json['created_by'] == null - ? null - : User.fromJson(json['created_by'] as Map), - frozen: json['frozen'] as bool? ?? false, - lastMessageAt: json['last_message_at'] == null - ? null - : DateTime.parse(json['last_message_at'] as String), - createdAt: json['created_at'] == null - ? null - : DateTime.parse(json['created_at'] as String), - updatedAt: json['updated_at'] == null - ? null - : DateTime.parse(json['updated_at'] as String), - deletedAt: json['deleted_at'] == null - ? null - : DateTime.parse(json['deleted_at'] as String), - memberCount: json['member_count'] as int? ?? 0, - extraData: json['extra_data'] as Map? ?? {}, - team: json['team'] as String?, - cooldown: json['cooldown'] as int? ?? 0, - ); -} +ChannelModel _$ChannelModelFromJson(Map json) => ChannelModel( + id: json['id'] as String?, + type: json['type'] as String?, + cid: json['cid'] as String?, + config: json['config'] == null + ? null + : ChannelConfig.fromJson(json['config'] as Map), + createdBy: json['created_by'] == null + ? null + : User.fromJson(json['created_by'] as Map), + frozen: json['frozen'] as bool? ?? false, + lastMessageAt: json['last_message_at'] == null + ? null + : DateTime.parse(json['last_message_at'] as String), + createdAt: json['created_at'] == null + ? null + : DateTime.parse(json['created_at'] as String), + updatedAt: json['updated_at'] == null + ? null + : DateTime.parse(json['updated_at'] as String), + deletedAt: json['deleted_at'] == null + ? null + : DateTime.parse(json['deleted_at'] as String), + memberCount: json['member_count'] as int? ?? 0, + extraData: json['extra_data'] as Map? ?? const {}, + team: json['team'] as String?, + cooldown: json['cooldown'] as int? ?? 0, + ); Map _$ChannelModelToJson(ChannelModel instance) { final val = { diff --git a/packages/stream_chat/lib/src/core/models/channel_state.dart b/packages/stream_chat/lib/src/core/models/channel_state.dart index 998efa98..fb5fc64f 100644 --- a/packages/stream_chat/lib/src/core/models/channel_state.dart +++ b/packages/stream_chat/lib/src/core/models/channel_state.dart @@ -25,26 +25,21 @@ class ChannelState { final ChannelModel? channel; /// A paginated list of channel messages - @JsonKey(defaultValue: []) final List messages; /// A paginated list of channel members - @JsonKey(defaultValue: []) final List members; /// A paginated list of pinned messages - @JsonKey(defaultValue: []) final List pinnedMessages; /// The count of users watching the channel final int? watcherCount; /// A paginated list of users watching the channel - @JsonKey(defaultValue: []) final List watchers; /// The list of channel reads - @JsonKey(defaultValue: []) final List read; /// Create a new instance from a json diff --git a/packages/stream_chat/lib/src/core/models/channel_state.g.dart b/packages/stream_chat/lib/src/core/models/channel_state.g.dart index 39c6373f..0da51768 100644 --- a/packages/stream_chat/lib/src/core/models/channel_state.g.dart +++ b/packages/stream_chat/lib/src/core/models/channel_state.g.dart @@ -6,34 +6,32 @@ part of 'channel_state.dart'; // JsonSerializableGenerator // ************************************************************************** -ChannelState _$ChannelStateFromJson(Map json) { - return ChannelState( - channel: json['channel'] == null - ? null - : ChannelModel.fromJson(json['channel'] as Map), - messages: (json['messages'] as List?) - ?.map((e) => Message.fromJson(e as Map)) - .toList() ?? - [], - members: (json['members'] as List?) - ?.map((e) => Member.fromJson(e as Map)) - .toList() ?? - [], - pinnedMessages: (json['pinned_messages'] as List?) - ?.map((e) => Message.fromJson(e as Map)) - .toList() ?? - [], - watcherCount: json['watcher_count'] as int?, - watchers: (json['watchers'] as List?) - ?.map((e) => User.fromJson(e as Map)) - .toList() ?? - [], - read: (json['read'] as List?) - ?.map((e) => Read.fromJson(e as Map)) - .toList() ?? - [], - ); -} +ChannelState _$ChannelStateFromJson(Map json) => ChannelState( + channel: json['channel'] == null + ? null + : ChannelModel.fromJson(json['channel'] as Map), + messages: (json['messages'] as List?) + ?.map((e) => Message.fromJson(e as Map)) + .toList() ?? + const [], + members: (json['members'] as List?) + ?.map((e) => Member.fromJson(e as Map)) + .toList() ?? + const [], + pinnedMessages: (json['pinned_messages'] as List?) + ?.map((e) => Message.fromJson(e as Map)) + .toList() ?? + const [], + watcherCount: json['watcher_count'] as int?, + watchers: (json['watchers'] as List?) + ?.map((e) => User.fromJson(e as Map)) + .toList() ?? + const [], + read: (json['read'] as List?) + ?.map((e) => Read.fromJson(e as Map)) + .toList() ?? + const [], + ); Map _$ChannelStateToJson(ChannelState instance) => { diff --git a/packages/stream_chat/lib/src/core/models/command.g.dart b/packages/stream_chat/lib/src/core/models/command.g.dart index cf8be971..0fe9d54c 100644 --- a/packages/stream_chat/lib/src/core/models/command.g.dart +++ b/packages/stream_chat/lib/src/core/models/command.g.dart @@ -6,13 +6,11 @@ part of 'command.dart'; // JsonSerializableGenerator // ************************************************************************** -Command _$CommandFromJson(Map json) { - return Command( - name: json['name'] as String, - description: json['description'] as String, - args: json['args'] as String, - ); -} +Command _$CommandFromJson(Map json) => Command( + name: json['name'] as String, + description: json['description'] as String, + args: json['args'] as String, + ); Map _$CommandToJson(Command instance) => { 'name': instance.name, diff --git a/packages/stream_chat/lib/src/core/models/device.g.dart b/packages/stream_chat/lib/src/core/models/device.g.dart index 5fcd9435..4de1f064 100644 --- a/packages/stream_chat/lib/src/core/models/device.g.dart +++ b/packages/stream_chat/lib/src/core/models/device.g.dart @@ -6,12 +6,10 @@ part of 'device.dart'; // JsonSerializableGenerator // ************************************************************************** -Device _$DeviceFromJson(Map json) { - return Device( - id: json['id'] as String, - pushProvider: json['push_provider'] as String, - ); -} +Device _$DeviceFromJson(Map json) => Device( + id: json['id'] as String, + pushProvider: json['push_provider'] as String, + ); Map _$DeviceToJson(Device instance) => { 'id': instance.id, diff --git a/packages/stream_chat/lib/src/core/models/event.dart b/packages/stream_chat/lib/src/core/models/event.dart index 9250176d..2aa1b33b 100644 --- a/packages/stream_chat/lib/src/core/models/event.dart +++ b/packages/stream_chat/lib/src/core/models/event.dart @@ -92,7 +92,6 @@ class Event { final bool isLocal; /// Map of custom channel extraData - @JsonKey(defaultValue: {}) final Map extraData; /// Known top level fields. diff --git a/packages/stream_chat/lib/src/core/models/event.g.dart b/packages/stream_chat/lib/src/core/models/event.g.dart index 93d2e75b..af48500c 100644 --- a/packages/stream_chat/lib/src/core/models/event.g.dart +++ b/packages/stream_chat/lib/src/core/models/event.g.dart @@ -6,42 +6,40 @@ part of 'event.dart'; // JsonSerializableGenerator // ************************************************************************** -Event _$EventFromJson(Map json) { - return Event( - type: json['type'] as String, - cid: json['cid'] as String?, - connectionId: json['connection_id'] as String?, - createdAt: json['created_at'] == null - ? null - : DateTime.parse(json['created_at'] as String), - me: json['me'] == null - ? null - : OwnUser.fromJson(json['me'] as Map), - user: json['user'] == null - ? null - : User.fromJson(json['user'] as Map), - message: json['message'] == null - ? null - : Message.fromJson(json['message'] as Map), - totalUnreadCount: json['total_unread_count'] as int?, - unreadChannels: json['unread_channels'] as int?, - reaction: json['reaction'] == null - ? null - : Reaction.fromJson(json['reaction'] as Map), - online: json['online'] as bool?, - channel: json['channel'] == null - ? null - : EventChannel.fromJson(json['channel'] as Map), - member: json['member'] == null - ? null - : Member.fromJson(json['member'] as Map), - channelId: json['channel_id'] as String?, - channelType: json['channel_type'] as String?, - parentId: json['parent_id'] as String?, - extraData: json['extra_data'] as Map? ?? {}, - isLocal: json['is_local'] as bool? ?? false, - ); -} +Event _$EventFromJson(Map json) => Event( + type: json['type'] as String? ?? 'local.event', + cid: json['cid'] as String?, + connectionId: json['connection_id'] as String?, + createdAt: json['created_at'] == null + ? null + : DateTime.parse(json['created_at'] as String), + me: json['me'] == null + ? null + : OwnUser.fromJson(json['me'] as Map), + user: json['user'] == null + ? null + : User.fromJson(json['user'] as Map), + message: json['message'] == null + ? null + : Message.fromJson(json['message'] as Map), + totalUnreadCount: json['total_unread_count'] as int?, + unreadChannels: json['unread_channels'] as int?, + reaction: json['reaction'] == null + ? null + : Reaction.fromJson(json['reaction'] as Map), + online: json['online'] as bool?, + channel: json['channel'] == null + ? null + : EventChannel.fromJson(json['channel'] as Map), + member: json['member'] == null + ? null + : Member.fromJson(json['member'] as Map), + channelId: json['channel_id'] as String?, + channelType: json['channel_type'] as String?, + parentId: json['parent_id'] as String?, + extraData: json['extra_data'] as Map? ?? const {}, + isLocal: json['is_local'] as bool? ?? false, + ); Map _$EventToJson(Event instance) => { 'type': instance.type, @@ -64,30 +62,28 @@ Map _$EventToJson(Event instance) => { 'extra_data': instance.extraData, }; -EventChannel _$EventChannelFromJson(Map json) { - return EventChannel( - members: (json['members'] as List?) - ?.map((e) => Member.fromJson(e as Map)) - .toList(), - id: json['id'] as String?, - type: json['type'] as String?, - cid: json['cid'] as String, - config: ChannelConfig.fromJson(json['config'] as Map), - createdBy: json['created_by'] == null - ? null - : User.fromJson(json['created_by'] as Map), - frozen: json['frozen'] as bool? ?? false, - lastMessageAt: json['last_message_at'] == null - ? null - : DateTime.parse(json['last_message_at'] as String), - createdAt: DateTime.parse(json['created_at'] as String), - updatedAt: DateTime.parse(json['updated_at'] as String), - deletedAt: json['deleted_at'] == null - ? null - : DateTime.parse(json['deleted_at'] as String), - memberCount: json['member_count'] as int? ?? 0, - extraData: json['extra_data'] as Map? ?? {}, - cooldown: json['cooldown'] as int? ?? 0, - team: json['team'] as String?, - ); -} +EventChannel _$EventChannelFromJson(Map json) => EventChannel( + members: (json['members'] as List?) + ?.map((e) => Member.fromJson(e as Map)) + .toList(), + id: json['id'] as String?, + type: json['type'] as String?, + cid: json['cid'] as String, + config: ChannelConfig.fromJson(json['config'] as Map), + createdBy: json['created_by'] == null + ? null + : User.fromJson(json['created_by'] as Map), + frozen: json['frozen'] as bool? ?? false, + lastMessageAt: json['last_message_at'] == null + ? null + : DateTime.parse(json['last_message_at'] as String), + createdAt: DateTime.parse(json['created_at'] as String), + updatedAt: DateTime.parse(json['updated_at'] as String), + deletedAt: json['deleted_at'] == null + ? null + : DateTime.parse(json['deleted_at'] as String), + memberCount: json['member_count'] as int, + extraData: json['extra_data'] as Map?, + cooldown: json['cooldown'] as int, + team: json['team'] as String?, + ); diff --git a/packages/stream_chat/lib/src/core/models/member.dart b/packages/stream_chat/lib/src/core/models/member.dart index 5c9bc95c..0dae7c04 100644 --- a/packages/stream_chat/lib/src/core/models/member.dart +++ b/packages/stream_chat/lib/src/core/models/member.dart @@ -42,7 +42,6 @@ class Member extends Equatable { final DateTime? inviteRejectedAt; /// True if the user has been invited to the channel - @JsonKey(defaultValue: false) final bool invited; /// The role of the user in the channel @@ -52,15 +51,12 @@ class Member extends Equatable { final String? userId; /// True if the user is a moderator of the channel - @JsonKey(defaultValue: false) final bool isModerator; /// True if the member is banned from the channel - @JsonKey(defaultValue: false) final bool banned; /// True if the member is shadow banned from the channel - @JsonKey(defaultValue: false) final bool shadowBanned; /// The date of creation diff --git a/packages/stream_chat/lib/src/core/models/member.g.dart b/packages/stream_chat/lib/src/core/models/member.g.dart index a75b458d..0e711b1a 100644 --- a/packages/stream_chat/lib/src/core/models/member.g.dart +++ b/packages/stream_chat/lib/src/core/models/member.g.dart @@ -6,31 +6,29 @@ part of 'member.dart'; // JsonSerializableGenerator // ************************************************************************** -Member _$MemberFromJson(Map json) { - return Member( - user: json['user'] == null - ? null - : User.fromJson(json['user'] as Map), - inviteAcceptedAt: json['invite_accepted_at'] == null - ? null - : DateTime.parse(json['invite_accepted_at'] as String), - inviteRejectedAt: json['invite_rejected_at'] == null - ? null - : DateTime.parse(json['invite_rejected_at'] as String), - invited: json['invited'] as bool? ?? false, - role: json['role'] as String?, - userId: json['user_id'] as String?, - isModerator: json['is_moderator'] as bool? ?? false, - createdAt: json['created_at'] == null - ? null - : DateTime.parse(json['created_at'] as String), - updatedAt: json['updated_at'] == null - ? null - : DateTime.parse(json['updated_at'] as String), - banned: json['banned'] as bool? ?? false, - shadowBanned: json['shadow_banned'] as bool? ?? false, - ); -} +Member _$MemberFromJson(Map json) => Member( + user: json['user'] == null + ? null + : User.fromJson(json['user'] as Map), + inviteAcceptedAt: json['invite_accepted_at'] == null + ? null + : DateTime.parse(json['invite_accepted_at'] as String), + inviteRejectedAt: json['invite_rejected_at'] == null + ? null + : DateTime.parse(json['invite_rejected_at'] as String), + invited: json['invited'] as bool? ?? false, + role: json['role'] as String?, + userId: json['user_id'] as String?, + isModerator: json['is_moderator'] as bool? ?? false, + createdAt: json['created_at'] == null + ? null + : DateTime.parse(json['created_at'] as String), + updatedAt: json['updated_at'] == null + ? null + : DateTime.parse(json['updated_at'] as String), + banned: json['banned'] as bool? ?? false, + shadowBanned: json['shadow_banned'] as bool? ?? false, + ); Map _$MemberToJson(Member instance) => { 'user': instance.user?.toJson(), diff --git a/packages/stream_chat/lib/src/core/models/message.dart b/packages/stream_chat/lib/src/core/models/message.dart index 6ad8721c..490bd981 100644 --- a/packages/stream_chat/lib/src/core/models/message.dart +++ b/packages/stream_chat/lib/src/core/models/message.dart @@ -98,23 +98,16 @@ class Message extends Equatable { @JsonKey( includeIfNull: false, toJson: Serializer.readOnly, - defaultValue: 'regular', ) final String type; /// The list of attachments, either provided by the user or generated from a /// command or as a result of URL scraping. - @JsonKey( - includeIfNull: false, - defaultValue: [], - ) + @JsonKey(includeIfNull: false) final List attachments; /// The list of user mentioned in the message - @JsonKey( - toJson: User.toIds, - defaultValue: [], - ) + @JsonKey(toJson: User.toIds) final List mentionedUsers; /// A map describing the count of number of every reaction @@ -155,14 +148,12 @@ class Message extends Equatable { final bool? showInChannel; /// If true the message is silent - @JsonKey(defaultValue: false) final bool silent; /// If true the message is shadowed @JsonKey( includeIfNull: false, toJson: Serializer.readOnly, - defaultValue: false, ) final bool shadowed; @@ -183,7 +174,6 @@ class Message extends Equatable { final User? user; /// If true the message is pinned - @JsonKey(defaultValue: false) final bool pinned; /// Reserved field indicating when the message was pinned @@ -200,10 +190,7 @@ class Message extends Equatable { final User? pinnedBy; /// Message custom extraData - @JsonKey( - includeIfNull: false, - defaultValue: {}, - ) + @JsonKey(includeIfNull: false) final Map extraData; /// True if the message is a system info diff --git a/packages/stream_chat/lib/src/core/models/message.g.dart b/packages/stream_chat/lib/src/core/models/message.g.dart index 25254e2c..b3b58c58 100644 --- a/packages/stream_chat/lib/src/core/models/message.g.dart +++ b/packages/stream_chat/lib/src/core/models/message.g.dart @@ -6,72 +6,70 @@ part of 'message.dart'; // JsonSerializableGenerator // ************************************************************************** -Message _$MessageFromJson(Map json) { - return Message( - id: json['id'] as String?, - text: json['text'] as String?, - type: json['type'] as String? ?? 'regular', - attachments: (json['attachments'] as List?) - ?.map((e) => Attachment.fromJson(e as Map)) - .toList() ?? - [], - mentionedUsers: (json['mentioned_users'] as List?) - ?.map((e) => User.fromJson(e as Map)) - .toList() ?? - [], - silent: json['silent'] as bool? ?? false, - shadowed: json['shadowed'] as bool? ?? false, - reactionCounts: (json['reaction_counts'] as Map?)?.map( - (k, e) => MapEntry(k, e as int), - ), - reactionScores: (json['reaction_scores'] as Map?)?.map( - (k, e) => MapEntry(k, e as int), - ), - latestReactions: (json['latest_reactions'] as List?) - ?.map((e) => Reaction.fromJson(e as Map)) - .toList(), - ownReactions: (json['own_reactions'] as List?) - ?.map((e) => Reaction.fromJson(e as Map)) - .toList(), - parentId: json['parent_id'] as String?, - quotedMessage: json['quoted_message'] == null - ? null - : Message.fromJson(json['quoted_message'] as Map), - quotedMessageId: json['quoted_message_id'] as String?, - replyCount: json['reply_count'] as int?, - threadParticipants: (json['thread_participants'] as List?) - ?.map((e) => User.fromJson(e as Map)) - .toList(), - showInChannel: json['show_in_channel'] as bool?, - command: json['command'] as String?, - createdAt: json['created_at'] == null - ? null - : DateTime.parse(json['created_at'] as String), - updatedAt: json['updated_at'] == null - ? null - : DateTime.parse(json['updated_at'] as String), - user: json['user'] == null - ? null - : User.fromJson(json['user'] as Map), - pinned: json['pinned'] as bool? ?? false, - pinnedAt: json['pinned_at'] == null - ? null - : DateTime.parse(json['pinned_at'] as String), - pinExpires: json['pin_expires'] == null - ? null - : DateTime.parse(json['pin_expires'] as String), - pinnedBy: json['pinned_by'] == null - ? null - : User.fromJson(json['pinned_by'] as Map), - extraData: json['extra_data'] as Map? ?? {}, - deletedAt: json['deleted_at'] == null - ? null - : DateTime.parse(json['deleted_at'] as String), - i18n: (json['i18n'] as Map?)?.map( - (k, e) => MapEntry(k, e as String), - ), - ); -} +Message _$MessageFromJson(Map json) => Message( + id: json['id'] as String?, + text: json['text'] as String?, + type: json['type'] as String? ?? 'regular', + attachments: (json['attachments'] as List?) + ?.map((e) => Attachment.fromJson(e as Map)) + .toList() ?? + const [], + mentionedUsers: (json['mentioned_users'] as List?) + ?.map((e) => User.fromJson(e as Map)) + .toList() ?? + const [], + silent: json['silent'] as bool? ?? false, + shadowed: json['shadowed'] as bool? ?? false, + reactionCounts: (json['reaction_counts'] as Map?)?.map( + (k, e) => MapEntry(k, e as int), + ), + reactionScores: (json['reaction_scores'] as Map?)?.map( + (k, e) => MapEntry(k, e as int), + ), + latestReactions: (json['latest_reactions'] as List?) + ?.map((e) => Reaction.fromJson(e as Map)) + .toList(), + ownReactions: (json['own_reactions'] as List?) + ?.map((e) => Reaction.fromJson(e as Map)) + .toList(), + parentId: json['parent_id'] as String?, + quotedMessage: json['quoted_message'] == null + ? null + : Message.fromJson(json['quoted_message'] as Map), + quotedMessageId: json['quoted_message_id'] as String?, + replyCount: json['reply_count'] as int? ?? 0, + threadParticipants: (json['thread_participants'] as List?) + ?.map((e) => User.fromJson(e as Map)) + .toList(), + showInChannel: json['show_in_channel'] as bool?, + command: json['command'] as String?, + createdAt: json['created_at'] == null + ? null + : DateTime.parse(json['created_at'] as String), + updatedAt: json['updated_at'] == null + ? null + : DateTime.parse(json['updated_at'] as String), + user: json['user'] == null + ? null + : User.fromJson(json['user'] as Map), + pinned: json['pinned'] as bool? ?? false, + pinnedAt: json['pinned_at'] == null + ? null + : DateTime.parse(json['pinned_at'] as String), + pinExpires: json['pin_expires'] == null + ? null + : DateTime.parse(json['pin_expires'] as String), + pinnedBy: json['pinned_by'] == null + ? null + : User.fromJson(json['pinned_by'] as Map), + extraData: json['extra_data'] as Map? ?? const {}, + deletedAt: json['deleted_at'] == null + ? null + : DateTime.parse(json['deleted_at'] as String), + i18n: (json['i18n'] as Map?)?.map( + (k, e) => MapEntry(k, e as String), + ), + ); Map _$MessageToJson(Message instance) { final val = { diff --git a/packages/stream_chat/lib/src/core/models/mute.g.dart b/packages/stream_chat/lib/src/core/models/mute.g.dart index b847a109..f57fd312 100644 --- a/packages/stream_chat/lib/src/core/models/mute.g.dart +++ b/packages/stream_chat/lib/src/core/models/mute.g.dart @@ -6,11 +6,9 @@ part of 'mute.dart'; // JsonSerializableGenerator // ************************************************************************** -Mute _$MuteFromJson(Map json) { - return Mute( - user: User.fromJson(json['user'] as Map), - channel: ChannelModel.fromJson(json['channel'] as Map), - createdAt: DateTime.parse(json['created_at'] as String), - updatedAt: DateTime.parse(json['updated_at'] as String), - ); -} +Mute _$MuteFromJson(Map json) => Mute( + user: User.fromJson(json['user'] as Map), + channel: ChannelModel.fromJson(json['channel'] as Map), + createdAt: DateTime.parse(json['created_at'] as String), + updatedAt: DateTime.parse(json['updated_at'] as String), + ); diff --git a/packages/stream_chat/lib/src/core/models/own_user.dart b/packages/stream_chat/lib/src/core/models/own_user.dart index eb64eed3..f65735ab 100644 --- a/packages/stream_chat/lib/src/core/models/own_user.dart +++ b/packages/stream_chat/lib/src/core/models/own_user.dart @@ -131,23 +131,23 @@ class OwnUser extends User { } /// List of user devices. - @JsonKey(includeIfNull: false, defaultValue: []) + @JsonKey(includeIfNull: false) final List devices; /// List of users muted by the user. - @JsonKey(includeIfNull: false, defaultValue: []) + @JsonKey(includeIfNull: false) final List mutes; /// List of users muted by the user. - @JsonKey(includeIfNull: false, defaultValue: []) + @JsonKey(includeIfNull: false) final List channelMutes; /// Total unread messages by the user. - @JsonKey(includeIfNull: false, defaultValue: 0) + @JsonKey(includeIfNull: false) final int totalUnreadCount; /// Total unread channels by the user. - @JsonKey(includeIfNull: false, defaultValue: 0) + @JsonKey(includeIfNull: false) final int unreadChannels; /// Known top level fields. diff --git a/packages/stream_chat/lib/src/core/models/own_user.g.dart b/packages/stream_chat/lib/src/core/models/own_user.g.dart index 185b6dd0..41b6e2f5 100644 --- a/packages/stream_chat/lib/src/core/models/own_user.g.dart +++ b/packages/stream_chat/lib/src/core/models/own_user.g.dart @@ -6,39 +6,37 @@ part of 'own_user.dart'; // JsonSerializableGenerator // ************************************************************************** -OwnUser _$OwnUserFromJson(Map json) { - return OwnUser( - devices: (json['devices'] as List?) - ?.map((e) => Device.fromJson(e as Map)) - .toList() ?? - [], - mutes: (json['mutes'] as List?) - ?.map((e) => Mute.fromJson(e as Map)) - .toList() ?? - [], - totalUnreadCount: json['total_unread_count'] as int? ?? 0, - unreadChannels: json['unread_channels'] as int? ?? 0, - channelMutes: (json['channel_mutes'] as List?) - ?.map((e) => Mute.fromJson(e as Map)) - .toList() ?? - [], - id: json['id'] as String, - role: json['role'] as String?, - createdAt: json['created_at'] == null - ? null - : DateTime.parse(json['created_at'] as String), - updatedAt: json['updated_at'] == null - ? null - : DateTime.parse(json['updated_at'] as String), - lastActive: json['last_active'] == null - ? null - : DateTime.parse(json['last_active'] as String), - online: json['online'] as bool? ?? false, - extraData: json['extra_data'] as Map? ?? {}, - banned: json['banned'] as bool? ?? false, - teams: - (json['teams'] as List?)?.map((e) => e as String).toList() ?? - [], - language: json['language'] as String?, - ); -} +OwnUser _$OwnUserFromJson(Map json) => OwnUser( + devices: (json['devices'] as List?) + ?.map((e) => Device.fromJson(e as Map)) + .toList() ?? + const [], + mutes: (json['mutes'] as List?) + ?.map((e) => Mute.fromJson(e as Map)) + .toList() ?? + const [], + totalUnreadCount: json['total_unread_count'] as int? ?? 0, + unreadChannels: json['unread_channels'] as int? ?? 0, + channelMutes: (json['channel_mutes'] as List?) + ?.map((e) => Mute.fromJson(e as Map)) + .toList() ?? + const [], + id: json['id'] as String, + role: json['role'] as String?, + createdAt: json['created_at'] == null + ? null + : DateTime.parse(json['created_at'] as String), + updatedAt: json['updated_at'] == null + ? null + : DateTime.parse(json['updated_at'] as String), + lastActive: json['last_active'] == null + ? null + : DateTime.parse(json['last_active'] as String), + online: json['online'] as bool? ?? false, + extraData: json['extra_data'] as Map? ?? const {}, + banned: json['banned'] as bool? ?? false, + teams: + (json['teams'] as List?)?.map((e) => e as String).toList() ?? + const [], + language: json['language'] as String?, + ); diff --git a/packages/stream_chat/lib/src/core/models/reaction.dart b/packages/stream_chat/lib/src/core/models/reaction.dart index 2b0ffbf6..f16fb09f 100644 --- a/packages/stream_chat/lib/src/core/models/reaction.dart +++ b/packages/stream_chat/lib/src/core/models/reaction.dart @@ -41,7 +41,6 @@ class Reaction { final User? user; /// The score of the reaction (ie. number of reactions sent) - @JsonKey(defaultValue: 0) final int score; /// The userId that sent the reaction @@ -49,10 +48,7 @@ class Reaction { final String? userId; /// Reaction custom extraData - @JsonKey( - includeIfNull: false, - defaultValue: {}, - ) + @JsonKey(includeIfNull: false) final Map extraData; /// Map of custom user extraData diff --git a/packages/stream_chat/lib/src/core/models/reaction.g.dart b/packages/stream_chat/lib/src/core/models/reaction.g.dart index 3e92150d..3554106d 100644 --- a/packages/stream_chat/lib/src/core/models/reaction.g.dart +++ b/packages/stream_chat/lib/src/core/models/reaction.g.dart @@ -6,21 +6,19 @@ part of 'reaction.dart'; // JsonSerializableGenerator // ************************************************************************** -Reaction _$ReactionFromJson(Map json) { - return Reaction( - messageId: json['message_id'] as String?, - createdAt: json['created_at'] == null - ? null - : DateTime.parse(json['created_at'] as String), - type: json['type'] as String, - user: json['user'] == null - ? null - : User.fromJson(json['user'] as Map), - userId: json['user_id'] as String?, - score: json['score'] as int? ?? 0, - extraData: json['extra_data'] as Map? ?? {}, - ); -} +Reaction _$ReactionFromJson(Map json) => Reaction( + messageId: json['message_id'] as String?, + createdAt: json['created_at'] == null + ? null + : DateTime.parse(json['created_at'] as String), + type: json['type'] as String, + user: json['user'] == null + ? null + : User.fromJson(json['user'] as Map), + userId: json['user_id'] as String?, + score: json['score'] as int? ?? 0, + extraData: json['extra_data'] as Map? ?? const {}, + ); Map _$ReactionToJson(Reaction instance) { final val = { diff --git a/packages/stream_chat/lib/src/core/models/read.dart b/packages/stream_chat/lib/src/core/models/read.dart index 55912762..812fc6f7 100644 --- a/packages/stream_chat/lib/src/core/models/read.dart +++ b/packages/stream_chat/lib/src/core/models/read.dart @@ -23,7 +23,6 @@ class Read { final User user; /// Number of unread messages - @JsonKey(defaultValue: 0) final int unreadMessages; /// Serialize to json diff --git a/packages/stream_chat/lib/src/core/models/read.g.dart b/packages/stream_chat/lib/src/core/models/read.g.dart index 93c832d8..f44a21d5 100644 --- a/packages/stream_chat/lib/src/core/models/read.g.dart +++ b/packages/stream_chat/lib/src/core/models/read.g.dart @@ -6,13 +6,11 @@ part of 'read.dart'; // JsonSerializableGenerator // ************************************************************************** -Read _$ReadFromJson(Map json) { - return Read( - lastRead: DateTime.parse(json['last_read'] as String), - user: User.fromJson(json['user'] as Map), - unreadMessages: json['unread_messages'] as int? ?? 0, - ); -} +Read _$ReadFromJson(Map json) => Read( + lastRead: DateTime.parse(json['last_read'] as String), + user: User.fromJson(json['user'] as Map), + unreadMessages: json['unread_messages'] as int? ?? 0, + ); Map _$ReadToJson(Read instance) => { 'last_read': instance.lastRead.toIso8601String(), diff --git a/packages/stream_chat/lib/src/core/models/user.dart b/packages/stream_chat/lib/src/core/models/user.dart index 5a5ef8e5..44df4399 100644 --- a/packages/stream_chat/lib/src/core/models/user.dart +++ b/packages/stream_chat/lib/src/core/models/user.dart @@ -100,7 +100,6 @@ class User extends Equatable { @JsonKey( includeIfNull: false, toJson: Serializer.readOnly, - defaultValue: [], ) final List teams; @@ -118,19 +117,20 @@ class User extends Equatable { /// True if user is online. @JsonKey( - includeIfNull: false, toJson: Serializer.readOnly, defaultValue: false) + includeIfNull: false, + toJson: Serializer.readOnly, + ) final bool online; /// True if user is banned from the chat. @JsonKey( - includeIfNull: false, toJson: Serializer.readOnly, defaultValue: false) + includeIfNull: false, + toJson: Serializer.readOnly, + ) final bool banned; /// Map of custom user extraData. - @JsonKey( - includeIfNull: false, - defaultValue: {}, - ) + @JsonKey(includeIfNull: false) final Map extraData; /// The language this user prefers. diff --git a/packages/stream_chat/lib/src/core/models/user.g.dart b/packages/stream_chat/lib/src/core/models/user.g.dart index ab2f04d5..82c799a0 100644 --- a/packages/stream_chat/lib/src/core/models/user.g.dart +++ b/packages/stream_chat/lib/src/core/models/user.g.dart @@ -6,28 +6,26 @@ part of 'user.dart'; // JsonSerializableGenerator // ************************************************************************** -User _$UserFromJson(Map json) { - return User( - id: json['id'] as String, - role: json['role'] as String?, - createdAt: json['created_at'] == null - ? null - : DateTime.parse(json['created_at'] as String), - updatedAt: json['updated_at'] == null - ? null - : DateTime.parse(json['updated_at'] as String), - lastActive: json['last_active'] == null - ? null - : DateTime.parse(json['last_active'] as String), - extraData: json['extra_data'] as Map? ?? {}, - online: json['online'] as bool? ?? false, - banned: json['banned'] as bool? ?? false, - teams: - (json['teams'] as List?)?.map((e) => e as String).toList() ?? - [], - language: json['language'] as String?, - ); -} +User _$UserFromJson(Map json) => User( + id: json['id'] as String, + role: json['role'] as String?, + createdAt: json['created_at'] == null + ? null + : DateTime.parse(json['created_at'] as String), + updatedAt: json['updated_at'] == null + ? null + : DateTime.parse(json['updated_at'] as String), + lastActive: json['last_active'] == null + ? null + : DateTime.parse(json['last_active'] as String), + extraData: json['extra_data'] as Map? ?? const {}, + online: json['online'] as bool? ?? false, + banned: json['banned'] as bool? ?? false, + teams: + (json['teams'] as List?)?.map((e) => e as String).toList() ?? + const [], + language: json['language'] as String?, + ); Map _$UserToJson(User instance) { final val = {