From d9c1fdb78afcc5ba096ff3d76cfc0f90ee48bd47 Mon Sep 17 00:00:00 2001 From: Lukas Lihotzki Date: Thu, 1 Jul 2021 15:11:39 +0200 Subject: [PATCH] refactor: migrate to null safety --- lib/fake_matrix_api.dart | 8 +- lib/matrix_api_lite.dart | 2 +- lib/src/matrix_api.dart | 90 +++++------ lib/src/model/algorithm_types.dart | 2 +- lib/src/model/auth/authentication_data.dart | 6 +- .../model/auth/authentication_identifier.dart | 4 +- .../model/auth/authentication_password.dart | 6 +- .../auth/authentication_phone_identifier.dart | 4 +- .../model/auth/authentication_recaptcha.dart | 4 +- ...authentication_third_party_identifier.dart | 4 +- .../auth/authentication_three_pid_creds.dart | 10 +- lib/src/model/auth/authentication_token.dart | 6 +- lib/src/model/auth/authentication_types.dart | 2 +- .../auth/authentication_user_identifier.dart | 4 +- lib/src/model/basic_event.dart | 6 +- lib/src/model/basic_event_with_sender.dart | 2 +- lib/src/model/basic_room_event.dart | 8 +- lib/src/model/event_types.dart | 2 +- .../events/forwarded_room_key_content.dart | 2 +- .../model/events/olm_plaintext_payload.dart | 14 +- .../model/events/room_encrypted_content.dart | 12 +- .../model/events/room_encryption_content.dart | 10 +- lib/src/model/events/room_key_content.dart | 2 +- .../events/room_key_request_content.dart | 6 +- .../secret_storage_default_key_content.dart | 2 +- .../events/secret_storage_key_content.dart | 20 +-- lib/src/model/events/tombstone_content.dart | 2 +- lib/src/model/events_sync_update.dart | 10 +- .../model/matrix_connection_exception.dart | 2 +- lib/src/model/matrix_event.dart | 16 +- lib/src/model/matrix_exception.dart | 16 +- lib/src/model/matrix_keys.dart | 24 +-- lib/src/model/message_types.dart | 2 +- lib/src/model/presence.dart | 2 +- lib/src/model/presence_content.dart | 8 +- lib/src/model/request_token_response.dart | 4 +- lib/src/model/room_creation_types.dart | 2 +- lib/src/model/room_keys_keys.dart | 12 +- lib/src/model/room_summary.dart | 8 +- lib/src/model/room_types.dart | 2 +- lib/src/model/stripped_state_event.dart | 4 +- lib/src/model/supported_protocol.dart | 4 +- lib/src/model/sync_update.dart | 94 ++++++------ lib/src/model/third_party_location.dart | 2 +- lib/src/model/third_party_user.dart | 2 +- .../model/upload_key_signatures_response.dart | 6 +- lib/src/utils/logs.dart | 18 +-- lib/src/utils/map_copy_extension.dart | 2 +- lib/src/utils/try_get_map_extension.dart | 2 +- test/event_content_test.dart | 30 ++-- test/map_copy_extension_test.dart | 2 +- test/matrix_api_test.dart | 140 +++++++++--------- test/try_get_map_extension_test.dart | 2 +- 53 files changed, 328 insertions(+), 328 deletions(-) diff --git a/lib/fake_matrix_api.dart b/lib/fake_matrix_api.dart index f2b3f6de..b1e80ed9 100644 --- a/lib/fake_matrix_api.dart +++ b/lib/fake_matrix_api.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + /* MIT License * * Copyright (C) 2019, 2020, 2021 Famedly GmbH @@ -83,9 +83,9 @@ class FakeMatrixApi extends MockClient { if (!calledEndpoints.containsKey(action)) { calledEndpoints[action] = []; } - calledEndpoints[action].add(data); - if (api.containsKey(method) && api[method].containsKey(action)) { - res = api[method][action](data); + calledEndpoints[action]!.add(data); + if (api.containsKey(method) && api[method]!.containsKey(action)) { + res = api[method]![action](data); if (res is Map && res.containsKey('errcode')) { statusCode = 405; } diff --git a/lib/matrix_api_lite.dart b/lib/matrix_api_lite.dart index 6695187e..3a638c49 100644 --- a/lib/matrix_api_lite.dart +++ b/lib/matrix_api_lite.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + /* MIT License * * Copyright (C) 2019, 2020, 2021 Famedly GmbH diff --git a/lib/src/matrix_api.dart b/lib/src/matrix_api.dart index cf471414..31dc95be 100644 --- a/lib/src/matrix_api.dart +++ b/lib/src/matrix_api.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + /* MIT License * * Copyright (C) 2019, 2020, 2021 Famedly GmbH @@ -54,13 +54,13 @@ String describeEnum(Object enumEntry) { class MatrixApi extends Api { /// The homeserver this client is communicating with. - Uri get homeserver => baseUri; - set homeserver(Uri uri) => baseUri = uri; + Uri? get homeserver => baseUri; + set homeserver(Uri? uri) => baseUri = uri; /// This is the access token for the matrix client. When it is undefined, then /// the user needs to sign in first. - String get accessToken => bearerToken; - set accessToken(String token) => bearerToken = token; + String? get accessToken => bearerToken; + set accessToken(String? token) => bearerToken = token; @override Null unexpectedResponse(http.BaseResponse response, Uint8List responseBody) { @@ -71,9 +71,9 @@ class MatrixApi extends Api { } MatrixApi({ - Uri homeserver, - String accessToken, - http.Client httpClient, + Uri? homeserver, + String? accessToken, + http.Client? httpClient, }) : super( httpClient: httpClient, baseUri: homeserver, @@ -102,7 +102,7 @@ class MatrixApi extends Api { String action, { dynamic data = '', String contentType = 'application/json', - Map query, + Map? query, }) async { if (homeserver == null) { throw ('No homeserver specified.'); @@ -111,7 +111,7 @@ class MatrixApi extends Api { (!(data is String)) ? json = jsonEncode(data) : json = data; if (data is List || action.startsWith('/media/r0/upload')) json = data; - final url = homeserver + final url = homeserver! .resolveUri(Uri(path: '_matrix$action', queryParameters: query)); final headers = {}; @@ -122,8 +122,8 @@ class MatrixApi extends Api { headers['Authorization'] = 'Bearer $accessToken'; } - http.Response resp; - var jsonResp = {}; + late http.Response resp; + Map? jsonResp = {}; try { switch (type) { case RequestType.GET: @@ -153,7 +153,7 @@ class MatrixApi extends Api { jsonString = '\{"chunk":$jsonString\}'; } jsonResp = jsonDecode(jsonString) - as Map; // May throw FormatException + as Map?; // May throw FormatException } catch (e, s) { throw MatrixConnectionException(e, s); } @@ -161,7 +161,7 @@ class MatrixApi extends Api { throw MatrixException(resp); } - return jsonResp; + return jsonResp!; } /// The homeserver must check that the given email address is not already associated @@ -173,9 +173,9 @@ class MatrixApi extends Api { String email, String clientSecret, int sendAttempt, { - String nextLink, - String idServer, - String idAccessToken, + String? nextLink, + String? idServer, + String? idAccessToken, }) async { final response = await request( RequestType.POST, '/client/r0/register/email/requestToken', @@ -199,9 +199,9 @@ class MatrixApi extends Api { String phoneNumber, String clientSecret, int sendAttempt, { - String nextLink, - String idServer, - String idAccessToken, + String? nextLink, + String? idServer, + String? idAccessToken, }) async { final response = await request( RequestType.POST, '/client/r0/register/msisdn/requestToken', @@ -225,9 +225,9 @@ class MatrixApi extends Api { String email, String clientSecret, int sendAttempt, { - String nextLink, - String idServer, - String idAccessToken, + String? nextLink, + String? idServer, + String? idAccessToken, }) async { final response = await request( RequestType.POST, '/client/r0/account/password/email/requestToken', @@ -251,9 +251,9 @@ class MatrixApi extends Api { String phoneNumber, String clientSecret, int sendAttempt, { - String nextLink, - String idServer, - String idAccessToken, + String? nextLink, + String? idServer, + String? idAccessToken, }) async { final response = await request( RequestType.POST, '/client/r0/account/password/msisdn/requestToken', @@ -275,9 +275,9 @@ class MatrixApi extends Api { String email, String clientSecret, int sendAttempt, { - String nextLink, - String idServer, - String idAccessToken, + String? nextLink, + String? idServer, + String? idAccessToken, }) async { final response = await request( RequestType.POST, '/client/r0/account/3pid/email/requestToken', @@ -299,9 +299,9 @@ class MatrixApi extends Api { String phoneNumber, String clientSecret, int sendAttempt, { - String nextLink, - String idServer, - String idAccessToken, + String? nextLink, + String? idServer, + String? idAccessToken, }) async { final response = await request( RequestType.POST, '/client/r0/account/3pid/msisdn/requestToken', @@ -323,7 +323,7 @@ class MatrixApi extends Api { /// https://matrix.org/docs/spec/client_server/r0.6.0#get-matrix-client-r0-rooms-roomid-state-eventtype-statekey Future> requestStateContent( String roomId, String eventType, - [String stateKey]) async { + [String? stateKey]) async { var url = '/client/r0/rooms/${Uri.encodeComponent(roomId)}/state/${Uri.encodeComponent(eventType)}/'; if (stateKey != null) { @@ -364,9 +364,9 @@ class MatrixApi extends Api { /// Publishes end-to-end encryption keys for the device. /// https://matrix.org/docs/spec/client_server/r0.6.1#post-matrix-client-r0-keys-query Future> uploadKeys( - {MatrixDeviceKeys deviceKeys, - Map oneTimeKeys, - Map fallbackKeys}) async { + {MatrixDeviceKeys? deviceKeys, + Map? oneTimeKeys, + Map? fallbackKeys}) async { final response = await request( RequestType.POST, '/client/r0/keys/upload', @@ -385,10 +385,10 @@ class MatrixApi extends Api { /// Uploads your own cross-signing keys. /// https://github.com/matrix-org/matrix-doc/pull/2536 Future uploadDeviceSigningKeys({ - MatrixCrossSigningKey masterKey, - MatrixCrossSigningKey selfSigningKey, - MatrixCrossSigningKey userSigningKey, - AuthenticationData auth, + MatrixCrossSigningKey? masterKey, + MatrixCrossSigningKey? selfSigningKey, + MatrixCrossSigningKey? userSigningKey, + AuthenticationData? auth, }) async { await request( RequestType.POST, @@ -410,7 +410,7 @@ class MatrixApi extends Api { for (final key in keys) { if (key.identifier == null || key.signatures == null || - key.signatures.isEmpty) { + key.signatures!.isEmpty) { continue; } if (!payload.containsKey(key.userId)) { @@ -437,7 +437,7 @@ class MatrixApi extends Api { /// for this user ID. The behaviour of this endpoint varies depending on the /// values in the JSON body. /// https://matrix.org/docs/spec/client_server/r0.6.1#post-matrix-client-r0-pushers-set - Future postPusher(Pusher pusher, {bool append}) async { + Future postPusher(Pusher pusher, {bool? append}) async { final data = pusher.toJson(); if (append != null) { data['append'] = append; @@ -454,9 +454,9 @@ class MatrixApi extends Api { /// caller. This will block until an event is received, or until the timeout is reached. /// https://matrix.org/docs/spec/client_server/r0.6.1#get-matrix-client-r0-events Future getEvents({ - String from, - int timeout, - String roomId, + String? from, + int? timeout, + String? roomId, }) async { final response = await request(RequestType.GET, '/client/r0/events', query: { diff --git a/lib/src/model/algorithm_types.dart b/lib/src/model/algorithm_types.dart index 207ccd96..59144cf3 100644 --- a/lib/src/model/algorithm_types.dart +++ b/lib/src/model/algorithm_types.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + /* MIT License * * Copyright (C) 2019, 2020, 2021 Famedly GmbH diff --git a/lib/src/model/auth/authentication_data.dart b/lib/src/model/auth/authentication_data.dart index 68441c43..85d39767 100644 --- a/lib/src/model/auth/authentication_data.dart +++ b/lib/src/model/auth/authentication_data.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + /* MIT License * * Copyright (C) 2019, 2020, 2021 Famedly GmbH @@ -24,9 +24,9 @@ class AuthenticationData { String type; - String session; + String?/*?*//*?*/ session; - AuthenticationData({this.type, this.session}); + AuthenticationData({required this.type, this.session}); AuthenticationData.fromJson(Map json) : type = json['type'], diff --git a/lib/src/model/auth/authentication_identifier.dart b/lib/src/model/auth/authentication_identifier.dart index 14047d42..572932a0 100644 --- a/lib/src/model/auth/authentication_identifier.dart +++ b/lib/src/model/auth/authentication_identifier.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + /* MIT License * * Copyright (C) 2019, 2020, 2021 Famedly GmbH @@ -30,7 +30,7 @@ import 'authentication_third_party_identifier.dart'; class AuthenticationIdentifier { String type; - AuthenticationIdentifier({this.type}); + AuthenticationIdentifier({required this.type}); AuthenticationIdentifier.fromJson(Map json) : type = json['type']; diff --git a/lib/src/model/auth/authentication_password.dart b/lib/src/model/auth/authentication_password.dart index 99d2c26d..b1066c2f 100644 --- a/lib/src/model/auth/authentication_password.dart +++ b/lib/src/model/auth/authentication_password.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + /* MIT License * * Copyright (C) 2019, 2020, 2021 Famedly GmbH @@ -29,7 +29,7 @@ import 'authentication_identifier.dart'; import 'authentication_types.dart'; class AuthenticationPassword extends AuthenticationData { - String user; + String? user; String password; /// You may want to cast this as [AuthenticationUserIdentifier] or other @@ -37,7 +37,7 @@ class AuthenticationPassword extends AuthenticationData { AuthenticationIdentifier identifier; AuthenticationPassword( - {String session, this.password, this.user, this.identifier}) + {String? session, required this.password, this.user, required this.identifier}) : super( type: AuthenticationTypes.password, session: session, diff --git a/lib/src/model/auth/authentication_phone_identifier.dart b/lib/src/model/auth/authentication_phone_identifier.dart index 7ae42bf6..5e3c7779 100644 --- a/lib/src/model/auth/authentication_phone_identifier.dart +++ b/lib/src/model/auth/authentication_phone_identifier.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + /* MIT License * * Copyright (C) 2019, 2020, 2021 Famedly GmbH @@ -29,7 +29,7 @@ class AuthenticationPhoneIdentifier extends AuthenticationIdentifier { String country; String phone; - AuthenticationPhoneIdentifier({this.country, this.phone}) + AuthenticationPhoneIdentifier({required this.country, required this.phone}) : super(type: AuthenticationIdentifierTypes.phone); AuthenticationPhoneIdentifier.fromJson(Map json) diff --git a/lib/src/model/auth/authentication_recaptcha.dart b/lib/src/model/auth/authentication_recaptcha.dart index 256f1931..fdedf5b3 100644 --- a/lib/src/model/auth/authentication_recaptcha.dart +++ b/lib/src/model/auth/authentication_recaptcha.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + /* MIT License * * Copyright (C) 2019, 2020, 2021 Famedly GmbH @@ -28,7 +28,7 @@ import 'authentication_types.dart'; class AuthenticationRecaptcha extends AuthenticationData { String response; - AuthenticationRecaptcha({String session, this.response}) + AuthenticationRecaptcha({required String session, required this.response}) : super( type: AuthenticationTypes.recaptcha, session: session, diff --git a/lib/src/model/auth/authentication_third_party_identifier.dart b/lib/src/model/auth/authentication_third_party_identifier.dart index 3cb44fe3..94b55e28 100644 --- a/lib/src/model/auth/authentication_third_party_identifier.dart +++ b/lib/src/model/auth/authentication_third_party_identifier.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + /* MIT License * * Copyright (C) 2019, 2020, 2021 Famedly GmbH @@ -29,7 +29,7 @@ class AuthenticationThirdPartyIdentifier extends AuthenticationIdentifier { String medium; String address; - AuthenticationThirdPartyIdentifier({this.medium, this.address}) + AuthenticationThirdPartyIdentifier({required this.medium, required this.address}) : super(type: AuthenticationIdentifierTypes.thirdParty); AuthenticationThirdPartyIdentifier.fromJson(Map json) diff --git a/lib/src/model/auth/authentication_three_pid_creds.dart b/lib/src/model/auth/authentication_three_pid_creds.dart index faaef644..2961ac56 100644 --- a/lib/src/model/auth/authentication_three_pid_creds.dart +++ b/lib/src/model/auth/authentication_three_pid_creds.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + /* MIT License * * Copyright (C) 2019, 2020, 2021 Famedly GmbH @@ -29,9 +29,9 @@ import 'authentication_data.dart'; /// Or phone number based identity: /// https://matrix.org/docs/spec/client_server/r0.6.1#phone-number-msisdn-based-identity-homeserver class AuthenticationThreePidCreds extends AuthenticationData { - List threepidCreds; + late List threepidCreds; - AuthenticationThreePidCreds({String session, String type, this.threepidCreds}) + AuthenticationThreePidCreds({String? session, required String type, required this.threepidCreds}) : super( type: type, session: session, @@ -65,13 +65,13 @@ class AuthenticationThreePidCreds extends AuthenticationData { } class ThreepidCreds { - String sid; + String/*!*/ sid; String clientSecret; String idServer; String idAccessToken; ThreepidCreds( - {this.sid, this.clientSecret, this.idServer, this.idAccessToken}); + {required this.sid, required this.clientSecret, required this.idServer, required this.idAccessToken}); ThreepidCreds.fromJson(Map json) : sid = json['sid'], diff --git a/lib/src/model/auth/authentication_token.dart b/lib/src/model/auth/authentication_token.dart index 32d42dd3..63233f4f 100644 --- a/lib/src/model/auth/authentication_token.dart +++ b/lib/src/model/auth/authentication_token.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + /* MIT License * * Copyright (C) 2019, 2020, 2021 Famedly GmbH @@ -27,9 +27,9 @@ import 'authentication_types.dart'; class AuthenticationToken extends AuthenticationData { String token; - String txnId; + String? txnId; - AuthenticationToken({String session, this.token, this.txnId}) + AuthenticationToken({String? session, required this.token, this.txnId}) : super( type: AuthenticationTypes.token, session: session, diff --git a/lib/src/model/auth/authentication_types.dart b/lib/src/model/auth/authentication_types.dart index 2a667ee6..00f13793 100644 --- a/lib/src/model/auth/authentication_types.dart +++ b/lib/src/model/auth/authentication_types.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + /* MIT License * * Copyright (C) 2019, 2020, 2021 Famedly GmbH diff --git a/lib/src/model/auth/authentication_user_identifier.dart b/lib/src/model/auth/authentication_user_identifier.dart index 0e1a98dc..974f7fee 100644 --- a/lib/src/model/auth/authentication_user_identifier.dart +++ b/lib/src/model/auth/authentication_user_identifier.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + /* MIT License * * Copyright (C) 2019, 2020, 2021 Famedly GmbH @@ -28,7 +28,7 @@ import 'authentication_types.dart'; class AuthenticationUserIdentifier extends AuthenticationIdentifier { String user; - AuthenticationUserIdentifier({this.user}) + AuthenticationUserIdentifier({required this.user}) : super(type: AuthenticationIdentifierTypes.userId); AuthenticationUserIdentifier.fromJson(Map json) diff --git a/lib/src/model/basic_event.dart b/lib/src/model/basic_event.dart index 0be5741f..666fa516 100644 --- a/lib/src/model/basic_event.dart +++ b/lib/src/model/basic_event.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + /* MIT License * * Copyright (C) 2019, 2020, 2021 Famedly GmbH @@ -29,8 +29,8 @@ class BasicEvent { Map content; BasicEvent({ - this.type, - this.content, + required this.type, + required this.content, }); BasicEvent.fromJson(Map json) diff --git a/lib/src/model/basic_event_with_sender.dart b/lib/src/model/basic_event_with_sender.dart index 78a7979b..4b6114a7 100644 --- a/lib/src/model/basic_event_with_sender.dart +++ b/lib/src/model/basic_event_with_sender.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + /* MIT License * * Copyright (C) 2019, 2020, 2021 Famedly GmbH diff --git a/lib/src/model/basic_room_event.dart b/lib/src/model/basic_room_event.dart index 4e9a0cf5..66eff7d8 100644 --- a/lib/src/model/basic_room_event.dart +++ b/lib/src/model/basic_room_event.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + /* MIT License * * Copyright (C) 2019, 2020, 2021 Famedly GmbH @@ -25,12 +25,12 @@ import 'basic_event.dart'; class BasicRoomEvent extends BasicEvent { - String roomId; + String? roomId; BasicRoomEvent({ this.roomId, - Map content, - String type, + required Map content, + required String type, }) : super( content: content, type: type, diff --git a/lib/src/model/event_types.dart b/lib/src/model/event_types.dart index 50840346..19623f5d 100644 --- a/lib/src/model/event_types.dart +++ b/lib/src/model/event_types.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + /* MIT License * * Copyright (C) 2019, 2020, 2021 Famedly GmbH diff --git a/lib/src/model/events/forwarded_room_key_content.dart b/lib/src/model/events/forwarded_room_key_content.dart index a9b238fc..fb8ca523 100644 --- a/lib/src/model/events/forwarded_room_key_content.dart +++ b/lib/src/model/events/forwarded_room_key_content.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + /* MIT License * * Copyright (C) 2019, 2020, 2021 Famedly GmbH diff --git a/lib/src/model/events/olm_plaintext_payload.dart b/lib/src/model/events/olm_plaintext_payload.dart index 55f377f3..69a6d0e8 100644 --- a/lib/src/model/events/olm_plaintext_payload.dart +++ b/lib/src/model/events/olm_plaintext_payload.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + /* MIT License * * Copyright (C) 2019, 2020, 2021 Famedly GmbH @@ -25,12 +25,12 @@ import '../../utils/try_get_map_extension.dart'; class OlmPlaintextPayload { - String type; - Map content; - String sender; - String recipient; - Map recipientKeys; - Map keys; + String? type; + Map? content; + String? sender; + String? recipient; + Map? recipientKeys; + Map? keys; OlmPlaintextPayload({ this.type, diff --git a/lib/src/model/events/room_encrypted_content.dart b/lib/src/model/events/room_encrypted_content.dart index 0b132541..3608621a 100644 --- a/lib/src/model/events/room_encrypted_content.dart +++ b/lib/src/model/events/room_encrypted_content.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + /* MIT License * * Copyright (C) 2019, 2020, 2021 Famedly GmbH @@ -35,10 +35,10 @@ extension RoomEncryptedContentBasicEventExtension on BasicEvent { class RoomEncryptedContent { String algorithm; String senderKey; - String deviceId; - String sessionId; - String ciphertextMegolm; - Map ciphertextOlm; + String? deviceId; + String? sessionId; + String? ciphertextMegolm; + Map? ciphertextOlm; RoomEncryptedContent.fromJson(Map json) : algorithm = json.tryGet('algorithm', ''), @@ -68,7 +68,7 @@ class RoomEncryptedContent { data['ciphertext'] = ciphertextMegolm; } if (ciphertextOlm != null) { - data['ciphertext'] = ciphertextOlm.map((k, v) => MapEntry(k, v.toJson())); + data['ciphertext'] = ciphertextOlm!.map((k, v) => MapEntry(k, v.toJson())); if (ciphertextMegolm != null) { Logs().wtf( 'ciphertextOlm and ciphertextMegolm are both set, which should never happen!'); diff --git a/lib/src/model/events/room_encryption_content.dart b/lib/src/model/events/room_encryption_content.dart index 33afcda2..c639ba67 100644 --- a/lib/src/model/events/room_encryption_content.dart +++ b/lib/src/model/events/room_encryption_content.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + /* MIT License * * Copyright (C) 2019, 2020, 2021 Famedly GmbH @@ -32,13 +32,13 @@ extension RoomEncryptionContentBasicEventExtension on BasicEvent { class RoomEncryptionContent { String algorithm; - int rotationPeriodMs; - int rotationPeriodMsgs; + int? rotationPeriodMs; + int? rotationPeriodMsgs; RoomEncryptionContent.fromJson(Map json) : algorithm = json.tryGet('algorithm', ''), - rotationPeriodMs = json.tryGet('rotation_period_ms'), - rotationPeriodMsgs = json.tryGet('rotation_period_msgs'); + rotationPeriodMs = json.tryGet('rotation_period_ms'), + rotationPeriodMsgs = json.tryGet('rotation_period_msgs'); Map toJson() { final data = {}; diff --git a/lib/src/model/events/room_key_content.dart b/lib/src/model/events/room_key_content.dart index 8686db21..4149ffad 100644 --- a/lib/src/model/events/room_key_content.dart +++ b/lib/src/model/events/room_key_content.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + /* MIT License * * Copyright (C) 2019, 2020, 2021 Famedly GmbH diff --git a/lib/src/model/events/room_key_request_content.dart b/lib/src/model/events/room_key_request_content.dart index ca690e52..1a7e6871 100644 --- a/lib/src/model/events/room_key_request_content.dart +++ b/lib/src/model/events/room_key_request_content.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + /* MIT License * * Copyright (C) 2019, 2020, 2021 Famedly GmbH @@ -31,7 +31,7 @@ extension RoomKeyRequestContentBasicEventExtension on BasicEvent { } class RoomKeyRequestContent { - RequestedKeyInfo body; + RequestedKeyInfo? body; String action; String requestingDeviceId; String requestId; @@ -45,7 +45,7 @@ class RoomKeyRequestContent { Map toJson() { final data = {}; - if (body != null) data['body'] = body.toJson(); + if (body != null) data['body'] = body!.toJson(); data['action'] = action; data['requesting_device_id'] = requestingDeviceId; data['request_id'] = requestId; diff --git a/lib/src/model/events/secret_storage_default_key_content.dart b/lib/src/model/events/secret_storage_default_key_content.dart index a8630813..389795d0 100644 --- a/lib/src/model/events/secret_storage_default_key_content.dart +++ b/lib/src/model/events/secret_storage_default_key_content.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + /* MIT License * * Copyright (C) 2019, 2020, 2021 Famedly GmbH diff --git a/lib/src/model/events/secret_storage_key_content.dart b/lib/src/model/events/secret_storage_key_content.dart index de7e3618..8e10a182 100644 --- a/lib/src/model/events/secret_storage_key_content.dart +++ b/lib/src/model/events/secret_storage_key_content.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + /* MIT License * * Copyright (C) 2019, 2020, 2021 Famedly GmbH @@ -31,10 +31,10 @@ extension SecretStorageKeyContentBasicEventExtension on BasicEvent { } class SecretStorageKeyContent { - PassphraseInfo passphrase; - String iv; - String mac; - String algorithm; + PassphraseInfo? passphrase; + String? iv; + String? mac; + String? algorithm; SecretStorageKeyContent(); @@ -42,13 +42,13 @@ class SecretStorageKeyContent { : passphrase = json['passphrase'] is Map ? PassphraseInfo.fromJson(json['passphrase']) : null, - iv = json.tryGet('iv'), - mac = json.tryGet('mac'), - algorithm = json.tryGet('algorithm'); + iv = json.tryGet('iv'), + mac = json.tryGet('mac'), + algorithm = json.tryGet('algorithm'); Map toJson() { final data = {}; - if (passphrase != null) data['passphrase'] = passphrase.toJson(); + if (passphrase != null) data['passphrase'] = passphrase!.toJson(); if (iv != null) data['iv'] = iv; if (mac != null) data['mac'] = mac; if (algorithm != null) data['algorithm'] = algorithm; @@ -60,7 +60,7 @@ class PassphraseInfo { String algorithm; String salt; int iterations; - int bits; + int? bits; PassphraseInfo(); diff --git a/lib/src/model/events/tombstone_content.dart b/lib/src/model/events/tombstone_content.dart index 9e939223..93a8221f 100644 --- a/lib/src/model/events/tombstone_content.dart +++ b/lib/src/model/events/tombstone_content.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + /* MIT License * * Copyright (C) 2019, 2020, 2021 Famedly GmbH diff --git a/lib/src/model/events_sync_update.dart b/lib/src/model/events_sync_update.dart index 1a215473..a93ee5b3 100644 --- a/lib/src/model/events_sync_update.dart +++ b/lib/src/model/events_sync_update.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + /* MIT License * * Copyright (C) 2019, 2020, 2021 Famedly GmbH @@ -25,9 +25,9 @@ import 'matrix_event.dart'; class EventsSyncUpdate { - String start; - String end; - List chunk; + String? start; + String? end; + List? chunk; EventsSyncUpdate.fromJson(Map json) : start = json['start'], @@ -47,7 +47,7 @@ class EventsSyncUpdate { data['end'] = end; } if (chunk != null) { - data['chunk'] = chunk.map((i) => i.toJson()).toList(); + data['chunk'] = chunk!.map((i) => i.toJson()).toList(); } return data; } diff --git a/lib/src/model/matrix_connection_exception.dart b/lib/src/model/matrix_connection_exception.dart index d9cfb113..96d12af9 100644 --- a/lib/src/model/matrix_connection_exception.dart +++ b/lib/src/model/matrix_connection_exception.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + /* MIT License * * Copyright (C) 2019, 2020, 2021 Famedly GmbH diff --git a/lib/src/model/matrix_event.dart b/lib/src/model/matrix_event.dart index a2aba791..b54856db 100644 --- a/lib/src/model/matrix_event.dart +++ b/lib/src/model/matrix_event.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + /* MIT License * * Copyright (C) 2019, 2020, 2021 Famedly GmbH @@ -27,11 +27,11 @@ import '../utils/map_copy_extension.dart'; class MatrixEvent extends StrippedStateEvent { String eventId; - String roomId; - DateTime originServerTs; - Map unsigned; - Map prevContent; - String redacts; + String? roomId; + late DateTime originServerTs; + Map? unsigned; + Map? prevContent; + String? redacts; MatrixEvent(); @@ -40,8 +40,8 @@ class MatrixEvent extends StrippedStateEvent { roomId = json['room_id'], originServerTs = DateTime.fromMillisecondsSinceEpoch(json['origin_server_ts']), - unsigned = (json['unsigned'] as Map)?.copy(), - prevContent = (json['prev_content'] as Map)?.copy(), + unsigned = (json['unsigned'] as Map?)?.copy(), + prevContent = (json['prev_content'] as Map?)?.copy(), redacts = json['redacts'], super.fromJson(json); diff --git a/lib/src/model/matrix_exception.dart b/lib/src/model/matrix_exception.dart index 4365d4ef..f2a03e24 100644 --- a/lib/src/model/matrix_exception.dart +++ b/lib/src/model/matrix_exception.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + /* MIT License * * Copyright (C) 2019, 2020, 2021 Famedly GmbH @@ -60,9 +60,9 @@ class MatrixException implements Exception { : 'Unknown error'); /// The frozen request which triggered this Error - http.Response response; + http.Response? response; - MatrixException(this.response) : raw = json.decode(response.body); + MatrixException(Response this.response) : raw = json.decode(response.body); MatrixException.fromJson(Map content) : raw = content; @override @@ -73,21 +73,21 @@ class MatrixException implements Exception { (e) => e.toString() == 'MatrixError.${(raw["errcode"] ?? "")}', orElse: () => MatrixError.M_UNKNOWN); - int get retryAfterMs => raw['retry_after_ms']; + int? get retryAfterMs => raw['retry_after_ms']; /// This is a session identifier that the client must pass back to the homeserver, if one is provided, /// in subsequent attempts to authenticate in the same API call. - String get session => raw['session']; + String? get session => raw['session']; /// Returns true if the server requires additional authentication. bool get requireAdditionalAuthentication => response != null - ? response.statusCode == 401 + ? response!.statusCode == 401 : authenticationFlows != null; /// For each endpoint, a server offers one or more 'flows' that the client can use /// to authenticate itself. Each flow comprises a series of stages. If this request /// doesn't need additional authentication, then this is null. - List get authenticationFlows { + List?/*?*/ get authenticationFlows { if (!raw.containsKey('flows') || !(raw['flows'] is List)) return null; return (raw['flows'] as List) .map((flow) => flow['stages']) @@ -99,7 +99,7 @@ class MatrixException implements Exception { /// This section contains any information that the client will need to know in order to use a given type /// of authentication. For each authentication type presented, that type may be present as a key in this /// dictionary. For example, the public part of an OAuth client ID could be given here. - Map get authenticationParams => raw['params']; + Map? get authenticationParams => raw['params']; /// Returns the list of already completed authentication flows from previous requests. List get completedAuthenticationFlows => diff --git a/lib/src/model/matrix_keys.dart b/lib/src/model/matrix_keys.dart index 9f179480..2ad89ed1 100644 --- a/lib/src/model/matrix_keys.dart +++ b/lib/src/model/matrix_keys.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + /* MIT License * * Copyright (C) 2019, 2020, 2021 Famedly GmbH @@ -26,16 +26,16 @@ import '../utils/map_copy_extension.dart'; class MatrixSignableKey { String userId; - String identifier; + String? identifier; Map keys; - Map> signatures; - Map unsigned; + Map>? signatures; + Map? unsigned; MatrixSignableKey(this.userId, this.identifier, this.keys, this.signatures, {this.unsigned}); // This object is used for signing so we need the raw json too - Map _json; + Map? _json; MatrixSignableKey.fromJson(Map json) : _json = json, @@ -46,7 +46,7 @@ class MatrixSignableKey { ? Map>.from((json['signatures'] as Map) .map((k, v) => MapEntry(k, Map.from(v)))) : null, - unsigned = (json['unsigned'] as Map)?.copy(); + unsigned = (json['unsigned'] as Map?)?.copy(); Map toJson() { final data = _json ?? {}; @@ -65,14 +65,14 @@ class MatrixSignableKey { class MatrixCrossSigningKey extends MatrixSignableKey { List usage; - String get publicKey => identifier; + String? get publicKey => identifier; MatrixCrossSigningKey( String userId, this.usage, Map keys, Map> signatures, { - Map unsigned, + Map? unsigned, }) : super(userId, keys?.values?.first, keys, signatures, unsigned: unsigned); @override @@ -91,10 +91,10 @@ class MatrixCrossSigningKey extends MatrixSignableKey { } class MatrixDeviceKeys extends MatrixSignableKey { - String get deviceId => identifier; + String get deviceId => identifier!; List algorithms; - String get deviceDisplayName => - unsigned != null ? unsigned['device_display_name'] : null; + String? get deviceDisplayName => + unsigned != null ? unsigned!['device_display_name'] : null; MatrixDeviceKeys( String userId, @@ -102,7 +102,7 @@ class MatrixDeviceKeys extends MatrixSignableKey { this.algorithms, Map keys, Map> signatures, { - Map unsigned, + Map? unsigned, }) : super(userId, deviceId, keys, signatures, unsigned: unsigned); @override diff --git a/lib/src/model/message_types.dart b/lib/src/model/message_types.dart index 0a9b240c..e6cbc443 100644 --- a/lib/src/model/message_types.dart +++ b/lib/src/model/message_types.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + /* MIT License * * Copyright (C) 2019, 2020, 2021 Famedly GmbH diff --git a/lib/src/model/presence.dart b/lib/src/model/presence.dart index c5091d5c..4874ea54 100644 --- a/lib/src/model/presence.dart +++ b/lib/src/model/presence.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + /* MIT License * * Copyright (C) 2019, 2020, 2021 Famedly GmbH diff --git a/lib/src/model/presence_content.dart b/lib/src/model/presence_content.dart index b7bab947..0df3f0c2 100644 --- a/lib/src/model/presence_content.dart +++ b/lib/src/model/presence_content.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + /* MIT License * * Copyright (C) 2019, 2020, 2021 Famedly GmbH @@ -26,9 +26,9 @@ import '../generated/model.dart'; class PresenceContent { PresenceType presence; - int lastActiveAgo; - String statusMsg; - bool currentlyActive; + int? lastActiveAgo; + String? statusMsg; + bool? currentlyActive; PresenceContent.fromJson(Map json) : presence = PresenceType.values.firstWhere( diff --git a/lib/src/model/request_token_response.dart b/lib/src/model/request_token_response.dart index 00dd1e68..46f24e5c 100644 --- a/lib/src/model/request_token_response.dart +++ b/lib/src/model/request_token_response.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + /* MIT License * * Copyright (C) 2019, 2020, 2021 Famedly GmbH @@ -24,7 +24,7 @@ class RequestTokenResponse { String sid; - String submitUrl; + String? submitUrl; RequestTokenResponse.fromJson(Map json) : sid = json['sid'], diff --git a/lib/src/model/room_creation_types.dart b/lib/src/model/room_creation_types.dart index fb41cb6c..be7b75d9 100644 --- a/lib/src/model/room_creation_types.dart +++ b/lib/src/model/room_creation_types.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + abstract class RoomCreationTypes { static const String mSpace = 'm.space'; } diff --git a/lib/src/model/room_keys_keys.dart b/lib/src/model/room_keys_keys.dart index 0e8122ba..b285c454 100644 --- a/lib/src/model/room_keys_keys.dart +++ b/lib/src/model/room_keys_keys.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + /* MIT License * * Copyright (C) 2019, 2020, 2021 Famedly GmbH @@ -29,10 +29,10 @@ class RoomKeysSingleKey { Map sessionData; RoomKeysSingleKey( - {this.firstMessageIndex, - this.forwardedCount, - this.isVerified, - this.sessionData}); + {required this.firstMessageIndex, + required this.forwardedCount, + required this.isVerified, + required this.sessionData}); RoomKeysSingleKey.fromJson(Map json) : firstMessageIndex = json['first_message_index'], @@ -53,7 +53,7 @@ class RoomKeysSingleKey { class RoomKeysRoom { Map sessions; - RoomKeysRoom({this.sessions}) { + RoomKeysRoom({required this.sessions}) { sessions ??= {}; } diff --git a/lib/src/model/room_summary.dart b/lib/src/model/room_summary.dart index 24a9d444..74dded00 100644 --- a/lib/src/model/room_summary.dart +++ b/lib/src/model/room_summary.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + /* MIT License * * Copyright (C) 2019, 2020, 2021 Famedly GmbH @@ -23,9 +23,9 @@ */ class RoomSummary { - List mHeroes; - int mJoinedMemberCount; - int mInvitedMemberCount; + List? mHeroes; + int? mJoinedMemberCount; + int? mInvitedMemberCount; RoomSummary.fromJson(Map json) : mHeroes = json['m.heroes'] != null ? List.from(json['m.heroes']) diff --git a/lib/src/model/room_types.dart b/lib/src/model/room_types.dart index 6a84114f..7dbcf0f5 100644 --- a/lib/src/model/room_types.dart +++ b/lib/src/model/room_types.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + /* MIT License * * Copyright (C) 2019, 2020, 2021 Famedly GmbH diff --git a/lib/src/model/stripped_state_event.dart b/lib/src/model/stripped_state_event.dart index cf222869..cb8f914d 100644 --- a/lib/src/model/stripped_state_event.dart +++ b/lib/src/model/stripped_state_event.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + /* MIT License * * Copyright (C) 2019, 2020, 2021 Famedly GmbH @@ -25,7 +25,7 @@ import 'basic_event_with_sender.dart'; class StrippedStateEvent extends BasicEventWithSender { - String stateKey; + String? stateKey; StrippedStateEvent(); StrippedStateEvent.fromJson(Map json) diff --git a/lib/src/model/supported_protocol.dart b/lib/src/model/supported_protocol.dart index 5a168f06..32cba75c 100644 --- a/lib/src/model/supported_protocol.dart +++ b/lib/src/model/supported_protocol.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + /* MIT License * * Copyright (C) 2019, 2020, 2021 Famedly GmbH @@ -72,7 +72,7 @@ class ProtocolFieldType { class ProtocolInstance { String networkId; String desc; - String icon; + String? icon; dynamic fields; ProtocolInstance.fromJson(Map json) { diff --git a/lib/src/model/sync_update.dart b/lib/src/model/sync_update.dart index c4d158a5..5b93d1ef 100644 --- a/lib/src/model/sync_update.dart +++ b/lib/src/model/sync_update.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + /* MIT License * * Copyright (C) 2019, 2020, 2021 Famedly GmbH @@ -32,13 +32,13 @@ import 'stripped_state_event.dart'; class SyncUpdate { String nextBatch; - RoomsUpdate rooms; - List presence; - List accountData; - List toDevice; - DeviceListsUpdate deviceLists; - Map deviceOneTimeKeysCount; - List deviceUnusedFallbackKeyTypes; + RoomsUpdate? rooms; + List? presence; + List? accountData; + List? toDevice; + DeviceListsUpdate? deviceLists; + Map? deviceOneTimeKeysCount; + List? deviceUnusedFallbackKeyTypes; SyncUpdate(); @@ -83,25 +83,25 @@ class SyncUpdate { final data = {}; data['next_batch'] = nextBatch; if (rooms != null) { - data['rooms'] = rooms.toJson(); + data['rooms'] = rooms!.toJson(); } if (presence != null) { data['presence'] = { - 'events': presence.map((i) => i.toJson()).toList(), + 'events': presence!.map((i) => i.toJson()).toList(), }; } if (accountData != null) { data['account_data'] = { - 'events': accountData.map((i) => i.toJson()).toList(), + 'events': accountData!.map((i) => i.toJson()).toList(), }; } if (toDevice != null) { data['to_device'] = { - 'events': toDevice.map((i) => i.toJson()).toList(), + 'events': toDevice!.map((i) => i.toJson()).toList(), }; } if (deviceLists != null) { - data['device_lists'] = deviceLists.toJson(); + data['device_lists'] = deviceLists!.toJson(); } if (deviceOneTimeKeysCount != null) { data['device_one_time_keys_count'] = deviceOneTimeKeysCount; @@ -116,9 +116,9 @@ class SyncUpdate { } class RoomsUpdate { - Map join; - Map invite; - Map leave; + Map? join; + Map? invite; + Map? leave; RoomsUpdate(); @@ -139,13 +139,13 @@ class RoomsUpdate { Map toJson() { final data = {}; if (join != null) { - data['join'] = join.map((k, v) => MapEntry(k, v.toJson())); + data['join'] = join!.map((k, v) => MapEntry(k, v.toJson())); } if (invite != null) { - data['invite'] = invite.map((k, v) => MapEntry(k, v.toJson())); + data['invite'] = invite!.map((k, v) => MapEntry(k, v.toJson())); } if (leave != null) { - data['leave'] = leave.map((k, v) => MapEntry(k, v.toJson())); + data['leave'] = leave!.map((k, v) => MapEntry(k, v.toJson())); } return data; } @@ -154,12 +154,12 @@ class RoomsUpdate { abstract class SyncRoomUpdate {} class JoinedRoomUpdate extends SyncRoomUpdate { - RoomSummary summary; - List state; - TimelineUpdate timeline; - List ephemeral; - List accountData; - UnreadNotificationCounts unreadNotifications; + RoomSummary? summary; + List? state; + TimelineUpdate? timeline; + List? ephemeral; + List? accountData; + UnreadNotificationCounts? unreadNotifications; JoinedRoomUpdate(); @@ -195,35 +195,35 @@ class JoinedRoomUpdate extends SyncRoomUpdate { Map toJson() { final data = {}; if (summary != null) { - data['summary'] = summary.toJson(); + data['summary'] = summary!.toJson(); } if (state != null) { data['state'] = { - 'events': state.map((i) => i.toJson()).toList(), + 'events': state!.map((i) => i.toJson()).toList(), }; } if (timeline != null) { - data['timeline'] = timeline.toJson(); + data['timeline'] = timeline!.toJson(); } if (ephemeral != null) { data['ephemeral'] = { - 'events': ephemeral.map((i) => i.toJson()).toList(), + 'events': ephemeral!.map((i) => i.toJson()).toList(), }; } if (accountData != null) { data['account_data'] = { - 'events': accountData.map((i) => i.toJson()).toList(), + 'events': accountData!.map((i) => i.toJson()).toList(), }; } if (unreadNotifications != null) { - data['unread_notifications'] = unreadNotifications.toJson(); + data['unread_notifications'] = unreadNotifications!.toJson(); } return data; } } class InvitedRoomUpdate extends SyncRoomUpdate { - List inviteState; + List? inviteState; InvitedRoomUpdate.fromJson(Map json) { inviteState = (json['invite_state'] != null && json['invite_state']['events'] != null) @@ -236,7 +236,7 @@ class InvitedRoomUpdate extends SyncRoomUpdate { final data = {}; if (inviteState != null) { data['invite_state'] = { - 'events': inviteState.map((i) => i.toJson()).toList(), + 'events': inviteState!.map((i) => i.toJson()).toList(), }; } return data; @@ -244,9 +244,9 @@ class InvitedRoomUpdate extends SyncRoomUpdate { } class LeftRoomUpdate extends SyncRoomUpdate { - List state; - TimelineUpdate timeline; - List accountData; + List? state; + TimelineUpdate? timeline; + List? accountData; LeftRoomUpdate(); @@ -270,15 +270,15 @@ class LeftRoomUpdate extends SyncRoomUpdate { final data = {}; if (state != null) { data['state'] = { - 'events': state.map((i) => i.toJson()).toList(), + 'events': state!.map((i) => i.toJson()).toList(), }; } if (timeline != null) { - data['timeline'] = timeline.toJson(); + data['timeline'] = timeline!.toJson(); } if (accountData != null) { data['account_data'] = { - 'events': accountData.map((i) => i.toJson()).toList(), + 'events': accountData!.map((i) => i.toJson()).toList(), }; } return data; @@ -286,9 +286,9 @@ class LeftRoomUpdate extends SyncRoomUpdate { } class TimelineUpdate { - List events; - bool limited; - String prevBatch; + List? events; + bool? limited; + String? prevBatch; TimelineUpdate(); @@ -303,7 +303,7 @@ class TimelineUpdate { Map toJson() { final data = {}; if (events != null) { - data['events'] = events.map((i) => i.toJson()).toList(); + data['events'] = events!.map((i) => i.toJson()).toList(); } if (limited != null) { data['limited'] = limited; @@ -316,8 +316,8 @@ class TimelineUpdate { } class UnreadNotificationCounts { - int highlightCount; - int notificationCount; + int? highlightCount; + int? notificationCount; UnreadNotificationCounts.fromJson(Map json) { highlightCount = json['highlight_count']; notificationCount = json['notification_count']; @@ -335,8 +335,8 @@ class UnreadNotificationCounts { } class DeviceListsUpdate { - List changed; - List left; + List? changed; + List? left; DeviceListsUpdate.fromJson(Map json) { changed = List.from(json['changed'] ?? []); left = List.from(json['left'] ?? []); diff --git a/lib/src/model/third_party_location.dart b/lib/src/model/third_party_location.dart index cfcad4d4..fb834daf 100644 --- a/lib/src/model/third_party_location.dart +++ b/lib/src/model/third_party_location.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + /* MIT License * * Copyright (C) 2019, 2020, 2021 Famedly GmbH diff --git a/lib/src/model/third_party_user.dart b/lib/src/model/third_party_user.dart index 65a23dc5..e230e4ab 100644 --- a/lib/src/model/third_party_user.dart +++ b/lib/src/model/third_party_user.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + /* MIT License * * Copyright (C) 2019, 2020, 2021 Famedly GmbH diff --git a/lib/src/model/upload_key_signatures_response.dart b/lib/src/model/upload_key_signatures_response.dart index f5b46015..94f3255f 100644 --- a/lib/src/model/upload_key_signatures_response.dart +++ b/lib/src/model/upload_key_signatures_response.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + /* MIT License * * Copyright (C) 2019, 2020, 2021 Famedly GmbH @@ -25,7 +25,7 @@ import 'matrix_exception.dart'; class UploadKeySignaturesResponse { - Map> failures; + Map>? failures; UploadKeySignaturesResponse.fromJson(Map json) : failures = json['failures'] != null @@ -43,7 +43,7 @@ class UploadKeySignaturesResponse { Map toJson() { final data = {}; if (failures != null) { - data['failures'] = failures.map( + data['failures'] = failures!.map( (k, v) => MapEntry( k, v.map( diff --git a/lib/src/utils/logs.dart b/lib/src/utils/logs.dart index b9179146..105319a3 100644 --- a/lib/src/utils/logs.dart +++ b/lib/src/utils/logs.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + /* MIT License * * Copyright (C) 2019, 2020, 2021 Famedly GmbH @@ -51,7 +51,7 @@ class Logs { } } - void wtf(String title, [Object exception, StackTrace stackTrace]) => + void wtf(String title, [Object? exception, StackTrace? stackTrace]) => addLogEvent( LogEvent( title, @@ -61,7 +61,7 @@ class Logs { ), ); - void e(String title, [Object exception, StackTrace stackTrace]) => + void e(String title, [Object? exception, StackTrace? stackTrace]) => addLogEvent( LogEvent( title, @@ -71,7 +71,7 @@ class Logs { ), ); - void w(String title, [Object exception, StackTrace stackTrace]) => + void w(String title, [Object? exception, StackTrace? stackTrace]) => addLogEvent( LogEvent( title, @@ -81,7 +81,7 @@ class Logs { ), ); - void i(String title, [Object exception, StackTrace stackTrace]) => + void i(String title, [Object? exception, StackTrace? stackTrace]) => addLogEvent( LogEvent( title, @@ -91,7 +91,7 @@ class Logs { ), ); - void d(String title, [Object exception, StackTrace stackTrace]) => + void d(String title, [Object? exception, StackTrace? stackTrace]) => addLogEvent( LogEvent( title, @@ -101,7 +101,7 @@ class Logs { ), ); - void v(String title, [Object exception, StackTrace stackTrace]) => + void v(String title, [Object? exception, StackTrace? stackTrace]) => addLogEvent( LogEvent( title, @@ -115,8 +115,8 @@ class Logs { // ignore: avoid_print class LogEvent { final String title; - final Object exception; - final StackTrace stackTrace; + final Object? exception; + final StackTrace? stackTrace; final Level level; LogEvent( diff --git a/lib/src/utils/map_copy_extension.dart b/lib/src/utils/map_copy_extension.dart index be21bf01..d2b89720 100644 --- a/lib/src/utils/map_copy_extension.dart +++ b/lib/src/utils/map_copy_extension.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + /* MIT License * * Copyright (C) 2019, 2020, 2021 Famedly GmbH diff --git a/lib/src/utils/try_get_map_extension.dart b/lib/src/utils/try_get_map_extension.dart index b9ab614c..0024aa12 100644 --- a/lib/src/utils/try_get_map_extension.dart +++ b/lib/src/utils/try_get_map_extension.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + /* MIT License * * Copyright (C) 2019, 2020, 2021 Famedly GmbH diff --git a/test/event_content_test.dart b/test/event_content_test.dart index 750f7581..d7f79670 100644 --- a/test/event_content_test.dart +++ b/test/event_content_test.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + /* MIT License * * Copyright (C) 2019, 2020, 2021 Famedly GmbH @@ -29,7 +29,7 @@ import 'dart:convert'; void main() { group('Event Content tests', () { test('Room Encryption Content', () { - var json = { + Map? json = { 'content': { 'algorithm': 'm.megolm.v1.aes-sha2', 'rotation_period_ms': 604800000, @@ -44,11 +44,11 @@ void main() { 'unsigned': {'age': 1234} }; json = jsonDecode(jsonEncode(json)); - expect(MatrixEvent.fromJson(json).parsedRoomEncryptionContent.toJson(), + expect(MatrixEvent.fromJson(json!).parsedRoomEncryptionContent.toJson(), json['content']); }); test('Room Encrypted Content', () { - var json = { + Map? json = { 'content': { 'algorithm': 'm.megolm.v1.aes-sha2', 'ciphertext': 'AwgAEnACgAkLmt6qF84IK++J7UDH2Za1YVchHyprqTqsg...', @@ -64,7 +64,7 @@ void main() { 'unsigned': {'age': 1234} }; json = jsonDecode(jsonEncode(json)); - expect(MatrixEvent.fromJson(json).parsedRoomEncryptedContent.toJson(), + expect(MatrixEvent.fromJson(json!).parsedRoomEncryptedContent.toJson(), json['content']); json = { 'content': { @@ -85,11 +85,11 @@ void main() { 'unsigned': {'age': 1234} }; json = jsonDecode(jsonEncode(json)); - expect(MatrixEvent.fromJson(json).parsedRoomEncryptedContent.toJson(), + expect(MatrixEvent.fromJson(json!).parsedRoomEncryptedContent.toJson(), json['content']); }); test('Room Key Content', () { - var json = { + Map? json = { 'content': { 'algorithm': 'm.megolm.v1.aes-sha2', 'room_id': '!Cuyf34gef24t:localhost', @@ -99,11 +99,11 @@ void main() { 'type': 'm.room_key' }; json = jsonDecode(jsonEncode(json)); - expect(BasicEvent.fromJson(json).parsedRoomKeyContent.toJson(), + expect(BasicEvent.fromJson(json!).parsedRoomKeyContent.toJson(), json['content']); }); test('Room Key Request Content', () { - var json = { + Map? json = { 'content': { 'action': 'request_cancellation', 'request_id': '1495474790150.19', @@ -112,7 +112,7 @@ void main() { 'type': 'm.room_key_request' }; json = jsonDecode(jsonEncode(json)); - expect(BasicEvent.fromJson(json).parsedRoomKeyRequestContent.toJson(), + expect(BasicEvent.fromJson(json!).parsedRoomKeyRequestContent.toJson(), json['content']); json = { 'content': { @@ -129,11 +129,11 @@ void main() { 'type': 'm.room_key_request' }; json = jsonDecode(jsonEncode(json)); - expect(BasicEvent.fromJson(json).parsedRoomKeyRequestContent.toJson(), + expect(BasicEvent.fromJson(json!).parsedRoomKeyRequestContent.toJson(), json['content']); }); test('Forwarded Room Key Content', () { - var json = { + Map? json = { 'content': { 'algorithm': 'm.megolm.v1.aes-sha2', 'forwarding_curve25519_key_chain': [ @@ -149,11 +149,11 @@ void main() { 'type': 'm.forwarded_room_key' }; json = jsonDecode(jsonEncode(json)); - expect(BasicEvent.fromJson(json).parsedForwardedRoomKeyContent.toJson(), + expect(BasicEvent.fromJson(json!).parsedForwardedRoomKeyContent.toJson(), json['content']); }); test('OLM Plaintext Payload', () { - var json = { + Map? json = { 'type': '', 'content': { 'msgtype': 'm.text', @@ -165,7 +165,7 @@ void main() { 'keys': {'ed25519': ''} }; json = jsonDecode(jsonEncode(json)); - expect(OlmPlaintextPayload.fromJson(json).toJson(), json); + expect(OlmPlaintextPayload.fromJson(json!).toJson(), json); }); }); } diff --git a/test/map_copy_extension_test.dart b/test/map_copy_extension_test.dart index 442aaa62..f67b60fc 100644 --- a/test/map_copy_extension_test.dart +++ b/test/map_copy_extension_test.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + /* MIT License * * Copyright (C) 2019, 2020, 2021 Famedly GmbH diff --git a/test/matrix_api_test.dart b/test/matrix_api_test.dart index 45eaf147..97b454e4 100644 --- a/test/matrix_api_test.dart +++ b/test/matrix_api_test.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + /* MIT License * * Copyright (C) 2019, 2020, 2021 Famedly GmbH @@ -61,8 +61,8 @@ void main() { 'completed': ['example.type.foo'] }); expect( - exception.authenticationFlows.first.stages.first, 'example.type.foo'); - expect(exception.authenticationParams['example.type.baz'], + exception.authenticationFlows!.first.stages.first, 'example.type.foo'); + expect(exception.authenticationParams!['example.type.baz'], {'example_key': 'foobar'}); expect(exception.session, 'xxxxxxyz'); expect(exception.completedAuthenticationFlows, ['example.type.foo']); @@ -109,12 +109,12 @@ void main() { } catch (exception) { expect(exception is MatrixException, true); expect((exception as MatrixException).errcode, 'M_FORBIDDEN'); - expect((exception as MatrixException).error, MatrixError.M_FORBIDDEN); - expect((exception as MatrixException).errorMessage, 'Blabla'); - expect((exception as MatrixException).requireAdditionalAuthentication, + expect(exception.error, MatrixError.M_FORBIDDEN); + expect(exception.errorMessage, 'Blabla'); + expect(exception.requireAdditionalAuthentication, false); expect( - (exception as MatrixException).toString(), 'M_FORBIDDEN: Blabla'); + exception.toString(), 'M_FORBIDDEN: Blabla'); error = true; } expect(error, true); @@ -124,8 +124,8 @@ void main() { matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); final supportedVersions = await matrixApi.getVersions(); expect(supportedVersions.versions.contains('r0.5.0'), true); - expect(supportedVersions.unstableFeatures['m.lazy_load_members'], true); - expect(FakeMatrixApi.api['GET']['/client/versions']({}), + expect(supportedVersions.unstableFeatures!['m.lazy_load_members'], true); + expect(FakeMatrixApi.api['GET']!['/client/versions']({}), supportedVersions.toJson()); matrixApi.homeserver = null; }); @@ -146,9 +146,9 @@ void main() { }); test('getLoginTypes', () async { matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - final loginTypes = await matrixApi.getLoginFlows(); + final loginTypes = await (matrixApi.getLoginFlows() as FutureOr>); expect(loginTypes.first.type, 'm.login.password'); - expect(FakeMatrixApi.api['GET']['/client/r0/login']({}), + expect(FakeMatrixApi.api['GET']!['/client/r0/login']({}), {'flows': loginTypes.map((x) => x.toJson()).toList()}); matrixApi.homeserver = null; }); @@ -158,7 +158,7 @@ void main() { LoginType.mLoginPassword, identifier: AuthenticationUserIdentifier(user: 'username'), ); - expect(FakeMatrixApi.api['POST']['/client/r0/login']({}), + expect(FakeMatrixApi.api['POST']!['/client/r0/login']({}), loginResponse.toJson()); matrixApi.homeserver = null; }); @@ -178,7 +178,7 @@ void main() { matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); final registerResponse = await matrixApi.register(kind: AccountKind.guest, username: 'test'); - expect(FakeMatrixApi.api['POST']['/client/r0/register?kind=guest']({}), + expect(FakeMatrixApi.api['POST']!['/client/r0/register?kind=guest']({}), registerResponse.toJson()); matrixApi.homeserver = null; }); @@ -194,7 +194,7 @@ void main() { idAccessToken: '1234', ); expect( - FakeMatrixApi.api['POST'] + FakeMatrixApi.api['POST']! ['/client/r0/register/email/requestToken']({}), response.toJson()); matrixApi.homeserver = matrixApi.accessToken = null; @@ -212,7 +212,7 @@ void main() { idAccessToken: '1234', ); expect( - FakeMatrixApi.api['POST'] + FakeMatrixApi.api['POST']! ['/client/r0/register/email/requestToken']({}), response.toJson()); matrixApi.homeserver = matrixApi.accessToken = null; @@ -281,8 +281,8 @@ void main() { test('getThirdPartyIdentifiers', () async { matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); matrixApi.accessToken = '1234'; - final response = await matrixApi.getAccount3PIDs(); - expect(FakeMatrixApi.api['GET']['/client/r0/account/3pid']({}), + final response = await (matrixApi.getAccount3PIDs() as FutureOr>); + expect(FakeMatrixApi.api['GET']!['/client/r0/account/3pid']({}), {'threepids': response.map((t) => t.toJson()).toList()}); matrixApi.homeserver = matrixApi.accessToken = null; }); @@ -364,7 +364,7 @@ void main() { matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); matrixApi.accessToken = '1234'; final response = await matrixApi.getCapabilities(); - expect(FakeMatrixApi.api['GET']['/client/r0/capabilities']({}), + expect(FakeMatrixApi.api['GET']!['/client/r0/capabilities']({}), {'capabilities': response.toJson()}); matrixApi.homeserver = matrixApi.accessToken = null; }); @@ -498,9 +498,9 @@ void main() { timeout: 15, ); expect( - FakeMatrixApi.api['GET'][ + FakeMatrixApi.api['GET']![ '/client/r0/sync?filter=%7B%7D&since=1234&full_state=false&set_presence=unavailable&timeout=15']( - {}) as Map, + {}) as Map?, response.toJson()); matrixApi.homeserver = matrixApi.accessToken = null; }); @@ -537,12 +537,12 @@ void main() { matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); matrixApi.accessToken = '1234'; - final states = await matrixApi.getMembersByRoom( + final states = await (matrixApi.getMembersByRoom( '!localpart:server.abc', at: '1234', membership: Membership.join, notMembership: Membership.leave, - ); + ) as FutureOr>); expect(states.length, 1); matrixApi.homeserver = matrixApi.accessToken = null; @@ -551,11 +551,11 @@ void main() { matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); matrixApi.accessToken = '1234'; - final states = await matrixApi.getJoinedMembersByRoom( + final states = await (matrixApi.getJoinedMembersByRoom( '!localpart:server.abc', - ); + ) as FutureOr>); expect(states.length, 1); - expect(states['@bar:example.com'].toJson(), { + expect(states['@bar:example.com']!.toJson(), { 'display_name': 'Bar', 'avatar_url': 'mxc://riot.ovh/printErCATzZijQsSDWorRaK' }); @@ -576,9 +576,9 @@ void main() { ); expect( - FakeMatrixApi.api['GET'][ + FakeMatrixApi.api['GET']![ '/client/r0/rooms/!localpart%3Aserver.abc/messages?from=1234&to=1234&dir=b&limit=10&filter=%7B%22lazy_load_members%22%3Atrue%7D']( - {}) as Map, + {}) as Map?, timelineHistoryResponse.toJson()); matrixApi.homeserver = matrixApi.accessToken = null; @@ -667,7 +667,7 @@ void main() { ); expect( - FakeMatrixApi.api['GET'] + FakeMatrixApi.api['GET']! ['/client/r0/directory/room/%23testalias%3Aexample.com']({}), roomAliasInformation.toJson()); @@ -829,7 +829,7 @@ void main() { ); expect( - FakeMatrixApi.api['GET'][ + FakeMatrixApi.api['GET']![ '/client/r0/publicRooms?limit=10&since=1234&server=example.com']({}), response.toJson()); @@ -851,7 +851,7 @@ void main() { ); expect( - FakeMatrixApi.api['POST'] + FakeMatrixApi.api['POST']! ['/client/r0/publicRooms?server=example.com']({}), response.toJson()); @@ -866,7 +866,7 @@ void main() { limit: 10, ); - expect(FakeMatrixApi.api['POST']['/client/r0/user_directory/search']({}), + expect(FakeMatrixApi.api['POST']!['/client/r0/user_directory/search']({}), response.toJson()); matrixApi.homeserver = matrixApi.accessToken = null; @@ -913,7 +913,7 @@ void main() { final response = await matrixApi.getUserProfile('@alice:example.com'); expect( - FakeMatrixApi.api['GET'] + FakeMatrixApi.api['GET']! ['/client/r0/profile/%40alice%3Aexample.com']({}), response.toJson()); @@ -924,7 +924,7 @@ void main() { matrixApi.accessToken = '1234'; final response = await matrixApi.getTurnServer(); - expect(FakeMatrixApi.api['GET']['/client/r0/voip/turnServer']({}), + expect(FakeMatrixApi.api['GET']!['/client/r0/voip/turnServer']({}), response.toJson()); matrixApi.homeserver = matrixApi.accessToken = null; @@ -987,7 +987,7 @@ void main() { '@alice:example.com', ); expect( - FakeMatrixApi.api['GET'][ + FakeMatrixApi.api['GET']![ '/client/r0/presence/${Uri.encodeComponent('@alice:example.com')}/status']({}), response.toJson()); @@ -1017,7 +1017,7 @@ void main() { ts: 10, ); expect( - FakeMatrixApi.api['GET'] + FakeMatrixApi.api['GET']! ['/media/r0/preview_url?url=https%3A%2F%2Fmatrix.org&ts=10']({}), openGraphData.toJson()); @@ -1048,8 +1048,8 @@ void main() { matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); matrixApi.accessToken = '1234'; - final devices = await matrixApi.getDevices(); - expect(FakeMatrixApi.api['GET']['/client/r0/devices']({})['devices'], + final devices = await (matrixApi.getDevices() as FutureOr>); + expect(FakeMatrixApi.api['GET']!['/client/r0/devices']({})['devices'], devices.map((i) => i.toJson()).toList()); matrixApi.homeserver = matrixApi.accessToken = null; @@ -1118,10 +1118,10 @@ void main() { ); expect( response - .deviceKeys['@alice:example.com']['JLAFKJWSCS'].deviceDisplayName, + .deviceKeys!['@alice:example.com']!['JLAFKJWSCS']!.deviceDisplayName, 'Alices mobile phone'); expect( - FakeMatrixApi.api['POST'] + FakeMatrixApi.api['POST']! ['/client/r0/keys/query']({'device_keys': {}}), response.toJson()); @@ -1138,7 +1138,7 @@ void main() { timeout: 10, ); expect( - FakeMatrixApi.api['POST']['/client/r0/keys/claim']({ + FakeMatrixApi.api['POST']!['/client/r0/keys/claim']({ 'one_time_keys': { '@alice:example.com': {'JLAFKJWSCS': 'signed_curve25519'} } @@ -1234,7 +1234,7 @@ void main() { }); final ret = await matrixApi.uploadKeySignatures([key1, key2]); expect( - FakeMatrixApi.api['POST']['/client/r0/keys/signatures/upload']({}), + FakeMatrixApi.api['POST']!['/client/r0/keys/signatures/upload']({}), ret.toJson(), ); }); @@ -1242,9 +1242,9 @@ void main() { matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); matrixApi.accessToken = '1234'; - final response = await matrixApi.getPushers(); + final response = await (matrixApi.getPushers() as FutureOr>); expect( - FakeMatrixApi.api['GET']['/client/r0/pushers']({}), + FakeMatrixApi.api['GET']!['/client/r0/pushers']({}), {'pushers': response.map((i) => i.toJson()).toList()}, ); @@ -1281,7 +1281,7 @@ void main() { only: '1234', ); expect( - FakeMatrixApi.api['GET'] + FakeMatrixApi.api['GET']! ['/client/r0/notifications?from=1234&limit=10&only=1234']({}), response.toJson(), ); @@ -1294,7 +1294,7 @@ void main() { final response = await matrixApi.getPushRules(); expect( - FakeMatrixApi.api['GET']['/client/r0/pushrules']({}), + FakeMatrixApi.api['GET']!['/client/r0/pushrules']({}), {'global': response.toJson()}, ); @@ -1307,7 +1307,7 @@ void main() { final response = await matrixApi.getPushRule('global', PushRuleKind.content, 'nocake'); expect( - FakeMatrixApi.api['GET'] + FakeMatrixApi.api['GET']! ['/client/r0/pushrules/global/content/nocake']({}), response.toJson(), ); @@ -1407,7 +1407,7 @@ void main() { final response = await matrixApi.getEvents(from: '1234', roomId: '!1234', timeout: 10); expect( - FakeMatrixApi.api['GET'] + FakeMatrixApi.api['GET']! ['/client/r0/events?from=1234&timeout=10&roomId=%211234']({}), response.toJson(), ); @@ -1418,10 +1418,10 @@ void main() { matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); matrixApi.accessToken = '1234'; - final response = await matrixApi.getRoomTags( - '@alice:example.com', '!localpart:example.com'); + final response = await (matrixApi.getRoomTags( + '@alice:example.com', '!localpart:example.com') as FutureOr>); expect( - FakeMatrixApi.api['GET'][ + FakeMatrixApi.api['GET']![ '/client/r0/user/%40alice%3Aexample.com/rooms/!localpart%3Aexample.com/tags']({}), {'tags': response.map((k, v) => MapEntry(k, v.toJson()))}, ); @@ -1507,7 +1507,7 @@ void main() { final response = await matrixApi.getWhoIs('@alice:example.com'); expect( - FakeMatrixApi.api['GET'] + FakeMatrixApi.api['GET']! ['/client/r0/admin/whois/%40alice%3Aexample.com']({}), response.toJson(), ); @@ -1521,7 +1521,7 @@ void main() { final response = await matrixApi.getEventContext('1234', '1234', limit: 10, filter: '{}'); expect( - FakeMatrixApi.api['GET'] + FakeMatrixApi.api['GET']! ['/client/r0/rooms/1234/context/1234?limit=10&filter=%7B%7D']({}), response.toJson(), ); @@ -1547,7 +1547,7 @@ void main() { final response = await matrixApi.requestSupportedProtocols(); expect( - FakeMatrixApi.api['GET']['/client/r0/thirdparty/protocols']({}), + FakeMatrixApi.api['GET']!['/client/r0/thirdparty/protocols']({}), response.map((k, v) => MapEntry(k, v.toJson())), ); @@ -1559,7 +1559,7 @@ void main() { final response = await matrixApi.requestSupportedProtocol('irc'); expect( - FakeMatrixApi.api['GET']['/client/r0/thirdparty/protocol/irc']({}), + FakeMatrixApi.api['GET']!['/client/r0/thirdparty/protocol/irc']({}), response.toJson(), ); @@ -1571,7 +1571,7 @@ void main() { final response = await matrixApi.requestThirdPartyLocations('irc'); expect( - FakeMatrixApi.api['GET']['/client/r0/thirdparty/location/irc']({}), + FakeMatrixApi.api['GET']!['/client/r0/thirdparty/location/irc']({}), response.map((i) => i.toJson()).toList(), ); @@ -1583,7 +1583,7 @@ void main() { final response = await matrixApi.requestThirdPartyUsers('irc'); expect( - FakeMatrixApi.api['GET']['/client/r0/thirdparty/user/irc']({}), + FakeMatrixApi.api['GET']!['/client/r0/thirdparty/user/irc']({}), response.map((i) => i.toJson()).toList(), ); @@ -1596,7 +1596,7 @@ void main() { final response = await matrixApi.requestThirdPartyLocationsByAlias('1234'); expect( - FakeMatrixApi.api['GET'] + FakeMatrixApi.api['GET']! ['/client/r0/thirdparty/location?alias=1234']({}), response.map((i) => i.toJson()).toList(), ); @@ -1609,7 +1609,7 @@ void main() { final response = await matrixApi.requestThirdPartyUsersByUserId('1234'); expect( - FakeMatrixApi.api['GET']['/client/r0/thirdparty/user?userid=1234']({}), + FakeMatrixApi.api['GET']!['/client/r0/thirdparty/user?userid=1234']({}), response.map((i) => i.toJson()).toList(), ); @@ -1621,7 +1621,7 @@ void main() { final response = await matrixApi.requestOpenIdToken('1234', {}); expect( - FakeMatrixApi.api['POST'] + FakeMatrixApi.api['POST']! ['/client/r0/user/1234/openid/request_token']({}), response.toJson(), ); @@ -1647,7 +1647,7 @@ void main() { }; final ret = await matrixApi.postRoomKeysVersion(algorithm, authData); expect( - FakeMatrixApi.api['POST'] + FakeMatrixApi.api['POST']! ['/client/unstable/room_keys/version']({})['version'], ret); }); @@ -1656,7 +1656,7 @@ void main() { matrixApi.accessToken = '1234'; final ret = await matrixApi.getRoomKeysVersionCurrent(); - expect(FakeMatrixApi.api['GET']['/client/unstable/room_keys/version']({}), + expect(FakeMatrixApi.api['GET']!['/client/unstable/room_keys/version']({}), ret.toJson()); }); test('putRoomKeysVersion', () async { @@ -1696,7 +1696,7 @@ void main() { final ret = await matrixApi.postRoomKeysKeyRoomIdSessionId( roomId, sessionId, '5', session); expect( - FakeMatrixApi.api['PUT'][ + FakeMatrixApi.api['PUT']![ '/client/unstable/room_keys/keys/${Uri.encodeComponent('!726s6s6q:example.com')}/${Uri.encodeComponent('ciM/JWTPrmiWPPZNkRLDPQYf9AW/I46bxyLSr+Bx5oU')}?version=5']({}), ret.toJson()); }); @@ -1708,7 +1708,7 @@ void main() { final sessionId = 'ciM/JWTPrmiWPPZNkRLDPQYf9AW/I46bxyLSr+Bx5oU'; final ret = await matrixApi.getRoomKeysSingleKey(roomId, sessionId, '5'); expect( - FakeMatrixApi.api['GET'][ + FakeMatrixApi.api['GET']![ '/client/unstable/room_keys/keys/${Uri.encodeComponent('!726s6s6q:example.com')}/${Uri.encodeComponent('ciM/JWTPrmiWPPZNkRLDPQYf9AW/I46bxyLSr+Bx5oU')}?version=5']({}), ret.toJson()); }); @@ -1721,7 +1721,7 @@ void main() { final ret = await matrixApi.deleteRoomKeysSingleKey(roomId, sessionId, '5'); expect( - FakeMatrixApi.api['DELETE'][ + FakeMatrixApi.api['DELETE']![ '/client/unstable/room_keys/keys/${Uri.encodeComponent('!726s6s6q:example.com')}/${Uri.encodeComponent('ciM/JWTPrmiWPPZNkRLDPQYf9AW/I46bxyLSr+Bx5oU')}?version=5']({}), ret.toJson()); }); @@ -1748,7 +1748,7 @@ void main() { }); final ret = await matrixApi.postRoomKeysKeyRoomId(roomId, '5', session); expect( - FakeMatrixApi.api['PUT'][ + FakeMatrixApi.api['PUT']![ '/client/unstable/room_keys/keys/${Uri.encodeComponent('!726s6s6q:example.com')}?version=5']({}), ret.toJson()); }); @@ -1759,7 +1759,7 @@ void main() { final roomId = '!726s6s6q:example.com'; final ret = await matrixApi.getRoomKeysRoom(roomId, '5'); expect( - FakeMatrixApi.api['GET'][ + FakeMatrixApi.api['GET']![ '/client/unstable/room_keys/keys/${Uri.encodeComponent('!726s6s6q:example.com')}?version=5']({}), ret.toJson()); }); @@ -1770,7 +1770,7 @@ void main() { final roomId = '!726s6s6q:example.com'; final ret = await matrixApi.deleteRoomKeysRoom(roomId, '5'); expect( - FakeMatrixApi.api['DELETE'][ + FakeMatrixApi.api['DELETE']![ '/client/unstable/room_keys/keys/${Uri.encodeComponent('!726s6s6q:example.com')}?version=5']({}), ret.toJson()); }); @@ -1801,7 +1801,7 @@ void main() { }); final ret = await matrixApi.postRoomKeysKey('5', session); expect( - FakeMatrixApi.api['PUT'] + FakeMatrixApi.api['PUT']! ['/client/unstable/room_keys/keys?version=5']({}), ret.toJson()); }); @@ -1811,7 +1811,7 @@ void main() { final ret = await matrixApi.getRoomKeys('5'); expect( - FakeMatrixApi.api['GET'] + FakeMatrixApi.api['GET']! ['/client/unstable/room_keys/keys?version=5']({}), ret.toJson()); }); @@ -1821,7 +1821,7 @@ void main() { final ret = await matrixApi.deleteRoomKeys('5'); expect( - FakeMatrixApi.api['DELETE'] + FakeMatrixApi.api['DELETE']! ['/client/unstable/room_keys/keys?version=5']({}), ret.toJson()); }); diff --git a/test/try_get_map_extension_test.dart b/test/try_get_map_extension_test.dart index dca18807..43317512 100644 --- a/test/try_get_map_extension_test.dart +++ b/test/try_get_map_extension_test.dart @@ -1,4 +1,4 @@ -// @dart=2.9 + /* MIT License * * Copyright (C) 2019, 2020, 2021 Famedly GmbH