From 3ab1e1956ecea5c30bb68347bf872f9db09fb6f8 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Wed, 19 May 2021 12:43:52 +0200 Subject: [PATCH 01/11] bump changelogs and pubspecs --- packages/stream_chat/CHANGELOG.md | 6 ++++++ packages/stream_chat/lib/version.dart | 2 +- packages/stream_chat/pubspec.yaml | 4 ++-- packages/stream_chat_flutter/CHANGELOG.md | 6 ++++++ packages/stream_chat_flutter/pubspec.yaml | 8 ++++---- packages/stream_chat_flutter_core/CHANGELOG.md | 5 +++++ packages/stream_chat_flutter_core/pubspec.yaml | 8 ++++---- packages/stream_chat_persistence/CHANGELOG.md | 6 ++++++ packages/stream_chat_persistence/pubspec.yaml | 6 +++--- 9 files changed, 37 insertions(+), 14 deletions(-) diff --git a/packages/stream_chat/CHANGELOG.md b/packages/stream_chat/CHANGELOG.md index 7fc05197e..75fecc34d 100644 --- a/packages/stream_chat/CHANGELOG.md +++ b/packages/stream_chat/CHANGELOG.md @@ -1,3 +1,9 @@ +## 2.0.0-nullsafety.2 + +- Added new `Filter.raw` constructor +- Changed extraData +- Minor fixes + ## 2.0.0-nullsafety.1 - Migrate this package to null safety diff --git a/packages/stream_chat/lib/version.dart b/packages/stream_chat/lib/version.dart index ef903a2aa..6c68818a0 100644 --- a/packages/stream_chat/lib/version.dart +++ b/packages/stream_chat/lib/version.dart @@ -3,4 +3,4 @@ import 'package:stream_chat/src/client.dart'; /// Current package version /// Used in [StreamChatClient] to build the `x-stream-client` header // ignore: constant_identifier_names -const PACKAGE_VERSION = '2.0.0-nullsafety.1'; +const PACKAGE_VERSION = '2.0.0-nullsafety.2'; diff --git a/packages/stream_chat/pubspec.yaml b/packages/stream_chat/pubspec.yaml index 6b8ee0aa6..d473beea9 100644 --- a/packages/stream_chat/pubspec.yaml +++ b/packages/stream_chat/pubspec.yaml @@ -1,7 +1,7 @@ name: stream_chat homepage: https://getstream.io/ description: The official Dart client for Stream Chat, a service for building chat applications. -version: 2.0.0-nullsafety.1 +version: 2.0.0-nullsafety.2 repository: https://github.com/GetStream/stream-chat-flutter issue_tracker: https://github.com/GetStream/stream-chat-flutter/issues @@ -19,7 +19,7 @@ dependencies: logging: ^1.0.1 meta: ^1.3.0 mime: ^1.0.0 - rxdart: ^0.26.0 + rxdart: ^0.27.0 uuid: ^3.0.4 web_socket_channel: ^2.0.0 diff --git a/packages/stream_chat_flutter/CHANGELOG.md b/packages/stream_chat_flutter/CHANGELOG.md index 9d3b372ee..e0b60fad6 100644 --- a/packages/stream_chat_flutter/CHANGELOG.md +++ b/packages/stream_chat_flutter/CHANGELOG.md @@ -1,3 +1,9 @@ +## 2.0.0-nullsafety.4 + +- Minor fixes and improvements +- Updated `stream_chat_core` dependency +- Improved performance of `MessageWidget` component + ## 2.0.0-nullsafety.3 - Fix MessageInput overflow when there are no actions diff --git a/packages/stream_chat_flutter/pubspec.yaml b/packages/stream_chat_flutter/pubspec.yaml index 1b2dbe2f7..2aa5ab4a9 100644 --- a/packages/stream_chat_flutter/pubspec.yaml +++ b/packages/stream_chat_flutter/pubspec.yaml @@ -1,7 +1,7 @@ name: stream_chat_flutter homepage: https://github.com/GetStream/stream-chat-flutter description: Stream Chat official Flutter SDK. Build your own chat experience using Dart and Flutter. -version: 2.0.0-nullsafety.3 +version: 2.0.0-nullsafety.4 repository: https://github.com/GetStream/stream-chat-flutter issue_tracker: https://github.com/GetStream/stream-chat-flutter/issues @@ -30,13 +30,13 @@ dependencies: lottie: ^1.0.1 meta: ^1.3.0 path_provider: ^2.0.1 - photo_manager: ^1.1.4 + photo_manager: ^1.1.6 photo_view: ^0.11.1 - rxdart: ^0.26.0 + rxdart: ^0.27.0 scrollable_positioned_list: ^0.2.0-nullsafety.0 share_plus: ^2.0.3 shimmer: ^2.0.0 - stream_chat_flutter_core: ^2.0.0-nullsafety.2 + stream_chat_flutter_core: ^2.0.0-nullsafety.3 substring_highlight: ^1.0.26 synchronized: ^3.0.0 url_launcher: ^6.0.3 diff --git a/packages/stream_chat_flutter_core/CHANGELOG.md b/packages/stream_chat_flutter_core/CHANGELOG.md index f07b49bd9..1930e36a9 100644 --- a/packages/stream_chat_flutter_core/CHANGELOG.md +++ b/packages/stream_chat_flutter_core/CHANGELOG.md @@ -1,3 +1,8 @@ +## 2.0.0-nullsafety.3 + +* Update llc dependency +* Minor fixes and improvements + ## 2.0.0-nullsafety.2 * Fix ChannelsBloc not performing calls if pagination ended diff --git a/packages/stream_chat_flutter_core/pubspec.yaml b/packages/stream_chat_flutter_core/pubspec.yaml index c84242b8b..e8d1014dd 100644 --- a/packages/stream_chat_flutter_core/pubspec.yaml +++ b/packages/stream_chat_flutter_core/pubspec.yaml @@ -1,7 +1,7 @@ name: stream_chat_flutter_core homepage: https://github.com/GetStream/stream-chat-flutter description: Stream Chat official Flutter SDK Core. Build your own chat experience using Dart and Flutter. -version: 2.0.0-nullsafety.2 +version: 2.0.0-nullsafety.3 repository: https://github.com/GetStream/stream-chat-flutter issue_tracker: https://github.com/GetStream/stream-chat-flutter/issues @@ -10,12 +10,12 @@ environment: flutter: ">=1.17.0" dependencies: - collection: ^1.15.0-nullsafety.4 + collection: ^1.15.0 flutter: sdk: flutter meta: ^1.3.0 - rxdart: ^0.26.0 - stream_chat: ^2.0.0-nullsafety.1 + rxdart: ^0.27.0 + stream_chat: ^2.0.0-nullsafety.2 dev_dependencies: fake_async: ^1.2.0 diff --git a/packages/stream_chat_persistence/CHANGELOG.md b/packages/stream_chat_persistence/CHANGELOG.md index 961e3de09..c35459ca4 100644 --- a/packages/stream_chat_persistence/CHANGELOG.md +++ b/packages/stream_chat_persistence/CHANGELOG.md @@ -1,3 +1,9 @@ +## 2.0.0-nullsafety.2 + +* Update llc dependency +* Minor fixes and improvements +* Fixed bug not saving message.mentioned_users + ## 2.0.0-nullsafety.1 * Migrate this package to null safety diff --git a/packages/stream_chat_persistence/pubspec.yaml b/packages/stream_chat_persistence/pubspec.yaml index 5d1927c30..661f55bb2 100644 --- a/packages/stream_chat_persistence/pubspec.yaml +++ b/packages/stream_chat_persistence/pubspec.yaml @@ -1,7 +1,7 @@ name: stream_chat_persistence homepage: https://github.com/GetStream/stream-chat-flutter description: Official Stream Chat Persistence library. Build your own chat experience using Dart and Flutter. -version: 2.0.0-nullsafety.1 +version: 2.0.0-nullsafety.2 repository: https://github.com/GetStream/stream-chat-flutter issue_tracker: https://github.com/GetStream/stream-chat-flutter/issues @@ -17,8 +17,8 @@ dependencies: mutex: ^3.0.0 path: ^1.8.0 path_provider: ^2.0.1 - sqlite3_flutter_libs: ^0.4.1 - stream_chat: ^2.0.0-nullsafety.0 + sqlite3_flutter_libs: ^0.4.2 + stream_chat: ^2.0.0-nullsafety.2 dev_dependencies: build_runner: ^2.0.1 From f5e73d3cc61c2073da6df5c6d43e7aceb8891268 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Wed, 19 May 2021 12:59:21 +0200 Subject: [PATCH 02/11] update rxdart --- packages/stream_chat/lib/src/api/channel.dart | 12 ++++++------ packages/stream_chat/lib/src/client.dart | 4 ++-- .../lib/src/channel_list_core.dart | 2 ++ .../lib/src/channels_bloc.dart | 4 ++-- .../lib/src/message_search_bloc.dart | 3 +-- .../stream_chat_flutter_core/lib/src/users_bloc.dart | 2 +- 6 files changed, 14 insertions(+), 13 deletions(-) diff --git a/packages/stream_chat/lib/src/api/channel.dart b/packages/stream_chat/lib/src/api/channel.dart index cb3cfe37a..69d967fe3 100644 --- a/packages/stream_chat/lib/src/api/channel.dart +++ b/packages/stream_chat/lib/src/api/channel.dart @@ -1427,7 +1427,7 @@ class ChannelClientState { /// This flag should be managed by UI sdks. /// When false, any new message (received by WebSocket event /// - [EventType.messageNew]) will not be pushed on to message list. - bool get isUpToDate => _isUpToDateController.value ?? true; + bool get isUpToDate => _isUpToDateController.value; set isUpToDate(bool isUpToDate) => _isUpToDateController.add(isUpToDate); @@ -1528,7 +1528,7 @@ class ChannelClientState { } if (_countMessageAsUnread(message)) { - _unreadCountController.add(_unreadCountController.value! + 1); + _unreadCountController.add(_unreadCountController.value + 1); } })); } @@ -1766,13 +1766,13 @@ class ChannelClientState { a.createdAt.compareTo(b.createdAt); /// The channel state related to this client - ChannelState get _channelState => _channelStateController.value!; + ChannelState get _channelState => _channelStateController.value; /// The channel state related to this client as a stream Stream get channelStateStream => _channelStateController.stream; /// The channel state related to this client - ChannelState get channelState => _channelStateController.value!; + ChannelState get channelState => _channelStateController.value; late BehaviorSubject _channelStateController; final Debounce _debouncedUpdatePersistenceChannelState; @@ -1784,7 +1784,7 @@ class ChannelClientState { /// The channel threads related to this channel Map> get threads => - _threadsController.value!.map((key, value) => MapEntry(key, value)); + _threadsController.value.map((key, value) => MapEntry(key, value)); /// The channel threads related to this channel as a stream Stream>> get threadsStream => @@ -1801,7 +1801,7 @@ class ChannelClientState { } /// Channel related typing users last value - List get typingEvents => _typingEventsController.value!; + List get typingEvents => _typingEventsController.value; /// Channel related typing users stream Stream> get typingEventsStream => _typingEventsController.stream; diff --git a/packages/stream_chat/lib/src/client.dart b/packages/stream_chat/lib/src/client.dart index 3cabe274d..b6efb6a5e 100644 --- a/packages/stream_chat/lib/src/client.dart +++ b/packages/stream_chat/lib/src/client.dart @@ -1495,7 +1495,7 @@ class ClientState { Stream get userStream => _userController.stream; /// The current user - Map get users => _usersController.value!; + Map get users => _usersController.value; /// The current user as a stream Stream> get usersStream => _usersController.stream; @@ -1517,7 +1517,7 @@ class ClientState { _channelsController.stream; /// The current list of channels in memory - Map get channels => _channelsController.value!; + Map get channels => _channelsController.value; set channels(Map v) { _channelsController.add(v); diff --git a/packages/stream_chat_flutter_core/lib/src/channel_list_core.dart b/packages/stream_chat_flutter_core/lib/src/channel_list_core.dart index a3be273dc..dbd572699 100644 --- a/packages/stream_chat_flutter_core/lib/src/channel_list_core.dart +++ b/packages/stream_chat_flutter_core/lib/src/channel_list_core.dart @@ -132,6 +132,8 @@ class ChannelListCoreState extends State { stream: channelsBlocState.channelsStream, builder: (context, snapshot) { if (snapshot.hasError) { + print(snapshot.error); + print(snapshot.stackTrace); return widget.errorBuilder(context, snapshot.error!); } if (!snapshot.hasData) { diff --git a/packages/stream_chat_flutter_core/lib/src/channels_bloc.dart b/packages/stream_chat_flutter_core/lib/src/channels_bloc.dart index d46ee4bd6..a3f0b58ca 100644 --- a/packages/stream_chat_flutter_core/lib/src/channels_bloc.dart +++ b/packages/stream_chat_flutter_core/lib/src/channels_bloc.dart @@ -71,7 +71,7 @@ class ChannelsBlocState extends State } /// The current channel list - List? get channels => _channelsController.value; + List? get channels => _channelsController.valueOrNull; /// The current channel list as a stream Stream> get channelsStream => _channelsController.stream; @@ -128,7 +128,7 @@ class ChannelsBlocState extends State _channelsController.add(temp); } if (_channelsController.hasValue && - _queryChannelsLoadingController.value!) { + _queryChannelsLoadingController.value) { _queryChannelsLoadingController.sink.add(false); } } diff --git a/packages/stream_chat_flutter_core/lib/src/message_search_bloc.dart b/packages/stream_chat_flutter_core/lib/src/message_search_bloc.dart index 386ba3889..70e6df116 100644 --- a/packages/stream_chat_flutter_core/lib/src/message_search_bloc.dart +++ b/packages/stream_chat_flutter_core/lib/src/message_search_bloc.dart @@ -93,8 +93,7 @@ class MessageSearchBlocState extends State final temp = oldMessages + messages.results; _messageResponses.add(temp); } - if (_messageResponses.hasValue && - _queryMessagesLoadingController.value!) { + if (_messageResponses.hasValue && _queryMessagesLoadingController.value) { _queryMessagesLoadingController.add(false); } } catch (e, stk) { diff --git a/packages/stream_chat_flutter_core/lib/src/users_bloc.dart b/packages/stream_chat_flutter_core/lib/src/users_bloc.dart index 57edfecb4..0c0d46cd5 100644 --- a/packages/stream_chat_flutter_core/lib/src/users_bloc.dart +++ b/packages/stream_chat_flutter_core/lib/src/users_bloc.dart @@ -92,7 +92,7 @@ class UsersBlocState extends State final temp = oldUsers + usersResponse.users; _usersController.add(temp); } - if (_usersController.hasValue && _queryUsersLoadingController.value!) { + if (_usersController.hasValue && _queryUsersLoadingController.value) { _queryUsersLoadingController.add(false); } } catch (e, stk) { From d7edb844f77453d9eb9f5a72496c1e5d539d2b0f Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Wed, 19 May 2021 13:11:23 +0200 Subject: [PATCH 03/11] regenerate files --- .../lib/src/db/moor_chat_database.g.dart | 296 +++++++++--------- 1 file changed, 142 insertions(+), 154 deletions(-) diff --git a/packages/stream_chat_persistence/lib/src/db/moor_chat_database.g.dart b/packages/stream_chat_persistence/lib/src/db/moor_chat_database.g.dart index b8d404b25..8da717178 100644 --- a/packages/stream_chat_persistence/lib/src/db/moor_chat_database.g.dart +++ b/packages/stream_chat_persistence/lib/src/db/moor_chat_database.g.dart @@ -60,31 +60,30 @@ class ChannelEntity extends DataClass implements Insertable { Map data, GeneratedDatabase db, {String? prefix}) { final effectivePrefix = prefix ?? ''; - final stringType = db.typeSystem.forDartType(); - final boolType = db.typeSystem.forDartType(); - final dateTimeType = db.typeSystem.forDartType(); - final intType = db.typeSystem.forDartType(); return ChannelEntity( - id: stringType.mapFromDatabaseResponse(data['${effectivePrefix}id'])!, - type: stringType.mapFromDatabaseResponse(data['${effectivePrefix}type'])!, - cid: stringType.mapFromDatabaseResponse(data['${effectivePrefix}cid'])!, - config: $ChannelsTable.$converter0.mapToDart(stringType + id: const StringType() + .mapFromDatabaseResponse(data['${effectivePrefix}id'])!, + type: const StringType() + .mapFromDatabaseResponse(data['${effectivePrefix}type'])!, + cid: const StringType() + .mapFromDatabaseResponse(data['${effectivePrefix}cid'])!, + config: $ChannelsTable.$converter0.mapToDart(const StringType() .mapFromDatabaseResponse(data['${effectivePrefix}config']))!, - frozen: - boolType.mapFromDatabaseResponse(data['${effectivePrefix}frozen'])!, - lastMessageAt: dateTimeType + frozen: const BoolType() + .mapFromDatabaseResponse(data['${effectivePrefix}frozen'])!, + lastMessageAt: const DateTimeType() .mapFromDatabaseResponse(data['${effectivePrefix}last_message_at']), - createdAt: dateTimeType + createdAt: const DateTimeType() .mapFromDatabaseResponse(data['${effectivePrefix}created_at'])!, - updatedAt: dateTimeType + updatedAt: const DateTimeType() .mapFromDatabaseResponse(data['${effectivePrefix}updated_at'])!, - deletedAt: dateTimeType + deletedAt: const DateTimeType() .mapFromDatabaseResponse(data['${effectivePrefix}deleted_at']), - memberCount: intType + memberCount: const IntType() .mapFromDatabaseResponse(data['${effectivePrefix}member_count'])!, - createdById: stringType + createdById: const StringType() .mapFromDatabaseResponse(data['${effectivePrefix}created_by_id']), - extraData: $ChannelsTable.$converter1.mapToDart(stringType + extraData: $ChannelsTable.$converter1.mapToDart(const StringType() .mapFromDatabaseResponse(data['${effectivePrefix}extra_data'])), ); } @@ -226,7 +225,7 @@ class ChannelEntity extends DataClass implements Insertable { $mrjc(createdById.hashCode, extraData.hashCode)))))))))))); @override - bool operator ==(dynamic other) => + bool operator ==(Object other) => identical(this, other) || (other is ChannelEntity && other.id == this.id && @@ -742,56 +741,54 @@ class MessageEntity extends DataClass implements Insertable { Map data, GeneratedDatabase db, {String? prefix}) { final effectivePrefix = prefix ?? ''; - final stringType = db.typeSystem.forDartType(); - final intType = db.typeSystem.forDartType(); - final boolType = db.typeSystem.forDartType(); - final dateTimeType = db.typeSystem.forDartType(); return MessageEntity( - id: stringType.mapFromDatabaseResponse(data['${effectivePrefix}id'])!, - messageText: stringType + id: const StringType() + .mapFromDatabaseResponse(data['${effectivePrefix}id'])!, + messageText: const StringType() .mapFromDatabaseResponse(data['${effectivePrefix}message_text']), - attachments: $MessagesTable.$converter0.mapToDart(stringType + attachments: $MessagesTable.$converter0.mapToDart(const StringType() .mapFromDatabaseResponse(data['${effectivePrefix}attachments']))!, - status: $MessagesTable.$converter1.mapToDart( - intType.mapFromDatabaseResponse(data['${effectivePrefix}status']))!, - type: stringType.mapFromDatabaseResponse(data['${effectivePrefix}type'])!, - mentionedUsers: $MessagesTable.$converter2.mapToDart(stringType + status: $MessagesTable.$converter1.mapToDart(const IntType() + .mapFromDatabaseResponse(data['${effectivePrefix}status']))!, + type: const StringType() + .mapFromDatabaseResponse(data['${effectivePrefix}type'])!, + mentionedUsers: $MessagesTable.$converter2.mapToDart(const StringType() .mapFromDatabaseResponse(data['${effectivePrefix}mentioned_users']))!, - reactionCounts: $MessagesTable.$converter3.mapToDart(stringType + reactionCounts: $MessagesTable.$converter3.mapToDart(const StringType() .mapFromDatabaseResponse(data['${effectivePrefix}reaction_counts'])), - reactionScores: $MessagesTable.$converter4.mapToDart(stringType + reactionScores: $MessagesTable.$converter4.mapToDart(const StringType() .mapFromDatabaseResponse(data['${effectivePrefix}reaction_scores'])), - parentId: stringType + parentId: const StringType() .mapFromDatabaseResponse(data['${effectivePrefix}parent_id']), - quotedMessageId: stringType + quotedMessageId: const StringType() .mapFromDatabaseResponse(data['${effectivePrefix}quoted_message_id']), - replyCount: intType + replyCount: const IntType() .mapFromDatabaseResponse(data['${effectivePrefix}reply_count']), - showInChannel: boolType + showInChannel: const BoolType() .mapFromDatabaseResponse(data['${effectivePrefix}show_in_channel']), - shadowed: - boolType.mapFromDatabaseResponse(data['${effectivePrefix}shadowed'])!, - command: - stringType.mapFromDatabaseResponse(data['${effectivePrefix}command']), - createdAt: dateTimeType + shadowed: const BoolType() + .mapFromDatabaseResponse(data['${effectivePrefix}shadowed'])!, + command: const StringType() + .mapFromDatabaseResponse(data['${effectivePrefix}command']), + createdAt: const DateTimeType() .mapFromDatabaseResponse(data['${effectivePrefix}created_at'])!, - updatedAt: dateTimeType + updatedAt: const DateTimeType() .mapFromDatabaseResponse(data['${effectivePrefix}updated_at'])!, - deletedAt: dateTimeType + deletedAt: const DateTimeType() .mapFromDatabaseResponse(data['${effectivePrefix}deleted_at']), - userId: - stringType.mapFromDatabaseResponse(data['${effectivePrefix}user_id']), - pinned: - boolType.mapFromDatabaseResponse(data['${effectivePrefix}pinned'])!, - pinnedAt: dateTimeType + userId: const StringType() + .mapFromDatabaseResponse(data['${effectivePrefix}user_id']), + pinned: const BoolType() + .mapFromDatabaseResponse(data['${effectivePrefix}pinned'])!, + pinnedAt: const DateTimeType() .mapFromDatabaseResponse(data['${effectivePrefix}pinned_at']), - pinExpires: dateTimeType + pinExpires: const DateTimeType() .mapFromDatabaseResponse(data['${effectivePrefix}pin_expires']), - pinnedByUserId: stringType + pinnedByUserId: const StringType() .mapFromDatabaseResponse(data['${effectivePrefix}pinned_by_user_id']), - channelCid: stringType + channelCid: const StringType() .mapFromDatabaseResponse(data['${effectivePrefix}channel_cid']), - extraData: $MessagesTable.$converter5.mapToDart(stringType + extraData: $MessagesTable.$converter5.mapToDart(const StringType() .mapFromDatabaseResponse(data['${effectivePrefix}extra_data'])), ); } @@ -1066,7 +1063,7 @@ class MessageEntity extends DataClass implements Insertable { pinned.hashCode, $mrjc(pinnedAt.hashCode, $mrjc(pinExpires.hashCode, $mrjc(pinnedByUserId.hashCode, $mrjc(channelCid.hashCode, extraData.hashCode)))))))))))))))))))))))); @override - bool operator ==(dynamic other) => + bool operator ==(Object other) => identical(this, other) || (other is MessageEntity && other.id == this.id && @@ -1923,56 +1920,57 @@ class PinnedMessageEntity extends DataClass Map data, GeneratedDatabase db, {String? prefix}) { final effectivePrefix = prefix ?? ''; - final stringType = db.typeSystem.forDartType(); - final intType = db.typeSystem.forDartType(); - final boolType = db.typeSystem.forDartType(); - final dateTimeType = db.typeSystem.forDartType(); return PinnedMessageEntity( - id: stringType.mapFromDatabaseResponse(data['${effectivePrefix}id'])!, - messageText: stringType + id: const StringType() + .mapFromDatabaseResponse(data['${effectivePrefix}id'])!, + messageText: const StringType() .mapFromDatabaseResponse(data['${effectivePrefix}message_text']), - attachments: $PinnedMessagesTable.$converter0.mapToDart(stringType + attachments: $PinnedMessagesTable.$converter0.mapToDart(const StringType() .mapFromDatabaseResponse(data['${effectivePrefix}attachments']))!, - status: $PinnedMessagesTable.$converter1.mapToDart( - intType.mapFromDatabaseResponse(data['${effectivePrefix}status']))!, - type: stringType.mapFromDatabaseResponse(data['${effectivePrefix}type'])!, - mentionedUsers: $PinnedMessagesTable.$converter2.mapToDart(stringType - .mapFromDatabaseResponse(data['${effectivePrefix}mentioned_users']))!, - reactionCounts: $PinnedMessagesTable.$converter3.mapToDart(stringType - .mapFromDatabaseResponse(data['${effectivePrefix}reaction_counts'])), - reactionScores: $PinnedMessagesTable.$converter4.mapToDart(stringType - .mapFromDatabaseResponse(data['${effectivePrefix}reaction_scores'])), - parentId: stringType + status: $PinnedMessagesTable.$converter1.mapToDart(const IntType() + .mapFromDatabaseResponse(data['${effectivePrefix}status']))!, + type: const StringType() + .mapFromDatabaseResponse(data['${effectivePrefix}type'])!, + mentionedUsers: $PinnedMessagesTable.$converter2.mapToDart( + const StringType().mapFromDatabaseResponse( + data['${effectivePrefix}mentioned_users']))!, + reactionCounts: $PinnedMessagesTable.$converter3.mapToDart( + const StringType().mapFromDatabaseResponse( + data['${effectivePrefix}reaction_counts'])), + reactionScores: $PinnedMessagesTable.$converter4.mapToDart( + const StringType().mapFromDatabaseResponse( + data['${effectivePrefix}reaction_scores'])), + parentId: const StringType() .mapFromDatabaseResponse(data['${effectivePrefix}parent_id']), - quotedMessageId: stringType + quotedMessageId: const StringType() .mapFromDatabaseResponse(data['${effectivePrefix}quoted_message_id']), - replyCount: intType + replyCount: const IntType() .mapFromDatabaseResponse(data['${effectivePrefix}reply_count']), - showInChannel: boolType + showInChannel: const BoolType() .mapFromDatabaseResponse(data['${effectivePrefix}show_in_channel']), - shadowed: - boolType.mapFromDatabaseResponse(data['${effectivePrefix}shadowed'])!, - command: - stringType.mapFromDatabaseResponse(data['${effectivePrefix}command']), - createdAt: dateTimeType + shadowed: const BoolType() + .mapFromDatabaseResponse(data['${effectivePrefix}shadowed'])!, + command: const StringType() + .mapFromDatabaseResponse(data['${effectivePrefix}command']), + createdAt: const DateTimeType() .mapFromDatabaseResponse(data['${effectivePrefix}created_at'])!, - updatedAt: dateTimeType + updatedAt: const DateTimeType() .mapFromDatabaseResponse(data['${effectivePrefix}updated_at'])!, - deletedAt: dateTimeType + deletedAt: const DateTimeType() .mapFromDatabaseResponse(data['${effectivePrefix}deleted_at']), - userId: - stringType.mapFromDatabaseResponse(data['${effectivePrefix}user_id']), - pinned: - boolType.mapFromDatabaseResponse(data['${effectivePrefix}pinned'])!, - pinnedAt: dateTimeType + userId: const StringType() + .mapFromDatabaseResponse(data['${effectivePrefix}user_id']), + pinned: const BoolType() + .mapFromDatabaseResponse(data['${effectivePrefix}pinned'])!, + pinnedAt: const DateTimeType() .mapFromDatabaseResponse(data['${effectivePrefix}pinned_at']), - pinExpires: dateTimeType + pinExpires: const DateTimeType() .mapFromDatabaseResponse(data['${effectivePrefix}pin_expires']), - pinnedByUserId: stringType + pinnedByUserId: const StringType() .mapFromDatabaseResponse(data['${effectivePrefix}pinned_by_user_id']), - channelCid: stringType + channelCid: const StringType() .mapFromDatabaseResponse(data['${effectivePrefix}channel_cid']), - extraData: $PinnedMessagesTable.$converter5.mapToDart(stringType + extraData: $PinnedMessagesTable.$converter5.mapToDart(const StringType() .mapFromDatabaseResponse(data['${effectivePrefix}extra_data'])), ); } @@ -2247,7 +2245,7 @@ class PinnedMessageEntity extends DataClass pinned.hashCode, $mrjc(pinnedAt.hashCode, $mrjc(pinExpires.hashCode, $mrjc(pinnedByUserId.hashCode, $mrjc(channelCid.hashCode, extraData.hashCode)))))))))))))))))))))))); @override - bool operator ==(dynamic other) => + bool operator ==(Object other) => identical(this, other) || (other is PinnedMessageEntity && other.id == this.id && @@ -3031,19 +3029,18 @@ class ReactionEntity extends DataClass implements Insertable { Map data, GeneratedDatabase db, {String? prefix}) { final effectivePrefix = prefix ?? ''; - final stringType = db.typeSystem.forDartType(); - final dateTimeType = db.typeSystem.forDartType(); - final intType = db.typeSystem.forDartType(); return ReactionEntity( - userId: stringType + userId: const StringType() .mapFromDatabaseResponse(data['${effectivePrefix}user_id'])!, - messageId: stringType + messageId: const StringType() .mapFromDatabaseResponse(data['${effectivePrefix}message_id'])!, - type: stringType.mapFromDatabaseResponse(data['${effectivePrefix}type'])!, - createdAt: dateTimeType + type: const StringType() + .mapFromDatabaseResponse(data['${effectivePrefix}type'])!, + createdAt: const DateTimeType() .mapFromDatabaseResponse(data['${effectivePrefix}created_at'])!, - score: intType.mapFromDatabaseResponse(data['${effectivePrefix}score'])!, - extraData: $ReactionsTable.$converter0.mapToDart(stringType + score: const IntType() + .mapFromDatabaseResponse(data['${effectivePrefix}score'])!, + extraData: $ReactionsTable.$converter0.mapToDart(const StringType() .mapFromDatabaseResponse(data['${effectivePrefix}extra_data'])), ); } @@ -3125,7 +3122,7 @@ class ReactionEntity extends DataClass implements Insertable { $mrjc(createdAt.hashCode, $mrjc(score.hashCode, extraData.hashCode)))))); @override - bool operator ==(dynamic other) => + bool operator ==(Object other) => identical(this, other) || (other is ReactionEntity && other.userId == this.userId && @@ -3395,23 +3392,22 @@ class UserEntity extends DataClass implements Insertable { factory UserEntity.fromData(Map data, GeneratedDatabase db, {String? prefix}) { final effectivePrefix = prefix ?? ''; - final stringType = db.typeSystem.forDartType(); - final dateTimeType = db.typeSystem.forDartType(); - final boolType = db.typeSystem.forDartType(); return UserEntity( - id: stringType.mapFromDatabaseResponse(data['${effectivePrefix}id'])!, - role: stringType.mapFromDatabaseResponse(data['${effectivePrefix}role']), - createdAt: dateTimeType + id: const StringType() + .mapFromDatabaseResponse(data['${effectivePrefix}id'])!, + role: const StringType() + .mapFromDatabaseResponse(data['${effectivePrefix}role']), + createdAt: const DateTimeType() .mapFromDatabaseResponse(data['${effectivePrefix}created_at'])!, - updatedAt: dateTimeType + updatedAt: const DateTimeType() .mapFromDatabaseResponse(data['${effectivePrefix}updated_at'])!, - lastActive: dateTimeType + lastActive: const DateTimeType() .mapFromDatabaseResponse(data['${effectivePrefix}last_active']), - online: - boolType.mapFromDatabaseResponse(data['${effectivePrefix}online'])!, - banned: - boolType.mapFromDatabaseResponse(data['${effectivePrefix}banned'])!, - extraData: $UsersTable.$converter0.mapToDart(stringType + online: const BoolType() + .mapFromDatabaseResponse(data['${effectivePrefix}online'])!, + banned: const BoolType() + .mapFromDatabaseResponse(data['${effectivePrefix}banned'])!, + extraData: $UsersTable.$converter0.mapToDart(const StringType() .mapFromDatabaseResponse(data['${effectivePrefix}extra_data']))!, ); } @@ -3513,7 +3509,7 @@ class UserEntity extends DataClass implements Insertable { $mrjc(online.hashCode, $mrjc(banned.hashCode, extraData.hashCode)))))))); @override - bool operator ==(dynamic other) => + bool operator ==(Object other) => identical(this, other) || (other is UserEntity && other.id == this.id && @@ -3554,7 +3550,7 @@ class UsersCompanion extends UpdateCompanion { this.online = const Value.absent(), this.banned = const Value.absent(), required Map extraData, - }) : id = Value(id), + }) : id = Value(id), extraData = Value(extraData); static Insertable custom({ Expression? id, @@ -3841,30 +3837,28 @@ class MemberEntity extends DataClass implements Insertable { factory MemberEntity.fromData(Map data, GeneratedDatabase db, {String? prefix}) { final effectivePrefix = prefix ?? ''; - final stringType = db.typeSystem.forDartType(); - final dateTimeType = db.typeSystem.forDartType(); - final boolType = db.typeSystem.forDartType(); return MemberEntity( - userId: stringType + userId: const StringType() .mapFromDatabaseResponse(data['${effectivePrefix}user_id'])!, - channelCid: stringType + channelCid: const StringType() .mapFromDatabaseResponse(data['${effectivePrefix}channel_cid'])!, - role: stringType.mapFromDatabaseResponse(data['${effectivePrefix}role']), - inviteAcceptedAt: dateTimeType.mapFromDatabaseResponse( + role: const StringType() + .mapFromDatabaseResponse(data['${effectivePrefix}role']), + inviteAcceptedAt: const DateTimeType().mapFromDatabaseResponse( data['${effectivePrefix}invite_accepted_at']), - inviteRejectedAt: dateTimeType.mapFromDatabaseResponse( + inviteRejectedAt: const DateTimeType().mapFromDatabaseResponse( data['${effectivePrefix}invite_rejected_at']), - invited: - boolType.mapFromDatabaseResponse(data['${effectivePrefix}invited'])!, - banned: - boolType.mapFromDatabaseResponse(data['${effectivePrefix}banned'])!, - shadowBanned: boolType + invited: const BoolType() + .mapFromDatabaseResponse(data['${effectivePrefix}invited'])!, + banned: const BoolType() + .mapFromDatabaseResponse(data['${effectivePrefix}banned'])!, + shadowBanned: const BoolType() .mapFromDatabaseResponse(data['${effectivePrefix}shadow_banned'])!, - isModerator: boolType + isModerator: const BoolType() .mapFromDatabaseResponse(data['${effectivePrefix}is_moderator'])!, - createdAt: dateTimeType + createdAt: const DateTimeType() .mapFromDatabaseResponse(data['${effectivePrefix}created_at'])!, - updatedAt: dateTimeType + updatedAt: const DateTimeType() .mapFromDatabaseResponse(data['${effectivePrefix}updated_at'])!, ); } @@ -3997,7 +3991,7 @@ class MemberEntity extends DataClass implements Insertable { $mrjc(createdAt.hashCode, updatedAt.hashCode))))))))))); @override - bool operator ==(dynamic other) => + bool operator ==(Object other) => identical(this, other) || (other is MemberEntity && other.userId == this.userId && @@ -4396,17 +4390,14 @@ class ReadEntity extends DataClass implements Insertable { factory ReadEntity.fromData(Map data, GeneratedDatabase db, {String? prefix}) { final effectivePrefix = prefix ?? ''; - final dateTimeType = db.typeSystem.forDartType(); - final stringType = db.typeSystem.forDartType(); - final intType = db.typeSystem.forDartType(); return ReadEntity( - lastRead: dateTimeType + lastRead: const DateTimeType() .mapFromDatabaseResponse(data['${effectivePrefix}last_read'])!, - userId: stringType + userId: const StringType() .mapFromDatabaseResponse(data['${effectivePrefix}user_id'])!, - channelCid: stringType + channelCid: const StringType() .mapFromDatabaseResponse(data['${effectivePrefix}channel_cid'])!, - unreadMessages: intType + unreadMessages: const IntType() .mapFromDatabaseResponse(data['${effectivePrefix}unread_messages'])!, ); } @@ -4469,7 +4460,7 @@ class ReadEntity extends DataClass implements Insertable { $mrjc(userId.hashCode, $mrjc(channelCid.hashCode, unreadMessages.hashCode)))); @override - bool operator ==(dynamic other) => + bool operator ==(Object other) => identical(this, other) || (other is ReadEntity && other.lastRead == this.lastRead && @@ -4666,11 +4657,10 @@ class ChannelQueryEntity extends DataClass Map data, GeneratedDatabase db, {String? prefix}) { final effectivePrefix = prefix ?? ''; - final stringType = db.typeSystem.forDartType(); return ChannelQueryEntity( - queryHash: stringType + queryHash: const StringType() .mapFromDatabaseResponse(data['${effectivePrefix}query_hash'])!, - channelCid: stringType + channelCid: const StringType() .mapFromDatabaseResponse(data['${effectivePrefix}channel_cid'])!, ); } @@ -4716,7 +4706,7 @@ class ChannelQueryEntity extends DataClass @override int get hashCode => $mrjf($mrjc(queryHash.hashCode, channelCid.hashCode)); @override - bool operator ==(dynamic other) => + bool operator ==(Object other) => identical(this, other) || (other is ChannelQueryEntity && other.queryHash == this.queryHash && @@ -4733,7 +4723,7 @@ class ChannelQueriesCompanion extends UpdateCompanion { ChannelQueriesCompanion.insert({ required String queryHash, required String channelCid, - }) : queryHash = Value(queryHash), + }) : queryHash = Value(queryHash), channelCid = Value(channelCid); static Insertable custom({ Expression? queryHash, @@ -4876,20 +4866,18 @@ class ConnectionEventEntity extends DataClass Map data, GeneratedDatabase db, {String? prefix}) { final effectivePrefix = prefix ?? ''; - final intType = db.typeSystem.forDartType(); - final stringType = db.typeSystem.forDartType(); - final dateTimeType = db.typeSystem.forDartType(); return ConnectionEventEntity( - id: intType.mapFromDatabaseResponse(data['${effectivePrefix}id'])!, - ownUser: $ConnectionEventsTable.$converter0.mapToDart(stringType + id: const IntType() + .mapFromDatabaseResponse(data['${effectivePrefix}id'])!, + ownUser: $ConnectionEventsTable.$converter0.mapToDart(const StringType() .mapFromDatabaseResponse(data['${effectivePrefix}own_user'])), - totalUnreadCount: intType.mapFromDatabaseResponse( + totalUnreadCount: const IntType().mapFromDatabaseResponse( data['${effectivePrefix}total_unread_count']), - unreadChannels: intType + unreadChannels: const IntType() .mapFromDatabaseResponse(data['${effectivePrefix}unread_channels']), - lastEventAt: dateTimeType + lastEventAt: const DateTimeType() .mapFromDatabaseResponse(data['${effectivePrefix}last_event_at']), - lastSyncAt: dateTimeType + lastSyncAt: const DateTimeType() .mapFromDatabaseResponse(data['${effectivePrefix}last_sync_at']), ); } @@ -4982,7 +4970,7 @@ class ConnectionEventEntity extends DataClass $mrjc(unreadChannels.hashCode, $mrjc(lastEventAt.hashCode, lastSyncAt.hashCode)))))); @override - bool operator ==(dynamic other) => + bool operator ==(Object other) => identical(this, other) || (other is ConnectionEventEntity && other.id == this.id && From b67db631e4ef64ffc26774fab53bff04dc688b5e Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Wed, 19 May 2021 13:30:37 +0200 Subject: [PATCH 04/11] use specific analysis option files --- .../stream_chat/analysis_options.yaml | 0 .../stream_chat_flutter/analysis_options.yaml | 150 ++++++++++++++++++ .../analysis_options.yaml | 150 ++++++++++++++++++ .../analysis_options.yaml | 150 ++++++++++++++++++ 4 files changed, 450 insertions(+) rename analysis_options.yaml => packages/stream_chat/analysis_options.yaml (100%) create mode 100644 packages/stream_chat_flutter/analysis_options.yaml create mode 100644 packages/stream_chat_flutter_core/analysis_options.yaml create mode 100644 packages/stream_chat_persistence/analysis_options.yaml diff --git a/analysis_options.yaml b/packages/stream_chat/analysis_options.yaml similarity index 100% rename from analysis_options.yaml rename to packages/stream_chat/analysis_options.yaml diff --git a/packages/stream_chat_flutter/analysis_options.yaml b/packages/stream_chat_flutter/analysis_options.yaml new file mode 100644 index 000000000..f0a87ea5d --- /dev/null +++ b/packages/stream_chat_flutter/analysis_options.yaml @@ -0,0 +1,150 @@ +analyzer: + enable-experiment: + - extension-methods + exclude: + - lib/**/*.g.dart + - example/** + - lib/src/emoji + - lib/**/*.freezed.dart + - test/** + +linter: + rules: + # these rules are documented on and in the same order as + # the Dart Lint rules page to make maintenance easier + # https://github.com/dart-lang/linter/blob/master/example/all.yaml + - always_use_package_imports + - avoid_empty_else + - avoid_relative_lib_imports + - avoid_slow_async_io + - avoid_types_as_parameter_names + - cancel_subscriptions + - close_sinks + - control_flow_in_finally + - empty_statements + - hash_and_equals + - invariant_booleans + - iterable_contains_unrelated_type + - list_remove_unrelated_type + - literal_only_boolean_expressions + - no_adjacent_strings_in_list + - no_duplicate_case_values + - no_logic_in_create_state + - prefer_void_to_null + - test_types_in_equals + - throw_in_finally + - unnecessary_statements + - unrelated_type_equality_checks + - omit_local_variable_types + - use_key_in_widget_constructors + - valid_regexps + - always_declare_return_types + - always_require_non_null_named_parameters + - annotate_overrides + - avoid_bool_literals_in_conditional_expressions + - avoid_catching_errors + - avoid_init_to_null + - avoid_null_checks_in_equality_operators + - avoid_positional_boolean_parameters + - avoid_private_typedef_functions + - avoid_redundant_argument_values + - avoid_return_types_on_setters + - avoid_returning_null_for_void + - avoid_shadowing_type_parameters + - avoid_single_cascade_in_expression_statements + - avoid_unnecessary_containers + - avoid_unused_constructor_parameters + - await_only_futures + - camel_case_extensions + - camel_case_types + - cascade_invocations + + - constant_identifier_names + - curly_braces_in_flow_control_structures + - directives_ordering + - empty_catches + - empty_constructor_bodies + - exhaustive_cases + - file_names + - implementation_imports + - join_return_with_assignment + - leading_newlines_in_multiline_strings + - library_names + - library_prefixes + - lines_longer_than_80_chars + - missing_whitespace_between_adjacent_strings + - non_constant_identifier_names + - null_closures + - one_member_abstracts + - only_throw_errors + - package_api_docs + - package_prefixed_library_names + - parameter_assignments + - prefer_adjacent_string_concatenation + - prefer_asserts_in_initializer_lists + - prefer_asserts_with_message + - prefer_collection_literals + - prefer_conditional_assignment + - prefer_const_constructors + - prefer_const_constructors_in_immutables + - prefer_const_declarations + - prefer_const_literals_to_create_immutables + - prefer_constructors_over_static_methods + - prefer_contains + - prefer_equal_for_default_values + - prefer_expression_function_bodies + - prefer_final_fields + - prefer_final_in_for_each + - prefer_final_locals + - prefer_function_declarations_over_variables + - prefer_generic_function_type_aliases + - prefer_if_elements_to_conditional_expressions + - prefer_if_null_operators + - prefer_initializing_formals + - prefer_inlined_adds + - prefer_int_literals + - prefer_interpolation_to_compose_strings + - prefer_is_empty + - prefer_is_not_empty + - prefer_is_not_operator + - prefer_null_aware_operators + - prefer_single_quotes + - prefer_spread_collections + - prefer_typing_uninitialized_variables + - provide_deprecation_message + - public_member_api_docs + - recursive_getters + - sized_box_for_whitespace + - slash_for_doc_comments + - sort_child_properties_last + - sort_constructors_first + - sort_unnamed_constructors_first + + - type_annotate_public_apis + - type_init_formals + - unnecessary_await_in_return + - unnecessary_brace_in_string_interps + - unnecessary_const + - unnecessary_getters_setters + - unnecessary_lambdas + - unnecessary_new + - unnecessary_null_aware_assignments + - unnecessary_null_in_if_null_operators + - unnecessary_nullable_for_final_variable_declarations + - unnecessary_parenthesis + - unnecessary_raw_strings + - unnecessary_string_escapes + - unnecessary_string_interpolations + - unnecessary_this + - use_is_even_rather_than_modulo + - use_late_for_private_fields_and_variables + - use_rethrow_when_possible + - use_setters_to_change_properties + - use_to_and_as_if_applicable + - package_names + - sort_pub_dependencies + + - cast_nullable_to_non_nullable + - unnecessary_null_checks + - tighten_type_of_initializing_formals + - null_check_on_nullable_type_parameter diff --git a/packages/stream_chat_flutter_core/analysis_options.yaml b/packages/stream_chat_flutter_core/analysis_options.yaml new file mode 100644 index 000000000..f0a87ea5d --- /dev/null +++ b/packages/stream_chat_flutter_core/analysis_options.yaml @@ -0,0 +1,150 @@ +analyzer: + enable-experiment: + - extension-methods + exclude: + - lib/**/*.g.dart + - example/** + - lib/src/emoji + - lib/**/*.freezed.dart + - test/** + +linter: + rules: + # these rules are documented on and in the same order as + # the Dart Lint rules page to make maintenance easier + # https://github.com/dart-lang/linter/blob/master/example/all.yaml + - always_use_package_imports + - avoid_empty_else + - avoid_relative_lib_imports + - avoid_slow_async_io + - avoid_types_as_parameter_names + - cancel_subscriptions + - close_sinks + - control_flow_in_finally + - empty_statements + - hash_and_equals + - invariant_booleans + - iterable_contains_unrelated_type + - list_remove_unrelated_type + - literal_only_boolean_expressions + - no_adjacent_strings_in_list + - no_duplicate_case_values + - no_logic_in_create_state + - prefer_void_to_null + - test_types_in_equals + - throw_in_finally + - unnecessary_statements + - unrelated_type_equality_checks + - omit_local_variable_types + - use_key_in_widget_constructors + - valid_regexps + - always_declare_return_types + - always_require_non_null_named_parameters + - annotate_overrides + - avoid_bool_literals_in_conditional_expressions + - avoid_catching_errors + - avoid_init_to_null + - avoid_null_checks_in_equality_operators + - avoid_positional_boolean_parameters + - avoid_private_typedef_functions + - avoid_redundant_argument_values + - avoid_return_types_on_setters + - avoid_returning_null_for_void + - avoid_shadowing_type_parameters + - avoid_single_cascade_in_expression_statements + - avoid_unnecessary_containers + - avoid_unused_constructor_parameters + - await_only_futures + - camel_case_extensions + - camel_case_types + - cascade_invocations + + - constant_identifier_names + - curly_braces_in_flow_control_structures + - directives_ordering + - empty_catches + - empty_constructor_bodies + - exhaustive_cases + - file_names + - implementation_imports + - join_return_with_assignment + - leading_newlines_in_multiline_strings + - library_names + - library_prefixes + - lines_longer_than_80_chars + - missing_whitespace_between_adjacent_strings + - non_constant_identifier_names + - null_closures + - one_member_abstracts + - only_throw_errors + - package_api_docs + - package_prefixed_library_names + - parameter_assignments + - prefer_adjacent_string_concatenation + - prefer_asserts_in_initializer_lists + - prefer_asserts_with_message + - prefer_collection_literals + - prefer_conditional_assignment + - prefer_const_constructors + - prefer_const_constructors_in_immutables + - prefer_const_declarations + - prefer_const_literals_to_create_immutables + - prefer_constructors_over_static_methods + - prefer_contains + - prefer_equal_for_default_values + - prefer_expression_function_bodies + - prefer_final_fields + - prefer_final_in_for_each + - prefer_final_locals + - prefer_function_declarations_over_variables + - prefer_generic_function_type_aliases + - prefer_if_elements_to_conditional_expressions + - prefer_if_null_operators + - prefer_initializing_formals + - prefer_inlined_adds + - prefer_int_literals + - prefer_interpolation_to_compose_strings + - prefer_is_empty + - prefer_is_not_empty + - prefer_is_not_operator + - prefer_null_aware_operators + - prefer_single_quotes + - prefer_spread_collections + - prefer_typing_uninitialized_variables + - provide_deprecation_message + - public_member_api_docs + - recursive_getters + - sized_box_for_whitespace + - slash_for_doc_comments + - sort_child_properties_last + - sort_constructors_first + - sort_unnamed_constructors_first + + - type_annotate_public_apis + - type_init_formals + - unnecessary_await_in_return + - unnecessary_brace_in_string_interps + - unnecessary_const + - unnecessary_getters_setters + - unnecessary_lambdas + - unnecessary_new + - unnecessary_null_aware_assignments + - unnecessary_null_in_if_null_operators + - unnecessary_nullable_for_final_variable_declarations + - unnecessary_parenthesis + - unnecessary_raw_strings + - unnecessary_string_escapes + - unnecessary_string_interpolations + - unnecessary_this + - use_is_even_rather_than_modulo + - use_late_for_private_fields_and_variables + - use_rethrow_when_possible + - use_setters_to_change_properties + - use_to_and_as_if_applicable + - package_names + - sort_pub_dependencies + + - cast_nullable_to_non_nullable + - unnecessary_null_checks + - tighten_type_of_initializing_formals + - null_check_on_nullable_type_parameter diff --git a/packages/stream_chat_persistence/analysis_options.yaml b/packages/stream_chat_persistence/analysis_options.yaml new file mode 100644 index 000000000..f0a87ea5d --- /dev/null +++ b/packages/stream_chat_persistence/analysis_options.yaml @@ -0,0 +1,150 @@ +analyzer: + enable-experiment: + - extension-methods + exclude: + - lib/**/*.g.dart + - example/** + - lib/src/emoji + - lib/**/*.freezed.dart + - test/** + +linter: + rules: + # these rules are documented on and in the same order as + # the Dart Lint rules page to make maintenance easier + # https://github.com/dart-lang/linter/blob/master/example/all.yaml + - always_use_package_imports + - avoid_empty_else + - avoid_relative_lib_imports + - avoid_slow_async_io + - avoid_types_as_parameter_names + - cancel_subscriptions + - close_sinks + - control_flow_in_finally + - empty_statements + - hash_and_equals + - invariant_booleans + - iterable_contains_unrelated_type + - list_remove_unrelated_type + - literal_only_boolean_expressions + - no_adjacent_strings_in_list + - no_duplicate_case_values + - no_logic_in_create_state + - prefer_void_to_null + - test_types_in_equals + - throw_in_finally + - unnecessary_statements + - unrelated_type_equality_checks + - omit_local_variable_types + - use_key_in_widget_constructors + - valid_regexps + - always_declare_return_types + - always_require_non_null_named_parameters + - annotate_overrides + - avoid_bool_literals_in_conditional_expressions + - avoid_catching_errors + - avoid_init_to_null + - avoid_null_checks_in_equality_operators + - avoid_positional_boolean_parameters + - avoid_private_typedef_functions + - avoid_redundant_argument_values + - avoid_return_types_on_setters + - avoid_returning_null_for_void + - avoid_shadowing_type_parameters + - avoid_single_cascade_in_expression_statements + - avoid_unnecessary_containers + - avoid_unused_constructor_parameters + - await_only_futures + - camel_case_extensions + - camel_case_types + - cascade_invocations + + - constant_identifier_names + - curly_braces_in_flow_control_structures + - directives_ordering + - empty_catches + - empty_constructor_bodies + - exhaustive_cases + - file_names + - implementation_imports + - join_return_with_assignment + - leading_newlines_in_multiline_strings + - library_names + - library_prefixes + - lines_longer_than_80_chars + - missing_whitespace_between_adjacent_strings + - non_constant_identifier_names + - null_closures + - one_member_abstracts + - only_throw_errors + - package_api_docs + - package_prefixed_library_names + - parameter_assignments + - prefer_adjacent_string_concatenation + - prefer_asserts_in_initializer_lists + - prefer_asserts_with_message + - prefer_collection_literals + - prefer_conditional_assignment + - prefer_const_constructors + - prefer_const_constructors_in_immutables + - prefer_const_declarations + - prefer_const_literals_to_create_immutables + - prefer_constructors_over_static_methods + - prefer_contains + - prefer_equal_for_default_values + - prefer_expression_function_bodies + - prefer_final_fields + - prefer_final_in_for_each + - prefer_final_locals + - prefer_function_declarations_over_variables + - prefer_generic_function_type_aliases + - prefer_if_elements_to_conditional_expressions + - prefer_if_null_operators + - prefer_initializing_formals + - prefer_inlined_adds + - prefer_int_literals + - prefer_interpolation_to_compose_strings + - prefer_is_empty + - prefer_is_not_empty + - prefer_is_not_operator + - prefer_null_aware_operators + - prefer_single_quotes + - prefer_spread_collections + - prefer_typing_uninitialized_variables + - provide_deprecation_message + - public_member_api_docs + - recursive_getters + - sized_box_for_whitespace + - slash_for_doc_comments + - sort_child_properties_last + - sort_constructors_first + - sort_unnamed_constructors_first + + - type_annotate_public_apis + - type_init_formals + - unnecessary_await_in_return + - unnecessary_brace_in_string_interps + - unnecessary_const + - unnecessary_getters_setters + - unnecessary_lambdas + - unnecessary_new + - unnecessary_null_aware_assignments + - unnecessary_null_in_if_null_operators + - unnecessary_nullable_for_final_variable_declarations + - unnecessary_parenthesis + - unnecessary_raw_strings + - unnecessary_string_escapes + - unnecessary_string_interpolations + - unnecessary_this + - use_is_even_rather_than_modulo + - use_late_for_private_fields_and_variables + - use_rethrow_when_possible + - use_setters_to_change_properties + - use_to_and_as_if_applicable + - package_names + - sort_pub_dependencies + + - cast_nullable_to_non_nullable + - unnecessary_null_checks + - tighten_type_of_initializing_formals + - null_check_on_nullable_type_parameter From 80cbb266d2f8e85386143bc7f4a3adc1d9edb834 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Wed, 19 May 2021 13:45:22 +0200 Subject: [PATCH 05/11] fix tests --- packages/stream_chat/lib/src/client.dart | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/stream_chat/lib/src/client.dart b/packages/stream_chat/lib/src/client.dart index b6efb6a5e..05f2559be 100644 --- a/packages/stream_chat/lib/src/client.dart +++ b/packages/stream_chat/lib/src/client.dart @@ -1489,7 +1489,7 @@ class ClientState { void _updateUser(User? user) => _updateUsers([user]); /// The current user - OwnUser? get user => _userController.value; + OwnUser? get user => _userController.valueOrNull; /// The current user as a stream Stream get userStream => _userController.stream; @@ -1501,13 +1501,13 @@ class ClientState { Stream> get usersStream => _usersController.stream; /// The current unread channels count - int? get unreadChannels => _unreadChannelsController.value; + int? get unreadChannels => _unreadChannelsController.valueOrNull; /// The current unread channels count as a stream Stream get unreadChannelsStream => _unreadChannelsController.stream; /// The current total unread messages count - int? get totalUnreadCount => _totalUnreadCountController.value; + int? get totalUnreadCount => _totalUnreadCountController.valueOrNull; /// The current total unread messages count as a stream Stream get totalUnreadCountStream => _totalUnreadCountController.stream; From d5820d25d9d2b56a8927ee7eec8402e1a0fe328d Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Wed, 19 May 2021 13:50:25 +0200 Subject: [PATCH 06/11] fix rxdart --- .../stream_chat_flutter_core/lib/src/message_search_bloc.dart | 3 ++- packages/stream_chat_flutter_core/lib/src/users_bloc.dart | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/stream_chat_flutter_core/lib/src/message_search_bloc.dart b/packages/stream_chat_flutter_core/lib/src/message_search_bloc.dart index 70e6df116..daffadfe0 100644 --- a/packages/stream_chat_flutter_core/lib/src/message_search_bloc.dart +++ b/packages/stream_chat_flutter_core/lib/src/message_search_bloc.dart @@ -44,7 +44,8 @@ class MessageSearchBlocState extends State late StreamChatCoreState _streamChatCoreState; /// The current messages list - List? get messageResponses => _messageResponses.value; + List? get messageResponses => + _messageResponses.valueOrNull; /// The current messages list as a stream Stream> get messagesStream => diff --git a/packages/stream_chat_flutter_core/lib/src/users_bloc.dart b/packages/stream_chat_flutter_core/lib/src/users_bloc.dart index 0c0d46cd5..1806ec36a 100644 --- a/packages/stream_chat_flutter_core/lib/src/users_bloc.dart +++ b/packages/stream_chat_flutter_core/lib/src/users_bloc.dart @@ -43,7 +43,7 @@ class UsersBloc extends StatefulWidget { class UsersBlocState extends State with AutomaticKeepAliveClientMixin { /// The current users list - List? get users => _usersController.value; + List? get users => _usersController.valueOrNull; /// The current users list as a stream Stream> get usersStream => _usersController.stream; From 9e71299cb686e4dd2b384fe8ef8b4b8ea65bcc54 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Wed, 19 May 2021 14:30:48 +0200 Subject: [PATCH 07/11] remove transform --- .../lib/src/message_input.dart | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/packages/stream_chat_flutter/lib/src/message_input.dart b/packages/stream_chat_flutter/lib/src/message_input.dart index ed0989036..c71fd3414 100644 --- a/packages/stream_chat_flutter/lib/src/message_input.dart +++ b/packages/stream_chat_flutter/lib/src/message_input.dart @@ -1473,16 +1473,12 @@ class MessageInputState extends State { final containsUrl = widget.quotedMessage!.attachments .any((element) => element.ogScrapeUrl != null) == true; - return Transform( - transform: Matrix4.rotationY(pi), - alignment: Alignment.center, - child: QuotedMessageWidget( - reverse: true, - showBorder: !containsUrl, - message: widget.quotedMessage!, - messageTheme: StreamChatTheme.of(context).otherMessageTheme, - padding: const EdgeInsets.fromLTRB(8, 8, 8, 0), - ), + return QuotedMessageWidget( + reverse: true, + showBorder: !containsUrl, + message: widget.quotedMessage!, + messageTheme: StreamChatTheme.of(context).otherMessageTheme, + padding: const EdgeInsets.fromLTRB(8, 8, 8, 0), ); } From 99562d9ba4e076f6e96cc6507ae77a578bedf0d8 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Wed, 19 May 2021 15:01:50 +0200 Subject: [PATCH 08/11] fix quoted message --- packages/stream_chat_flutter/lib/src/message_input.dart | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/stream_chat_flutter/lib/src/message_input.dart b/packages/stream_chat_flutter/lib/src/message_input.dart index c71fd3414..91f16b7b6 100644 --- a/packages/stream_chat_flutter/lib/src/message_input.dart +++ b/packages/stream_chat_flutter/lib/src/message_input.dart @@ -1474,7 +1474,6 @@ class MessageInputState extends State { .any((element) => element.ogScrapeUrl != null) == true; return QuotedMessageWidget( - reverse: true, showBorder: !containsUrl, message: widget.quotedMessage!, messageTheme: StreamChatTheme.of(context).otherMessageTheme, From be0378e4f0351914181917e096bcca74734f8790 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Wed, 19 May 2021 15:14:36 +0200 Subject: [PATCH 09/11] fix quoted message --- .../lib/src/message_input.dart | 1 + .../lib/src/quoted_message_widget.dart | 31 ++++++++++--------- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/packages/stream_chat_flutter/lib/src/message_input.dart b/packages/stream_chat_flutter/lib/src/message_input.dart index 91f16b7b6..c71fd3414 100644 --- a/packages/stream_chat_flutter/lib/src/message_input.dart +++ b/packages/stream_chat_flutter/lib/src/message_input.dart @@ -1474,6 +1474,7 @@ class MessageInputState extends State { .any((element) => element.ogScrapeUrl != null) == true; return QuotedMessageWidget( + reverse: true, showBorder: !containsUrl, message: widget.quotedMessage!, messageTheme: StreamChatTheme.of(context).otherMessageTheme, diff --git a/packages/stream_chat_flutter/lib/src/quoted_message_widget.dart b/packages/stream_chat_flutter/lib/src/quoted_message_widget.dart index a7c7c7988..4b45494cd 100644 --- a/packages/stream_chat_flutter/lib/src/quoted_message_widget.dart +++ b/packages/stream_chat_flutter/lib/src/quoted_message_widget.dart @@ -102,21 +102,24 @@ class QuotedMessageWidget extends StatelessWidget { bool get _containsText => message.text?.isNotEmpty == true; @override - Widget build(BuildContext context) => Padding( - padding: padding, - child: InkWell( - onTap: onTap, - child: Row( - crossAxisAlignment: CrossAxisAlignment.end, - mainAxisSize: MainAxisSize.min, - children: [ - Flexible(child: _buildMessage(context)), - const SizedBox(width: 8), - if (message.user != null) _buildUserAvatar(), - ], - ), + Widget build(BuildContext context) { + final children = [ + Flexible(child: _buildMessage(context)), + const SizedBox(width: 8), + if (message.user != null) _buildUserAvatar(), + ]; + return Padding( + padding: padding, + child: InkWell( + onTap: onTap, + child: Row( + crossAxisAlignment: CrossAxisAlignment.end, + mainAxisSize: MainAxisSize.min, + children: reverse ? children.reversed.toList() : children, ), - ); + ), + ); + } Widget _buildMessage(BuildContext context) { final isOnlyEmoji = message.text!.isOnlyEmoji; From 52739738c3dec37a2352172bc38a0c31ac2d7cd4 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Wed, 19 May 2021 15:29:58 +0200 Subject: [PATCH 10/11] fix quoted message --- .../lib/src/quoted_message_widget.dart | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/stream_chat_flutter/lib/src/quoted_message_widget.dart b/packages/stream_chat_flutter/lib/src/quoted_message_widget.dart index 4b45494cd..07a820b92 100644 --- a/packages/stream_chat_flutter/lib/src/quoted_message_widget.dart +++ b/packages/stream_chat_flutter/lib/src/quoted_message_widget.dart @@ -157,10 +157,11 @@ class QuotedMessageWidget extends StatelessWidget { color: StreamChatTheme.of(context).colorTheme.greyGainsboro, ) : null, - borderRadius: const BorderRadius.only( - topRight: Radius.circular(12), - topLeft: Radius.circular(12), - bottomLeft: Radius.circular(12), + borderRadius: BorderRadius.only( + topRight: const Radius.circular(12), + topLeft: const Radius.circular(12), + bottomRight: reverse ? const Radius.circular(12) : Radius.zero, + bottomLeft: reverse ? Radius.zero : const Radius.circular(12), ), ), padding: const EdgeInsets.all(8), From 4c90b7229fde6746ec1c1ad95a208d6cffe7b910 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Wed, 19 May 2021 15:58:49 +0200 Subject: [PATCH 11/11] remove prints --- .../stream_chat_flutter_core/lib/src/channel_list_core.dart | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/stream_chat_flutter_core/lib/src/channel_list_core.dart b/packages/stream_chat_flutter_core/lib/src/channel_list_core.dart index dbd572699..a3be273dc 100644 --- a/packages/stream_chat_flutter_core/lib/src/channel_list_core.dart +++ b/packages/stream_chat_flutter_core/lib/src/channel_list_core.dart @@ -132,8 +132,6 @@ class ChannelListCoreState extends State { stream: channelsBlocState.channelsStream, builder: (context, snapshot) { if (snapshot.hasError) { - print(snapshot.error); - print(snapshot.stackTrace); return widget.errorBuilder(context, snapshot.error!); } if (!snapshot.hasData) {