diff --git a/lib/utils/account_bundles.dart b/lib/utils/account_bundles.dart index eb9d96f4..fbced64d 100644 --- a/lib/utils/account_bundles.dart +++ b/lib/utils/account_bundles.dart @@ -1,8 +1,10 @@ +//@dart=2.12 + import 'package:matrix/matrix.dart'; class AccountBundles { - String prefix; - List bundles; + String? prefix; + List? bundles; AccountBundles({this.prefix, this.bundles}); @@ -23,13 +25,14 @@ class AccountBundles { Map toJson() => { if (prefix != null) 'prefix': prefix, - if (bundles != null) 'bundles': bundles.map((v) => v.toJson()).toList(), + if (bundles != null) + 'bundles': bundles!.map((v) => v.toJson()).toList(), }; } class AccountBundle { - String name; - int priority; + String? name; + int? priority; AccountBundle({this.name, this.priority}); @@ -47,9 +50,9 @@ const accountBundlesType = 'im.fluffychat.account_bundles'; extension AccountBundlesExtension on Client { List get accountBundles { - List ret; + List? ret; if (accountData.containsKey(accountBundlesType)) { - ret = AccountBundles.fromJson(accountData[accountBundlesType].content) + ret = AccountBundles.fromJson(accountData[accountBundlesType]!.content) .bundles; } ret ??= []; @@ -62,12 +65,12 @@ extension AccountBundlesExtension on Client { return ret; } - Future setAccountBundle(String name, [int priority]) async { + Future setAccountBundle(String name, [int? priority]) async { final data = AccountBundles.fromJson(accountData[accountBundlesType]?.content ?? {}); var foundBundle = false; - data.bundles ??= []; - for (final bundle in data.bundles) { + final bundles = data.bundles ??= []; + for (final bundle in bundles) { if (bundle.name == name) { bundle.priority = priority; foundBundle = true; @@ -75,9 +78,9 @@ extension AccountBundlesExtension on Client { } } if (!foundBundle) { - data.bundles.add(AccountBundle(name: name, priority: priority)); + bundles.add(AccountBundle(name: name, priority: priority)); } - await setAccountData(userID, accountBundlesType, data.toJson()); + await setAccountData(userID!, accountBundlesType, data.toJson()); } Future removeFromAccountBundle(String name) async { @@ -85,15 +88,15 @@ extension AccountBundlesExtension on Client { return; // nothing to do } final data = - AccountBundles.fromJson(accountData[accountBundlesType].content); + AccountBundles.fromJson(accountData[accountBundlesType]!.content); if (data.bundles == null) return; - data.bundles.removeWhere((b) => b.name == name); - await setAccountData(userID, accountBundlesType, data.toJson()); + data.bundles!.removeWhere((b) => b.name == name); + await setAccountData(userID!, accountBundlesType, data.toJson()); } String get sendPrefix { final data = AccountBundles.fromJson(accountData[accountBundlesType]?.content ?? {}); - return data.prefix; + return data.prefix!; } } diff --git a/lib/utils/beautify_string_extension.dart b/lib/utils/beautify_string_extension.dart index b555d6de..7811460a 100644 --- a/lib/utils/beautify_string_extension.dart +++ b/lib/utils/beautify_string_extension.dart @@ -1,3 +1,5 @@ +//@dart=2.12 + extension BeautifyStringExtension on String { String get beautified { var beautifiedStr = ''; diff --git a/lib/utils/custom_scroll_behaviour.dart b/lib/utils/custom_scroll_behaviour.dart index 84721115..f61f4285 100644 --- a/lib/utils/custom_scroll_behaviour.dart +++ b/lib/utils/custom_scroll_behaviour.dart @@ -1,3 +1,5 @@ +//@dart=2.12 + import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; diff --git a/lib/utils/date_time_extension.dart b/lib/utils/date_time_extension.dart index 8a537c4b..54c89d9a 100644 --- a/lib/utils/date_time_extension.dart +++ b/lib/utils/date_time_extension.dart @@ -1,3 +1,5 @@ +//@dart=2.12 + import 'package:flutter/material.dart'; import 'package:flutter_gen/gen_l10n/l10n.dart'; @@ -61,25 +63,25 @@ extension DateTimeExtension on DateTime { } else if (sameWeek) { switch (weekday) { case 1: - return L10n.of(context).monday; + return L10n.of(context)!.monday; case 2: - return L10n.of(context).tuesday; + return L10n.of(context)!.tuesday; case 3: - return L10n.of(context).wednesday; + return L10n.of(context)!.wednesday; case 4: - return L10n.of(context).thursday; + return L10n.of(context)!.thursday; case 5: - return L10n.of(context).friday; + return L10n.of(context)!.friday; case 6: - return L10n.of(context).saturday; + return L10n.of(context)!.saturday; case 7: - return L10n.of(context).sunday; + return L10n.of(context)!.sunday; } } else if (sameYear) { - return L10n.of(context).dateWithoutYear( + return L10n.of(context)!.dateWithoutYear( month.toString().padLeft(2, '0'), day.toString().padLeft(2, '0')); } - return L10n.of(context).dateWithYear(year.toString(), + return L10n.of(context)!.dateWithYear(year.toString(), month.toString().padLeft(2, '0'), day.toString().padLeft(2, '0')); } @@ -94,7 +96,7 @@ extension DateTimeExtension on DateTime { final sameDay = sameYear && now.month == month && now.day == day; if (sameDay) return localizedTimeOfDay(context); - return L10n.of(context).dateAndTimeOfDay( + return L10n.of(context)!.dateAndTimeOfDay( localizedTimeShort(context), localizedTimeOfDay(context)); } diff --git a/lib/utils/fluffy_share.dart b/lib/utils/fluffy_share.dart index 8f8cda73..2d3f909b 100644 --- a/lib/utils/fluffy_share.dart +++ b/lib/utils/fluffy_share.dart @@ -1,3 +1,5 @@ +//@dart=2.12 + import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; @@ -15,7 +17,7 @@ abstract class FluffyShare { ClipboardData(text: text), ); ScaffoldMessenger.of(context).showSnackBar( - SnackBar(content: Text(L10n.of(context).copiedToClipboard))); + SnackBar(content: Text(L10n.of(context)!.copiedToClipboard))); return; } } diff --git a/lib/utils/get_client_secret.dart b/lib/utils/get_client_secret.dart index d86cd388..b141350c 100644 --- a/lib/utils/get_client_secret.dart +++ b/lib/utils/get_client_secret.dart @@ -1,3 +1,5 @@ +//@dart=2.12 + import 'dart:math'; const _chars = 'AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz1234567890'; diff --git a/lib/utils/localized_exception_extension.dart b/lib/utils/localized_exception_extension.dart index 52d194ca..7191bbdf 100644 --- a/lib/utils/localized_exception_extension.dart +++ b/lib/utils/localized_exception_extension.dart @@ -1,3 +1,5 @@ +//@dart=2.12 + import 'dart:io'; import 'package:flutter/material.dart'; @@ -12,9 +14,9 @@ extension LocalizedExceptionExtension on Object { if (this is MatrixException) { switch ((this as MatrixException).error) { case MatrixError.M_FORBIDDEN: - return L10n.of(context).noPermission; + return L10n.of(context)!.noPermission; case MatrixError.M_LIMIT_EXCEEDED: - return L10n.of(context).tooManyRequestsWarning; + return L10n.of(context)!.tooManyRequestsWarning; default: return (this as MatrixException).errorMessage; } @@ -30,7 +32,7 @@ extension LocalizedExceptionExtension on Object { .toString() .replaceAll('{', '"') .replaceAll('}', '"'); - return L10n.of(context) + return L10n.of(context)! .badServerVersionsException(serverVersions, supportedVersions); } if (this is BadServerLoginTypesException) { @@ -44,15 +46,15 @@ extension LocalizedExceptionExtension on Object { .toString() .replaceAll('{', '"') .replaceAll('}', '"'); - return L10n.of(context) + return L10n.of(context)! .badServerLoginTypesException(serverVersions, supportedVersions); } if (this is MatrixConnectionException || this is SocketException) { - return L10n.of(context).noConnectionToTheServer; + return L10n.of(context)!.noConnectionToTheServer; } if (this is String) return toString(); if (this is UiaException) return toString(); Logs().w('Something went wrong: ', this); - return L10n.of(context).oopsSomethingWentWrong; + return L10n.of(context)!.oopsSomethingWentWrong; } } diff --git a/lib/utils/matrix_sdk_extensions.dart/client_presence_extension.dart b/lib/utils/matrix_sdk_extensions.dart/client_presence_extension.dart index fcabae5e..d7274df8 100644 --- a/lib/utils/matrix_sdk_extensions.dart/client_presence_extension.dart +++ b/lib/utils/matrix_sdk_extensions.dart/client_presence_extension.dart @@ -1,3 +1,5 @@ +//@dart=2.12 + import 'package:matrix/matrix.dart'; extension ClientPresenceExtension on Client { diff --git a/lib/utils/matrix_sdk_extensions.dart/device_extension.dart b/lib/utils/matrix_sdk_extensions.dart/device_extension.dart index 15c0c369..0eea82f0 100644 --- a/lib/utils/matrix_sdk_extensions.dart/device_extension.dart +++ b/lib/utils/matrix_sdk_extensions.dart/device_extension.dart @@ -1,3 +1,5 @@ +//@dart=2.12 + import 'package:flutter/material.dart'; import 'package:matrix/matrix.dart'; @@ -31,14 +33,14 @@ IconData _getIconFromName(String displayname) { extension DeviceExtension on Device { String get displayname => - (displayName?.isNotEmpty ?? false) ? displayName : 'Unknown device'; + (displayName?.isNotEmpty ?? false) ? displayName! : 'Unknown device'; IconData get icon => _getIconFromName(displayname); } extension DeviceKeysExtension on DeviceKeys { String get displayname => (deviceDisplayName?.isNotEmpty ?? false) - ? deviceDisplayName + ? deviceDisplayName! : 'Unknown device'; IconData get icon => _getIconFromName(displayname); diff --git a/lib/utils/matrix_sdk_extensions.dart/event_extension.dart b/lib/utils/matrix_sdk_extensions.dart/event_extension.dart index 4b3571d4..520dc403 100644 --- a/lib/utils/matrix_sdk_extensions.dart/event_extension.dart +++ b/lib/utils/matrix_sdk_extensions.dart/event_extension.dart @@ -1,3 +1,5 @@ +//@dart=2.12 + import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; @@ -19,10 +21,10 @@ extension LocalizedBody on Event { bool get isAttachmentSmallEnough => infoMap['size'] is int && - infoMap['size'] < room.client.database.maxFileSize; + infoMap['size'] < room.client.database!.maxFileSize; bool get isThumbnailSmallEnough => thumbnailInfoMap['size'] is int && - thumbnailInfoMap['size'] < room.client.database.maxFileSize; + thumbnailInfoMap['size'] < room.client.database!.maxFileSize; bool get showThumbnail => [MessageTypes.Image, MessageTypes.Sticker, MessageTypes.Video] @@ -32,7 +34,7 @@ extension LocalizedBody on Event { isThumbnailSmallEnough || (content['url'] is String)); - String get sizeString { + String? get sizeString { if (content['info'] is Map && content['info'].containsKey('size')) { num size = content['info']['size']; @@ -58,6 +60,7 @@ extension LocalizedBody on Event { Future isAttachmentCached({bool getThumbnail = false}) async { final mxcUrl = attachmentOrThumbnailMxcUrl(getThumbnail: getThumbnail); + if (mxcUrl == null) return false; // check if we have it in-memory if (_downloadAndDecryptFutures.containsKey(mxcUrl)) { return true; @@ -72,7 +75,7 @@ extension LocalizedBody on Event { return file != null; } - Future downloadAndDecryptAttachmentCached( + Future downloadAndDecryptAttachmentCached( {bool getThumbnail = false}) async { final mxcUrl = attachmentOrThumbnailMxcUrl(getThumbnail: getThumbnail).toString(); diff --git a/lib/utils/matrix_sdk_extensions.dart/filtered_timeline_extension.dart b/lib/utils/matrix_sdk_extensions.dart/filtered_timeline_extension.dart index 497a0e10..4dda918e 100644 --- a/lib/utils/matrix_sdk_extensions.dart/filtered_timeline_extension.dart +++ b/lib/utils/matrix_sdk_extensions.dart/filtered_timeline_extension.dart @@ -1,3 +1,5 @@ +//@dart=2.12 + import 'package:matrix/matrix.dart'; import '../../config/app_config.dart'; @@ -30,13 +32,14 @@ extension FilteredTimelineExtension on Timeline { filteredEvents[i - 1].isState && !unfolded.contains(filteredEvents[i - 1].eventId)) { counter++; - filteredEvents[i].unsigned['im.fluffychat.collapsed_state_event'] = + filteredEvents[i].unsigned ??= {}; + filteredEvents[i].unsigned!['im.fluffychat.collapsed_state_event'] = true; } else { - filteredEvents[i].unsigned['im.fluffychat.collapsed_state_event'] = + filteredEvents[i].unsigned!['im.fluffychat.collapsed_state_event'] = false; filteredEvents[i] - .unsigned['im.fluffychat.collapsed_state_event_count'] = counter; + .unsigned!['im.fluffychat.collapsed_state_event_count'] = counter; counter = 0; } } diff --git a/lib/utils/matrix_sdk_extensions.dart/matrix_file_extension.dart b/lib/utils/matrix_sdk_extensions.dart/matrix_file_extension.dart index b84a4744..303d9feb 100644 --- a/lib/utils/matrix_sdk_extensions.dart/matrix_file_extension.dart +++ b/lib/utils/matrix_sdk_extensions.dart/matrix_file_extension.dart @@ -1,3 +1,5 @@ +//@dart=2.12 + import 'dart:io'; import 'package:flutter/material.dart'; @@ -16,14 +18,14 @@ extension MatrixFileExtension on MatrixFile { if (PlatformInfos.isMobile) { final tmpDirectory = PlatformInfos.isAndroid ? (await getExternalStorageDirectories( - type: StorageDirectory.downloads)) + type: StorageDirectory.downloads))! .first : await getTemporaryDirectory(); final path = '${tmpDirectory.path}$fileName'; await File(path).writeAsBytes(bytes); await Share.shareFiles([path]); ScaffoldMessenger.of(context).showSnackBar( - SnackBar(content: Text(L10n.of(context).savedFileAs(path))), + SnackBar(content: Text(L10n.of(context)!.savedFileAs(path))), ); return; } else { diff --git a/lib/utils/matrix_sdk_extensions.dart/matrix_locals.dart b/lib/utils/matrix_sdk_extensions.dart/matrix_locals.dart index a755f124..b5908876 100644 --- a/lib/utils/matrix_sdk_extensions.dart/matrix_locals.dart +++ b/lib/utils/matrix_sdk_extensions.dart/matrix_locals.dart @@ -1,3 +1,5 @@ +//@dart=2.12 + import 'package:flutter_gen/gen_l10n/l10n.dart'; import 'package:matrix/matrix.dart'; diff --git a/lib/utils/matrix_sdk_extensions.dart/presence_extension.dart b/lib/utils/matrix_sdk_extensions.dart/presence_extension.dart index bf69fae0..5d5b195d 100644 --- a/lib/utils/matrix_sdk_extensions.dart/presence_extension.dart +++ b/lib/utils/matrix_sdk_extensions.dart/presence_extension.dart @@ -1,3 +1,5 @@ +//@dart=2.12 + import 'package:flutter/material.dart'; import 'package:flutter_gen/gen_l10n/l10n.dart'; @@ -8,25 +10,27 @@ import '../date_time_extension.dart'; extension PresenceExtension on Presence { String getLocalizedLastActiveAgo(BuildContext context) { if (presence.lastActiveAgo != null && presence.lastActiveAgo != 0) { - return L10n.of(context).lastActiveAgo(DateTime.fromMillisecondsSinceEpoch( - DateTime.now().millisecondsSinceEpoch - presence.lastActiveAgo) - .localizedTimeShort(context)); + return L10n.of(context)!.lastActiveAgo( + DateTime.fromMillisecondsSinceEpoch( + DateTime.now().millisecondsSinceEpoch - + presence.lastActiveAgo!) + .localizedTimeShort(context)); } - return L10n.of(context).lastSeenLongTimeAgo; + return L10n.of(context)!.lastSeenLongTimeAgo; } String getLocalizedStatusMessage(BuildContext context) { if (presence.statusMsg?.isNotEmpty ?? false) { - return presence.statusMsg; + return presence.statusMsg!; } if (presence.currentlyActive ?? false) { - return L10n.of(context).currentlyActive; + return L10n.of(context)!.currentlyActive; } return getLocalizedLastActiveAgo(context); } Color get color { - switch (presence?.presence ?? PresenceType.offline) { + switch (presence.presence) { case PresenceType.online: return Colors.green; case PresenceType.offline: diff --git a/lib/utils/platform_infos.dart b/lib/utils/platform_infos.dart index 9eec8ed1..0359899a 100644 --- a/lib/utils/platform_infos.dart +++ b/lib/utils/platform_infos.dart @@ -1,3 +1,5 @@ +//@dart=2.12 + import 'dart:io'; import 'package:flutter/foundation.dart'; @@ -50,7 +52,7 @@ abstract class PlatformInfos { Text('Version: $version'), OutlinedButton( onPressed: () => launch(AppConfig.sourceCodeUrl), - child: Text(L10n.of(context).sourceCode), + child: Text(L10n.of(context)!.sourceCode), ), OutlinedButton( onPressed: () => launch(AppConfig.emojiFontUrl), @@ -60,7 +62,7 @@ abstract class PlatformInfos { onPressed: () => VRouter.of(context).to('logs'), child: const Text('Logs'), ), - SentrySwitchListTile.adaptive(label: L10n.of(context).sendBugReports), + SentrySwitchListTile.adaptive(label: L10n.of(context)!.sendBugReports), ], applicationIcon: Image.asset('assets/logo.png', width: 64, height: 64), applicationName: AppConfig.applicationName, diff --git a/lib/utils/room_send_file_extension.dart b/lib/utils/room_send_file_extension.dart index 22f225e2..9ff94c8c 100644 --- a/lib/utils/room_send_file_extension.dart +++ b/lib/utils/room_send_file_extension.dart @@ -1,20 +1,4 @@ -/* - * Famedly App - * Copyright (C) 2020 Famedly GmbH - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ +//@dart=2.12 import 'package:matrix/matrix.dart'; @@ -23,12 +7,12 @@ import 'resize_image.dart'; extension RoomSendFileExtension on Room { Future sendFileEventWithThumbnail( MatrixFile file, { - String txid, - Event inReplyTo, - String editEventId, - bool waitUntilSent, + String? txid, + Event? inReplyTo, + String? editEventId, + bool? waitUntilSent, }) async { - MatrixFile thumbnail; + MatrixImageFile? thumbnail; if (file is MatrixImageFile) { thumbnail = await file.resizeImage(); diff --git a/lib/utils/room_status_extension.dart b/lib/utils/room_status_extension.dart index 039e0beb..59cd9a30 100644 --- a/lib/utils/room_status_extension.dart +++ b/lib/utils/room_status_extension.dart @@ -1,3 +1,5 @@ +//@dart=2.12 + import 'package:flutter/widgets.dart'; import 'package:flutter_gen/gen_l10n/l10n.dart'; @@ -8,31 +10,32 @@ import 'date_time_extension.dart'; import 'matrix_sdk_extensions.dart/filtered_timeline_extension.dart'; extension RoomStatusExtension on Room { - Presence get directChatPresence => client.presences[directChatMatrixID]; + Presence? get directChatPresence => client.presences[directChatMatrixID]; String getLocalizedStatus(BuildContext context) { if (isDirectChat) { + final directChatPresence = this.directChatPresence; if (directChatPresence != null && - directChatPresence.presence != null && (directChatPresence.presence.lastActiveAgo != null || directChatPresence.presence.currentlyActive != null)) { if (directChatPresence.presence.statusMsg?.isNotEmpty ?? false) { - return directChatPresence.presence.statusMsg; + return directChatPresence.presence.statusMsg!; } if (directChatPresence.presence.currentlyActive == true) { - return L10n.of(context).currentlyActive; + return L10n.of(context)!.currentlyActive; } if (directChatPresence.presence.lastActiveAgo == null) { - return L10n.of(context).lastSeenLongTimeAgo; + return L10n.of(context)!.lastSeenLongTimeAgo; } final time = DateTime.fromMillisecondsSinceEpoch( DateTime.now().millisecondsSinceEpoch - - directChatPresence.presence.lastActiveAgo); - return L10n.of(context).lastActiveAgo(time.localizedTimeShort(context)); + directChatPresence.presence.lastActiveAgo!); + return L10n.of(context)! + .lastActiveAgo(time.localizedTimeShort(context)); } - return L10n.of(context).lastSeenLongTimeAgo; + return L10n.of(context)!.lastSeenLongTimeAgo; } - return L10n.of(context) + return L10n.of(context)! .countParticipants(summary.mJoinedMemberCount.toString()); } @@ -42,23 +45,23 @@ extension RoomStatusExtension on Room { typingUsers.removeWhere((User u) => u.id == client.userID); if (AppConfig.hideTypingUsernames) { - typingText = L10n.of(context).isTyping; + typingText = L10n.of(context)!.isTyping; if (typingUsers.first.id != directChatMatrixID) { typingText = - L10n.of(context).numUsersTyping(typingUsers.length.toString()); + L10n.of(context)!.numUsersTyping(typingUsers.length.toString()); } } else if (typingUsers.length == 1) { - typingText = L10n.of(context).isTyping; + typingText = L10n.of(context)!.isTyping; if (typingUsers.first.id != directChatMatrixID) { typingText = - L10n.of(context).userIsTyping(typingUsers.first.calcDisplayname()); + L10n.of(context)!.userIsTyping(typingUsers.first.calcDisplayname()); } } else if (typingUsers.length == 2) { - typingText = L10n.of(context).userAndUserAreTyping( + typingText = L10n.of(context)!.userAndUserAreTyping( typingUsers.first.calcDisplayname(), typingUsers[1].calcDisplayname()); } else if (typingUsers.length > 2) { - typingText = L10n.of(context).userAndOthersAreTyping( + typingText = L10n.of(context)!.userAndOthersAreTyping( typingUsers.first.calcDisplayname(), (typingUsers.length - 1).toString()); } diff --git a/lib/utils/run_in_background.dart b/lib/utils/run_in_background.dart index e75d1452..1ea4a7f3 100644 --- a/lib/utils/run_in_background.dart +++ b/lib/utils/run_in_background.dart @@ -1,3 +1,5 @@ +//@dart=2.12 + import 'dart:async'; import 'package:isolate/isolate.dart'; diff --git a/lib/utils/sentry_controller.dart b/lib/utils/sentry_controller.dart index b805d995..87708113 100644 --- a/lib/utils/sentry_controller.dart +++ b/lib/utils/sentry_controller.dart @@ -1,3 +1,5 @@ +//@dart=2.12 + import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; diff --git a/lib/utils/stream_extension.dart b/lib/utils/stream_extension.dart index e7b739da..eb0eed96 100644 --- a/lib/utils/stream_extension.dart +++ b/lib/utils/stream_extension.dart @@ -1,3 +1,5 @@ +//@dart=2.12 + import 'dart:async'; extension StreamExtension on Stream { @@ -5,11 +7,11 @@ extension StreamExtension on Stream { /// stream, ratelimited by the Duration t Stream rateLimit(Duration t) { final controller = StreamController(); - Timer timer; + Timer? timer; var gotMessage = false; // as we call our inline-defined function recursively we need to make sure that the // variable exists prior of creating the function. Silly dart. - Function _onMessage; + Function? _onMessage; // callback to determine if we should send out an update _onMessage = () { // do nothing if it is already closed @@ -25,7 +27,7 @@ extension StreamExtension on Stream { // method to send out an update! timer = null; if (gotMessage) { - _onMessage(); + _onMessage?.call(); } }); } else { @@ -33,7 +35,7 @@ extension StreamExtension on Stream { gotMessage = true; } }; - final subscription = listen((_) => _onMessage(), + final subscription = listen((_) => _onMessage?.call(), onDone: () => controller.close(), onError: (e, s) => controller.addError(e, s)); // add proper cleanup to the subscription and the controller, to not memory leak diff --git a/lib/utils/string_color.dart b/lib/utils/string_color.dart index 4ed39432..7e35841b 100644 --- a/lib/utils/string_color.dart +++ b/lib/utils/string_color.dart @@ -1,3 +1,5 @@ +//@dart=2.12 + import 'package:flutter/material.dart'; extension StringColor on String { diff --git a/lib/utils/ui_fake.dart b/lib/utils/ui_fake.dart deleted file mode 100644 index c2094e7c..00000000 --- a/lib/utils/ui_fake.dart +++ /dev/null @@ -1,4 +0,0 @@ -// ignore: camel_case_types -class platformViewRegistry { - static void registerViewFactory(String _, dynamic __) {} -} diff --git a/lib/utils/uia_request_manager.dart b/lib/utils/uia_request_manager.dart index 3a513af6..08d74433 100644 --- a/lib/utils/uia_request_manager.dart +++ b/lib/utils/uia_request_manager.dart @@ -1,3 +1,5 @@ +//@dart=2.12 + import 'dart:async'; import 'package:adaptive_dialog/adaptive_dialog.dart'; @@ -24,9 +26,9 @@ extension UiaRequestManager on MatrixState { final input = cachedPassword ?? (await showTextInputDialog( context: navigatorContext, - title: L10n.of(context).pleaseEnterYourPassword, - okLabel: L10n.of(context).ok, - cancelLabel: L10n.of(context).cancel, + title: L10n.of(context)!.pleaseEnterYourPassword, + okLabel: L10n.of(context)!.ok, + cancelLabel: L10n.of(context)!.cancel, textFields: [ const DialogTextField( minLines: 1, @@ -37,20 +39,20 @@ extension UiaRequestManager on MatrixState { ], )) ?.single; - if (input?.isEmpty ?? true) { + if (input == null || input.isEmpty) { return uiaRequest.cancel(); } return uiaRequest.completeStage( AuthenticationPassword( session: uiaRequest.session, password: input, - identifier: AuthenticationUserIdentifier(user: client.userID), + identifier: AuthenticationUserIdentifier(user: client.userID!), ), ); case AuthenticationTypes.emailIdentity: if (currentThreepidCreds == null || currentClientSecret == null) { return uiaRequest.cancel( - UiaException(L10n.of(widget.context).serverRequiresEmail), + UiaException(L10n.of(widget.context)!.serverRequiresEmail), ); } final auth = AuthenticationThreePidCreds( @@ -65,10 +67,10 @@ extension UiaRequestManager on MatrixState { await showOkCancelAlertDialog( useRootNavigator: false, context: navigatorContext, - title: L10n.of(context).weSentYouAnEmail, - message: L10n.of(context).pleaseClickOnLink, - okLabel: L10n.of(context).iHaveClickedOnLink, - cancelLabel: L10n.of(context).cancel, + title: L10n.of(context)!.weSentYouAnEmail, + message: L10n.of(context)!.pleaseClickOnLink, + okLabel: L10n.of(context)!.iHaveClickedOnLink, + cancelLabel: L10n.of(context)!.cancel, )) { return uiaRequest.completeStage(auth); } @@ -90,7 +92,7 @@ extension UiaRequestManager on MatrixState { action: (_, __) { uiaRequest.cancel(); }, - label: L10n.of(context).cancel, + label: L10n.of(context)!.cancel, id: 0, ), ); @@ -101,10 +103,10 @@ extension UiaRequestManager on MatrixState { if (OkCancelResult.ok == await showOkCancelAlertDialog( useRootNavigator: false, - message: L10n.of(context).pleaseFollowInstructionsOnWeb, + message: L10n.of(context)!.pleaseFollowInstructionsOnWeb, context: navigatorContext, - okLabel: L10n.of(context).next, - cancelLabel: L10n.of(context).cancel, + okLabel: L10n.of(context)!.next, + cancelLabel: L10n.of(context)!.cancel, )) { return uiaRequest.completeStage( AuthenticationData(session: uiaRequest.session),