Move to Flutter 3.47, use the improvements that come with this (#64)
Reviewed-on: #64
This commit is contained in:
parent
01b13b4764
commit
077044ec19
157 changed files with 1366 additions and 1457 deletions
|
|
@ -1,15 +1,17 @@
|
|||
import "package:freezed_annotation/freezed_annotation.dart";
|
||||
|
||||
part "download_media.freezed.dart";
|
||||
part "download_media.g.dart";
|
||||
|
||||
@freezed
|
||||
abstract class DownloadMediaRequest with _$DownloadMediaRequest {
|
||||
const factory DownloadMediaRequest({
|
||||
required Uri mxc,
|
||||
@Default(false) bool encrypted,
|
||||
@Default(false) bool isAvatar,
|
||||
@Default(false) bool thumbnailAvatar,
|
||||
}) = _DownloadMediaRequest;
|
||||
@Freezed(toJson: false, fromJson: false)
|
||||
@JsonSerializable()
|
||||
class const DownloadMediaRequest({
|
||||
required final Uri mxc,
|
||||
final bool encrypted = false,
|
||||
final bool isAvatar = false,
|
||||
final bool thumbnailAvatar = false,
|
||||
}) with _$DownloadMediaRequest {
|
||||
Map<String, Object?> toJson() => _$DownloadMediaRequestToJson(this);
|
||||
|
||||
factory DownloadMediaRequest.fromJson(Map<String, Object?> json) =>
|
||||
_$DownloadMediaRequestFromJson(json);
|
||||
|
|
|
|||
|
|
@ -1,14 +1,16 @@
|
|||
import "package:freezed_annotation/freezed_annotation.dart";
|
||||
|
||||
part "get_event.freezed.dart";
|
||||
part "get_event.g.dart";
|
||||
|
||||
@freezed
|
||||
abstract class GetEventRequest with _$GetEventRequest {
|
||||
const factory GetEventRequest({
|
||||
required String roomId,
|
||||
required String eventId,
|
||||
@Default(false) bool unredact,
|
||||
}) = _GetEventRequest;
|
||||
@Freezed(toJson: false, fromJson: false)
|
||||
@JsonSerializable()
|
||||
class const GetEventRequest({
|
||||
required final String roomId,
|
||||
required final String eventId,
|
||||
final bool unredact = false,
|
||||
}) with _$GetEventRequest {
|
||||
Map<String, Object?> toJson() => _$GetEventRequestToJson(this);
|
||||
|
||||
factory GetEventRequest.fromJson(Map<String, Object?> json) =>
|
||||
_$GetEventRequestFromJson(json);
|
||||
|
|
|
|||
|
|
@ -1,14 +1,16 @@
|
|||
import "package:freezed_annotation/freezed_annotation.dart";
|
||||
|
||||
part "get_related_events.freezed.dart";
|
||||
part "get_related_events.g.dart";
|
||||
|
||||
@freezed
|
||||
abstract class GetRelatedEventsRequest with _$GetRelatedEventsRequest {
|
||||
const factory GetRelatedEventsRequest({
|
||||
required String roomId,
|
||||
required String eventId,
|
||||
required String relationType,
|
||||
}) = _GetRelatedEventsRequest;
|
||||
@Freezed(toJson: false, fromJson: false)
|
||||
@JsonSerializable()
|
||||
class const GetRelatedEventsRequest({
|
||||
required final String roomId,
|
||||
required final String eventId,
|
||||
required final String relationType,
|
||||
}) with _$GetRelatedEventsRequest {
|
||||
Map<String, Object?> toJson() => _$GetRelatedEventsRequestToJson(this);
|
||||
|
||||
factory GetRelatedEventsRequest.fromJson(Map<String, Object?> json) =>
|
||||
_$GetRelatedEventsRequestFromJson(json);
|
||||
|
|
|
|||
|
|
@ -1,15 +1,17 @@
|
|||
import "package:freezed_annotation/freezed_annotation.dart";
|
||||
|
||||
part "get_room_state.freezed.dart";
|
||||
part "get_room_state.g.dart";
|
||||
|
||||
@freezed
|
||||
abstract class GetRoomStateRequest with _$GetRoomStateRequest {
|
||||
const factory GetRoomStateRequest({
|
||||
required String roomId,
|
||||
@Default(false) bool refetch,
|
||||
@Default(false) bool fetchMembers,
|
||||
@Default(false) bool includeMembers,
|
||||
}) = _GetRoomStateRequest;
|
||||
@Freezed(toJson: false, fromJson: false)
|
||||
@JsonSerializable()
|
||||
class const GetRoomStateRequest({
|
||||
required final String roomId,
|
||||
final bool refetch = false,
|
||||
final bool fetchMembers = false,
|
||||
final bool includeMembers = false,
|
||||
}) with _$GetRoomStateRequest {
|
||||
Map<String, Object?> toJson() => _$GetRoomStateRequestToJson(this);
|
||||
|
||||
factory GetRoomStateRequest.fromJson(Map<String, Object?> json) =>
|
||||
_$GetRoomStateRequestFromJson(json);
|
||||
|
|
|
|||
|
|
@ -1,14 +1,16 @@
|
|||
import "package:fast_immutable_collections/fast_immutable_collections.dart";
|
||||
import "package:freezed_annotation/freezed_annotation.dart";
|
||||
|
||||
part "join_room.freezed.dart";
|
||||
part "join_room.g.dart";
|
||||
|
||||
@freezed
|
||||
abstract class JoinRoomRequest with _$JoinRoomRequest {
|
||||
const factory JoinRoomRequest({
|
||||
required String roomIdOrAlias,
|
||||
@Default(IList.empty()) IList<String> via,
|
||||
}) = _JoinRoomRequest;
|
||||
@Freezed(toJson: false, fromJson: false)
|
||||
@JsonSerializable()
|
||||
class const JoinRoomRequest({
|
||||
required final String roomIdOrAlias,
|
||||
final IList<String> via = const IList.empty(),
|
||||
}) with _$JoinRoomRequest {
|
||||
Map<String, Object?> toJson() => _$JoinRoomRequestToJson(this);
|
||||
|
||||
factory JoinRoomRequest.fromJson(Map<String, Object?> json) =>
|
||||
_$JoinRoomRequestFromJson(json);
|
||||
|
|
|
|||
|
|
@ -1,16 +1,18 @@
|
|||
import "package:freezed_annotation/freezed_annotation.dart";
|
||||
|
||||
part "exchange_token.freezed.dart";
|
||||
part "exchange_token.g.dart";
|
||||
|
||||
@freezed
|
||||
abstract class OAuthExchangeTokenRequest with _$OAuthExchangeTokenRequest {
|
||||
const factory OAuthExchangeTokenRequest({
|
||||
required Uri homeserverUrl,
|
||||
required String codeVerifier,
|
||||
required Uri redirectUri,
|
||||
required String code,
|
||||
required String clientId,
|
||||
}) = _OAuthExchangeTokenRequest;
|
||||
@Freezed(toJson: false, fromJson: false)
|
||||
@JsonSerializable()
|
||||
class const OAuthExchangeTokenRequest({
|
||||
required final Uri homeserverUrl,
|
||||
required final String codeVerifier,
|
||||
required final Uri redirectUri,
|
||||
required final String code,
|
||||
required final String clientId,
|
||||
}) with _$OAuthExchangeTokenRequest {
|
||||
Map<String, Object?> toJson() => _$OAuthExchangeTokenRequestToJson(this);
|
||||
|
||||
factory OAuthExchangeTokenRequest.fromJson(Map<String, Object?> json) =>
|
||||
_$OAuthExchangeTokenRequestFromJson(json);
|
||||
|
|
|
|||
|
|
@ -2,25 +2,27 @@ import "dart:math";
|
|||
|
||||
import "package:fast_immutable_collections/fast_immutable_collections.dart";
|
||||
import "package:freezed_annotation/freezed_annotation.dart";
|
||||
|
||||
part "get_auth_url.freezed.dart";
|
||||
part "get_auth_url.g.dart";
|
||||
|
||||
@freezed
|
||||
abstract class OAuthGetAuthUrl with _$OAuthGetAuthUrl {
|
||||
const factory OAuthGetAuthUrl({
|
||||
required ResponseMode responseMode,
|
||||
required Uri homeserverUrl,
|
||||
required Uri redirectUri,
|
||||
required IList<String> scopes,
|
||||
required String clientId,
|
||||
String? userIdHint,
|
||||
}) = _OAuthGetAuthUrl;
|
||||
@Freezed(toJson: false, fromJson: false)
|
||||
@JsonSerializable()
|
||||
class const OAuthGetAuthUrl({
|
||||
required final ResponseMode responseMode,
|
||||
required final Uri homeserverUrl,
|
||||
required final Uri redirectUri,
|
||||
required final IList<String> scopes,
|
||||
required final String clientId,
|
||||
final String? userIdHint,
|
||||
}) with _$OAuthGetAuthUrl {
|
||||
Map<String, Object?> toJson() => _$OAuthGetAuthUrlToJson(this);
|
||||
|
||||
factory OAuthGetAuthUrl.fromJson(Map<String, Object?> json) =>
|
||||
_$OAuthGetAuthUrlFromJson(json);
|
||||
}
|
||||
|
||||
abstract class Scope {
|
||||
sealed class Scope {
|
||||
static final openid = "openid";
|
||||
static final email = "email";
|
||||
static final clientApi = "urn:matrix:client:api:*";
|
||||
|
|
|
|||
|
|
@ -1,26 +1,27 @@
|
|||
import "package:fast_immutable_collections/fast_immutable_collections.dart";
|
||||
import "package:freezed_annotation/freezed_annotation.dart";
|
||||
|
||||
part "register_client.freezed.dart";
|
||||
part "register_client.g.dart";
|
||||
|
||||
@freezed
|
||||
abstract class OAuthRegisterClientRequest with _$OAuthRegisterClientRequest {
|
||||
const factory OAuthRegisterClientRequest({
|
||||
required Uri homeserverUrl,
|
||||
@Default(ApplicationType.web) ApplicationType applicationType,
|
||||
String? clientName,
|
||||
required Uri clientUri,
|
||||
Uri? logoUri,
|
||||
Uri? policyUri,
|
||||
Uri? tosUri,
|
||||
IList<GrantType>? grantTypes,
|
||||
IList<Uri>? redirectUris,
|
||||
IList<ResponseType>? responseTypes,
|
||||
@Freezed(toJson: false, fromJson: false)
|
||||
@JsonSerializable()
|
||||
class const OAuthRegisterClientRequest({
|
||||
required final Uri homeserverUrl,
|
||||
final ApplicationType applicationType = ApplicationType.web,
|
||||
final String? clientName,
|
||||
required final Uri clientUri,
|
||||
final Uri? logoUri,
|
||||
final Uri? policyUri,
|
||||
final Uri? tosUri,
|
||||
final IList<GrantType>? grantTypes,
|
||||
final IList<Uri>? redirectUris,
|
||||
final IList<ResponseType>? responseTypes,
|
||||
|
||||
@Default(AuthMethod.none)
|
||||
@JsonKey(name: "token_endpoint_auth_method")
|
||||
AuthMethod? authMethod,
|
||||
}) = _OAuthRegisterClientRequest;
|
||||
@JsonKey(name: "token_endpoint_auth_method")
|
||||
final AuthMethod? authMethod = AuthMethod.none,
|
||||
}) with _$OAuthRegisterClientRequest {
|
||||
Map<String, Object?> toJson() => _$OAuthRegisterClientRequestToJson(this);
|
||||
|
||||
factory OAuthRegisterClientRequest.fromJson(Map<String, Object?> json) =>
|
||||
_$OAuthRegisterClientRequestFromJson(json);
|
||||
|
|
|
|||
|
|
@ -1,14 +1,16 @@
|
|||
import "package:freezed_annotation/freezed_annotation.dart";
|
||||
|
||||
part "paginate.freezed.dart";
|
||||
part "paginate.g.dart";
|
||||
|
||||
@freezed
|
||||
abstract class PaginateRequest with _$PaginateRequest {
|
||||
const factory PaginateRequest({
|
||||
required String roomId,
|
||||
required int? maxTimelineId,
|
||||
@Default(20) int limit,
|
||||
}) = _PaginateRequest;
|
||||
@Freezed(toJson: false, fromJson: false)
|
||||
@JsonSerializable()
|
||||
class const PaginateRequest({
|
||||
required final String roomId,
|
||||
required final int? maxTimelineId,
|
||||
final int limit = 20,
|
||||
}) with _$PaginateRequest {
|
||||
Map<String, Object?> toJson() => _$PaginateRequestToJson(this);
|
||||
|
||||
factory PaginateRequest.fromJson(Map<String, Object?> json) =>
|
||||
_$PaginateRequestFromJson(json);
|
||||
|
|
|
|||
|
|
@ -1,14 +1,16 @@
|
|||
import "package:freezed_annotation/freezed_annotation.dart";
|
||||
|
||||
part "report.freezed.dart";
|
||||
part "report.g.dart";
|
||||
|
||||
@freezed
|
||||
abstract class ReportRequest with _$ReportRequest {
|
||||
const factory ReportRequest({
|
||||
required String roomId,
|
||||
required String eventId,
|
||||
String? reason,
|
||||
}) = _ReportRequest;
|
||||
@Freezed(toJson: false, fromJson: false)
|
||||
@JsonSerializable()
|
||||
class const ReportRequest({
|
||||
required final String roomId,
|
||||
required final String eventId,
|
||||
final String? reason,
|
||||
}) with _$ReportRequest {
|
||||
Map<String, Object?> toJson() => _$ReportRequestToJson(this);
|
||||
|
||||
factory ReportRequest.fromJson(Map<String, Object?> json) =>
|
||||
_$ReportRequestFromJson(json);
|
||||
|
|
|
|||
|
|
@ -1,19 +1,21 @@
|
|||
import "package:freezed_annotation/freezed_annotation.dart";
|
||||
import "package:nexus/models/content/content.dart";
|
||||
|
||||
part "send_event.freezed.dart";
|
||||
part "send_event.g.dart";
|
||||
|
||||
@freezed
|
||||
abstract class SendEventRequest with _$SendEventRequest {
|
||||
const factory SendEventRequest({
|
||||
required String roomId,
|
||||
required String type,
|
||||
required Content content,
|
||||
String? relatesTo,
|
||||
String? relationType,
|
||||
@Default(false) bool synchronous,
|
||||
@Default(false) bool disableEncryption,
|
||||
}) = _SendEventRequest;
|
||||
@Freezed(toJson: false, fromJson: false)
|
||||
@JsonSerializable()
|
||||
class const SendEventRequest({
|
||||
required final String roomId,
|
||||
required final String type,
|
||||
required final Content content,
|
||||
final String? relatesTo,
|
||||
final String? relationType,
|
||||
final bool synchronous = false,
|
||||
final bool disableEncryption = false,
|
||||
}) with _$SendEventRequest {
|
||||
Map<String, Object?> toJson() => _$SendEventRequestToJson(this);
|
||||
|
||||
factory SendEventRequest.fromJson(Map<String, Object?> json) =>
|
||||
_$SendEventRequestFromJson(json);
|
||||
|
|
|
|||
|
|
@ -2,43 +2,42 @@ import "package:fast_immutable_collections/fast_immutable_collections.dart";
|
|||
import "package:freezed_annotation/freezed_annotation.dart";
|
||||
import "package:nexus/models/content/content.dart";
|
||||
import "package:nexus/models/relation_type.dart";
|
||||
|
||||
part "send_message.freezed.dart";
|
||||
part "send_message.g.dart";
|
||||
|
||||
@freezed
|
||||
abstract class SendMessageRequest with _$SendMessageRequest {
|
||||
const factory SendMessageRequest({
|
||||
required String roomId,
|
||||
required String text,
|
||||
Content? baseContent,
|
||||
@Default(Mentions()) @JsonKey(name: "mentions") Mentions mentions,
|
||||
@JsonKey(name: "relates_to") Relation? relation,
|
||||
}) = _SendMessageRequest;
|
||||
@Freezed(toJson: false, fromJson: false)
|
||||
@JsonSerializable()
|
||||
class const SendMessageRequest({
|
||||
required final String roomId,
|
||||
required final String text,
|
||||
final Content? baseContent,
|
||||
@JsonKey(name: "mentions") final Mentions mentions = const Mentions(),
|
||||
@JsonKey(name: "relates_to") final Relation? relation,
|
||||
}) with _$SendMessageRequest {
|
||||
Map<String, Object?> toJson() => _$SendMessageRequestToJson(this);
|
||||
|
||||
factory SendMessageRequest.fromJson(Map<String, Object?> json) =>
|
||||
_$SendMessageRequestFromJson(json);
|
||||
}
|
||||
|
||||
@freezed
|
||||
abstract class Mentions with _$Mentions {
|
||||
const factory Mentions({
|
||||
@Default(false) bool room,
|
||||
@Default(IList.empty()) IList<String> userIds,
|
||||
}) = _Mentions;
|
||||
@Freezed(toJson: false, fromJson: false)
|
||||
@JsonSerializable()
|
||||
class const Mentions({
|
||||
final bool room = false,
|
||||
final IList<String> userIds = const IList.empty(),
|
||||
}) with _$Mentions {
|
||||
Map<String, Object?> toJson() => _$MentionsToJson(this);
|
||||
|
||||
factory Mentions.fromJson(Map<String, Object?> json) =>
|
||||
_$MentionsFromJson(json);
|
||||
}
|
||||
|
||||
@Freezed(toJson: false)
|
||||
abstract class Relation with _$Relation {
|
||||
const Relation._();
|
||||
|
||||
const factory Relation({
|
||||
required String eventId,
|
||||
required RelationType relationType,
|
||||
}) = _Relation;
|
||||
|
||||
class const Relation({
|
||||
required final String eventId,
|
||||
required final RelationType relationType,
|
||||
}) with _$Relation {
|
||||
Map<String, dynamic> toJson() {
|
||||
switch (relationType) {
|
||||
case RelationType.reply:
|
||||
|
|
|
|||
|
|
@ -1,14 +1,16 @@
|
|||
import "package:freezed_annotation/freezed_annotation.dart";
|
||||
|
||||
part "set_account_data.freezed.dart";
|
||||
part "set_account_data.g.dart";
|
||||
|
||||
@freezed
|
||||
abstract class SetAccountDataRequest with _$SetAccountDataRequest {
|
||||
const factory SetAccountDataRequest({
|
||||
required String type,
|
||||
required dynamic content,
|
||||
String? roomId,
|
||||
}) = _SetAccountDataRequest;
|
||||
@Freezed(toJson: false, fromJson: false)
|
||||
@JsonSerializable()
|
||||
class const SetAccountDataRequest({
|
||||
required final String type,
|
||||
required final dynamic content,
|
||||
final String? roomId,
|
||||
}) with _$SetAccountDataRequest {
|
||||
Map<String, Object?> toJson() => _$SetAccountDataRequestToJson(this);
|
||||
|
||||
factory SetAccountDataRequest.fromJson(Map<String, Object?> json) =>
|
||||
_$SetAccountDataRequestFromJson(json);
|
||||
|
|
|
|||
|
|
@ -1,18 +1,19 @@
|
|||
import "package:freezed_annotation/freezed_annotation.dart";
|
||||
import "package:nexus/models/membership_action.dart";
|
||||
|
||||
part "set_membership.freezed.dart";
|
||||
part "set_membership.g.dart";
|
||||
|
||||
@freezed
|
||||
abstract class SetMembershipRequest with _$SetMembershipRequest {
|
||||
const factory SetMembershipRequest({
|
||||
required String userId,
|
||||
required String roomId,
|
||||
|
||||
String? reason,
|
||||
@JsonKey(name: "action") required MembershipAction action,
|
||||
@Default(false) @JsonKey(name: "msc4293_redact_events") bool redact,
|
||||
}) = _SetMembershipRequest;
|
||||
@Freezed(toJson: false, fromJson: false)
|
||||
@JsonSerializable()
|
||||
class const SetMembershipRequest({
|
||||
required final String userId,
|
||||
required final String roomId,
|
||||
final String? reason,
|
||||
@JsonKey(name: "action") required final MembershipAction action,
|
||||
@JsonKey(name: "msc4293_redact_events") final bool redact = false,
|
||||
}) with _$SetMembershipRequest {
|
||||
Map<String, Object?> toJson() => _$SetMembershipRequestToJson(this);
|
||||
|
||||
factory SetMembershipRequest.fromJson(Map<String, Object?> json) =>
|
||||
_$SetMembershipRequestFromJson(json);
|
||||
|
|
|
|||
|
|
@ -1,22 +1,23 @@
|
|||
import "package:freezed_annotation/freezed_annotation.dart";
|
||||
import "package:nexus/models/content/content.dart";
|
||||
import "package:nexus/models/ms_duration.dart";
|
||||
|
||||
part "set_state.freezed.dart";
|
||||
part "set_state.g.dart";
|
||||
|
||||
@freezed
|
||||
abstract class SetStateRequest with _$SetStateRequest {
|
||||
const factory SetStateRequest({
|
||||
required String roomId,
|
||||
required String type,
|
||||
required String stateKey,
|
||||
required Content content,
|
||||
@Freezed(toJson: false, fromJson: false)
|
||||
@JsonSerializable()
|
||||
class const SetStateRequest({
|
||||
required final String roomId,
|
||||
required final String type,
|
||||
required final String stateKey,
|
||||
required final Content content,
|
||||
|
||||
@JsonKey(name: "delay_ms", includeIfNull: false)
|
||||
@MSDuration()
|
||||
@Default(null)
|
||||
Duration? delay,
|
||||
}) = _SetStateRequest;
|
||||
@JsonKey(name: "delay_ms", includeIfNull: false)
|
||||
@MSDuration()
|
||||
final Duration? delay,
|
||||
}) with _$SetStateRequest {
|
||||
Map<String, Object?> toJson() => _$SetStateRequestToJson(this);
|
||||
|
||||
factory SetStateRequest.fromJson(Map<String, Object?> json) =>
|
||||
_$SetStateRequestFromJson(json);
|
||||
|
|
|
|||
|
|
@ -1,23 +1,26 @@
|
|||
import "package:freezed_annotation/freezed_annotation.dart";
|
||||
|
||||
part "upload_media.freezed.dart";
|
||||
part "upload_media.g.dart";
|
||||
|
||||
@freezed
|
||||
abstract class UploadMediaRequest with _$UploadMediaRequest {
|
||||
const factory UploadMediaRequest({
|
||||
required String path,
|
||||
required bool encrypt,
|
||||
String? filename,
|
||||
@Default(false) @JsonKey(name: "voice_message") bool isVoiceMessage,
|
||||
@Default(false) bool forceFile,
|
||||
|
||||
// Below params only work if encodeTo is set
|
||||
String? encodeTo,
|
||||
int? resizeWidth,
|
||||
int? resizeHeight,
|
||||
int? resizePercent,
|
||||
@Default(80) int quality,
|
||||
}) = _UploadMediaRequest;
|
||||
@Freezed(toJson: false, fromJson: false)
|
||||
@JsonSerializable()
|
||||
class const UploadMediaRequest({
|
||||
required final String path,
|
||||
required final bool encrypt,
|
||||
final String? filename,
|
||||
@JsonKey(name: "voice_message") final bool isVoiceMessage = false,
|
||||
final bool forceFile = false,
|
||||
final
|
||||
// Below params only work if encodeTo is set
|
||||
String?
|
||||
encodeTo,
|
||||
final int? resizeWidth,
|
||||
final int? resizeHeight,
|
||||
final int? resizePercent,
|
||||
final int quality = 80,
|
||||
}) with _$UploadMediaRequest {
|
||||
Map<String, Object?> toJson() => _$UploadMediaRequestToJson(this);
|
||||
|
||||
factory UploadMediaRequest.fromJson(Map<String, Object?> json) =>
|
||||
_$UploadMediaRequestFromJson(json);
|
||||
|
|
|
|||
Loading…
Reference in a new issue