diff --git a/docusaurus/docs/Flutter/guides/migration_guide_4_0.mdx b/docusaurus/docs/Flutter/guides/migration_guide_4_0.mdx index 28a43ca1..887cef3a 100644 --- a/docusaurus/docs/Flutter/guides/migration_guide_4_0.mdx +++ b/docusaurus/docs/Flutter/guides/migration_guide_4_0.mdx @@ -1,7 +1,7 @@ --- id: migration_guide_4_0 sidebar_position: 14 -title: Migration Guide For The Stream Chat Flutter SDK v4.0 +title: Migration Guide v4.0 --- **Version 4.0.0** of the Stream Chat Flutter SDK carries significant architectural changes to improve the developer experience by giving you more control and flexibility in how you use our core components and UI widgets. @@ -44,7 +44,7 @@ See the sections below on “deprecated classes” for a complete list of change This section highlights functionality removed. -## Removed methods and classes +### Removed Methods And Classes In version 4 we removed the following deprecated methods and classes: @@ -733,7 +733,7 @@ The controller makes it much simpler to dynamically modify the message input. ## Stream Chat Flutter Core -Various changes have been made to the Core package, most notably, the indroduction of all of the controllers mentioned above: +Various changes have been made to the Core package, most notably, the indroduction of all of the controllers mentioned above. These controllers replace the business logic implementations (Bloc). Please note that this is not related to the well-known Flutter Bloc package, but instead refers to the naming we used for our business logic components. diff --git a/packages/stream_chat/lib/src/core/models/attachment_file.freezed.dart b/packages/stream_chat/lib/src/core/models/attachment_file.freezed.dart index 634af64f..f6442a53 100644 --- a/packages/stream_chat/lib/src/core/models/attachment_file.freezed.dart +++ b/packages/stream_chat/lib/src/core/models/attachment_file.freezed.dart @@ -12,7 +12,7 @@ part of 'attachment_file.dart'; T _$identity(T value) => value; final _privateConstructorUsedError = UnsupportedError( - 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more informations: https://github.com/rrousselGit/freezed#custom-getters-and-methods'); + 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#custom-getters-and-methods'); UploadState _$UploadStateFromJson(Map json) { switch (json['runtimeType']) { @@ -31,39 +31,6 @@ UploadState _$UploadStateFromJson(Map json) { } } -/// @nodoc -class _$UploadStateTearOff { - const _$UploadStateTearOff(); - - Preparing preparing() { - return const Preparing(); - } - - InProgress inProgress({required int uploaded, required int total}) { - return InProgress( - uploaded: uploaded, - total: total, - ); - } - - Success success() { - return const Success(); - } - - Failed failed({required String error}) { - return Failed( - error: error, - ); - } - - UploadState fromJson(Map json) { - return UploadState.fromJson(json); - } -} - -/// @nodoc -const $UploadState = _$UploadStateTearOff(); - /// @nodoc mixin _$UploadState { @optionalTypeArgs @@ -154,7 +121,7 @@ class _$PreparingCopyWithImpl<$Res> extends _$UploadStateCopyWithImpl<$Res> /// @nodoc @JsonSerializable() class _$Preparing implements Preparing { - const _$Preparing({String? $type}) : $type = $type ?? 'preparing'; + const _$Preparing({final String? $type}) : $type = $type ?? 'preparing'; factory _$Preparing.fromJson(Map json) => _$$PreparingFromJson(json); @@ -173,6 +140,7 @@ class _$Preparing implements Preparing { (other.runtimeType == runtimeType && other is Preparing); } + @JsonKey(ignore: true) @override int get hashCode => runtimeType.hashCode; @@ -301,7 +269,7 @@ class _$InProgressCopyWithImpl<$Res> extends _$UploadStateCopyWithImpl<$Res> @JsonSerializable() class _$InProgress implements InProgress { const _$InProgress( - {required this.uploaded, required this.total, String? $type}) + {required this.uploaded, required this.total, final String? $type}) : $type = $type ?? 'inProgress'; factory _$InProgress.fromJson(Map json) => @@ -329,6 +297,7 @@ class _$InProgress implements InProgress { const DeepCollectionEquality().equals(other.total, total)); } + @JsonKey(ignore: true) @override int get hashCode => Object.hash( runtimeType, @@ -421,14 +390,14 @@ class _$InProgress implements InProgress { } abstract class InProgress implements UploadState { - const factory InProgress({required int uploaded, required int total}) = - _$InProgress; + const factory InProgress( + {required final int uploaded, required final int total}) = _$InProgress; factory InProgress.fromJson(Map json) = _$InProgress.fromJson; - int get uploaded; - int get total; + int get uploaded => throw _privateConstructorUsedError; + int get total => throw _privateConstructorUsedError; @JsonKey(ignore: true) $InProgressCopyWith get copyWith => throw _privateConstructorUsedError; @@ -453,7 +422,7 @@ class _$SuccessCopyWithImpl<$Res> extends _$UploadStateCopyWithImpl<$Res> /// @nodoc @JsonSerializable() class _$Success implements Success { - const _$Success({String? $type}) : $type = $type ?? 'success'; + const _$Success({final String? $type}) : $type = $type ?? 'success'; factory _$Success.fromJson(Map json) => _$$SuccessFromJson(json); @@ -472,6 +441,7 @@ class _$Success implements Success { (other.runtimeType == runtimeType && other is Success); } + @JsonKey(ignore: true) @override int get hashCode => runtimeType.hashCode; @@ -593,7 +563,7 @@ class _$FailedCopyWithImpl<$Res> extends _$UploadStateCopyWithImpl<$Res> /// @nodoc @JsonSerializable() class _$Failed implements Failed { - const _$Failed({required this.error, String? $type}) + const _$Failed({required this.error, final String? $type}) : $type = $type ?? 'failed'; factory _$Failed.fromJson(Map json) => @@ -618,6 +588,7 @@ class _$Failed implements Failed { const DeepCollectionEquality().equals(other.error, error)); } + @JsonKey(ignore: true) @override int get hashCode => Object.hash(runtimeType, const DeepCollectionEquality().hash(error)); @@ -708,11 +679,11 @@ class _$Failed implements Failed { } abstract class Failed implements UploadState { - const factory Failed({required String error}) = _$Failed; + const factory Failed({required final String error}) = _$Failed; factory Failed.fromJson(Map json) = _$Failed.fromJson; - String get error; + String get error => throw _privateConstructorUsedError; @JsonKey(ignore: true) $FailedCopyWith get copyWith => throw _privateConstructorUsedError; } diff --git a/packages/stream_chat_flutter/lib/src/info_tile.dart b/packages/stream_chat_flutter/lib/src/info_tile.dart index 86964bf0..fee76d5c 100644 --- a/packages/stream_chat_flutter/lib/src/info_tile.dart +++ b/packages/stream_chat_flutter/lib/src/info_tile.dart @@ -46,11 +46,13 @@ class StreamInfoTile extends StatelessWidget { @override Widget build(BuildContext context) { final chatThemeData = StreamChatTheme.of(context); - return PortalEntry( + return PortalTarget( visible: showMessage, - portalAnchor: tileAnchor ?? Alignment.topCenter, - childAnchor: childAnchor ?? Alignment.bottomCenter, - portal: Container( + anchor: Aligned( + follower: tileAnchor ?? Alignment.topCenter, + target: childAnchor ?? Alignment.bottomCenter, + ), + portalFollower: Container( height: 25, color: backgroundColor ?? chatThemeData.colorTheme.textLowEmphasis.withOpacity(0.9), diff --git a/packages/stream_chat_flutter/lib/src/message_widget.dart b/packages/stream_chat_flutter/lib/src/message_widget.dart index beabe77f..caf2722e 100644 --- a/packages/stream_chat_flutter/lib/src/message_widget.dart +++ b/packages/stream_chat_flutter/lib/src/message_widget.dart @@ -659,9 +659,9 @@ class _StreamMessageWidgetState extends State if (widget.showUserAvatar == DisplayWidget.hide) SizedBox(width: avatarWidth + 4), Flexible( - child: PortalEntry( + child: PortalTarget( visible: showReactions, - portal: showReactions + portalFollower: showReactions ? Container( transform: Matrix4.translationValues( @@ -677,10 +677,16 @@ class _StreamMessageWidgetState extends State ), ) : null, - portalAnchor: - Alignment(widget.reverse ? 1 : -1, -1), - childAnchor: - Alignment(widget.reverse ? -1 : 1, -1), + anchor: Aligned( + follower: Alignment( + widget.reverse ? 1 : -1, + -1, + ), + target: Alignment( + widget.reverse ? -1 : 1, + -1, + ), + ), child: Stack( clipBehavior: Clip.none, children: [ diff --git a/packages/stream_chat_flutter/lib/src/multi_overlay.dart b/packages/stream_chat_flutter/lib/src/multi_overlay.dart index bd1ed387..71ed18d2 100644 --- a/packages/stream_chat_flutter/lib/src/multi_overlay.dart +++ b/packages/stream_chat_flutter/lib/src/multi_overlay.dart @@ -41,11 +41,13 @@ class StreamMultiOverlay extends StatelessWidget { final visibleOverlay = overlayOptions.firstWhereOrNull((element) => element.visible); - return PortalEntry( - childAnchor: childAnchor, - portalAnchor: overlayAnchor, + return PortalTarget( + anchor: Aligned( + follower: overlayAnchor ?? Alignment.center, + target: childAnchor ?? Alignment.center, + ), visible: visibleOverlay != null, - portal: visibleOverlay?.widget, + portalFollower: visibleOverlay?.widget, child: child, ); } diff --git a/packages/stream_chat_flutter/pubspec.yaml b/packages/stream_chat_flutter/pubspec.yaml index ac7a6c69..f01991c2 100644 --- a/packages/stream_chat_flutter/pubspec.yaml +++ b/packages/stream_chat_flutter/pubspec.yaml @@ -21,7 +21,7 @@ dependencies: flutter: sdk: flutter flutter_markdown: ^0.6.1 - flutter_portal: ^0.4.0 + flutter_portal: ^1.0.0 flutter_slidable: ^1.2.0 flutter_svg: ^1.0.1 http_parser: ^4.0.0 diff --git a/packages/stream_chat_persistence/lib/src/db/drift_chat_database.g.dart b/packages/stream_chat_persistence/lib/src/db/drift_chat_database.g.dart index d0565973..e5382861 100644 --- a/packages/stream_chat_persistence/lib/src/db/drift_chat_database.g.dart +++ b/packages/stream_chat_persistence/lib/src/db/drift_chat_database.g.dart @@ -390,9 +390,10 @@ class ChannelsCompanion extends UpdateCompanion { class $ChannelsTable extends Channels with TableInfo<$ChannelsTable, ChannelEntity> { - final GeneratedDatabase _db; + @override + final GeneratedDatabase attachedDatabase; final String? _alias; - $ChannelsTable(this._db, [this._alias]); + $ChannelsTable(this.attachedDatabase, [this._alias]); final VerificationMeta _idMeta = const VerificationMeta('id'); @override late final GeneratedColumn id = GeneratedColumn( @@ -557,7 +558,7 @@ class $ChannelsTable extends Channels @override $ChannelsTable createAlias(String alias) { - return $ChannelsTable(_db, alias); + return $ChannelsTable(attachedDatabase, alias); } static TypeConverter, String> $converter0 = @@ -1337,9 +1338,10 @@ class MessagesCompanion extends UpdateCompanion { class $MessagesTable extends Messages with TableInfo<$MessagesTable, MessageEntity> { - final GeneratedDatabase _db; + @override + final GeneratedDatabase attachedDatabase; final String? _alias; - $MessagesTable(this._db, [this._alias]); + $MessagesTable(this.attachedDatabase, [this._alias]); final VerificationMeta _idMeta = const VerificationMeta('id'); @override late final GeneratedColumn id = GeneratedColumn( @@ -1647,7 +1649,7 @@ class $MessagesTable extends Messages @override $MessagesTable createAlias(String alias) { - return $MessagesTable(_db, alias); + return $MessagesTable(attachedDatabase, alias); } static TypeConverter, String> $converter0 = @@ -2442,9 +2444,10 @@ class PinnedMessagesCompanion extends UpdateCompanion { class $PinnedMessagesTable extends PinnedMessages with TableInfo<$PinnedMessagesTable, PinnedMessageEntity> { - final GeneratedDatabase _db; + @override + final GeneratedDatabase attachedDatabase; final String? _alias; - $PinnedMessagesTable(this._db, [this._alias]); + $PinnedMessagesTable(this.attachedDatabase, [this._alias]); final VerificationMeta _idMeta = const VerificationMeta('id'); @override late final GeneratedColumn id = GeneratedColumn( @@ -2755,7 +2758,7 @@ class $PinnedMessagesTable extends PinnedMessages @override $PinnedMessagesTable createAlias(String alias) { - return $PinnedMessagesTable(_db, alias); + return $PinnedMessagesTable(attachedDatabase, alias); } static TypeConverter, String> $converter0 = @@ -3005,9 +3008,10 @@ class PinnedMessageReactionsCompanion class $PinnedMessageReactionsTable extends PinnedMessageReactions with TableInfo<$PinnedMessageReactionsTable, PinnedMessageReactionEntity> { - final GeneratedDatabase _db; + @override + final GeneratedDatabase attachedDatabase; final String? _alias; - $PinnedMessageReactionsTable(this._db, [this._alias]); + $PinnedMessageReactionsTable(this.attachedDatabase, [this._alias]); final VerificationMeta _userIdMeta = const VerificationMeta('userId'); @override late final GeneratedColumn userId = GeneratedColumn( @@ -3100,7 +3104,7 @@ class $PinnedMessageReactionsTable extends PinnedMessageReactions @override $PinnedMessageReactionsTable createAlias(String alias) { - return $PinnedMessageReactionsTable(_db, alias); + return $PinnedMessageReactionsTable(attachedDatabase, alias); } static TypeConverter, String> $converter0 = @@ -3334,9 +3338,10 @@ class ReactionsCompanion extends UpdateCompanion { class $ReactionsTable extends Reactions with TableInfo<$ReactionsTable, ReactionEntity> { - final GeneratedDatabase _db; + @override + final GeneratedDatabase attachedDatabase; final String? _alias; - $ReactionsTable(this._db, [this._alias]); + $ReactionsTable(this.attachedDatabase, [this._alias]); final VerificationMeta _userIdMeta = const VerificationMeta('userId'); @override late final GeneratedColumn userId = GeneratedColumn( @@ -3426,7 +3431,7 @@ class $ReactionsTable extends Reactions @override $ReactionsTable createAlias(String alias) { - return $ReactionsTable(_db, alias); + return $ReactionsTable(attachedDatabase, alias); } static TypeConverter, String> $converter0 = @@ -3736,9 +3741,10 @@ class UsersCompanion extends UpdateCompanion { } class $UsersTable extends Users with TableInfo<$UsersTable, UserEntity> { - final GeneratedDatabase _db; + @override + final GeneratedDatabase attachedDatabase; final String? _alias; - $UsersTable(this._db, [this._alias]); + $UsersTable(this.attachedDatabase, [this._alias]); final VerificationMeta _idMeta = const VerificationMeta('id'); @override late final GeneratedColumn id = GeneratedColumn( @@ -3865,7 +3871,7 @@ class $UsersTable extends Users with TableInfo<$UsersTable, UserEntity> { @override $UsersTable createAlias(String alias) { - return $UsersTable(_db, alias); + return $UsersTable(attachedDatabase, alias); } static TypeConverter, String> $converter0 = @@ -4235,9 +4241,10 @@ class MembersCompanion extends UpdateCompanion { class $MembersTable extends Members with TableInfo<$MembersTable, MemberEntity> { - final GeneratedDatabase _db; + @override + final GeneratedDatabase attachedDatabase; final String? _alias; - $MembersTable(this._db, [this._alias]); + $MembersTable(this.attachedDatabase, [this._alias]); final VerificationMeta _userIdMeta = const VerificationMeta('userId'); @override late final GeneratedColumn userId = GeneratedColumn( @@ -4409,7 +4416,7 @@ class $MembersTable extends Members @override $MembersTable createAlias(String alias) { - return $MembersTable(_db, alias); + return $MembersTable(attachedDatabase, alias); } } @@ -4585,9 +4592,10 @@ class ReadsCompanion extends UpdateCompanion { } class $ReadsTable extends Reads with TableInfo<$ReadsTable, ReadEntity> { - final GeneratedDatabase _db; + @override + final GeneratedDatabase attachedDatabase; final String? _alias; - $ReadsTable(this._db, [this._alias]); + $ReadsTable(this.attachedDatabase, [this._alias]); final VerificationMeta _lastReadMeta = const VerificationMeta('lastRead'); @override late final GeneratedColumn lastRead = GeneratedColumn( @@ -4664,7 +4672,7 @@ class $ReadsTable extends Reads with TableInfo<$ReadsTable, ReadEntity> { @override $ReadsTable createAlias(String alias) { - return $ReadsTable(_db, alias); + return $ReadsTable(attachedDatabase, alias); } } @@ -4789,9 +4797,10 @@ class ChannelQueriesCompanion extends UpdateCompanion { class $ChannelQueriesTable extends ChannelQueries with TableInfo<$ChannelQueriesTable, ChannelQueryEntity> { - final GeneratedDatabase _db; + @override + final GeneratedDatabase attachedDatabase; final String? _alias; - $ChannelQueriesTable(this._db, [this._alias]); + $ChannelQueriesTable(this.attachedDatabase, [this._alias]); final VerificationMeta _queryHashMeta = const VerificationMeta('queryHash'); @override late final GeneratedColumn queryHash = GeneratedColumn( @@ -4840,7 +4849,7 @@ class $ChannelQueriesTable extends ChannelQueries @override $ChannelQueriesTable createAlias(String alias) { - return $ChannelQueriesTable(_db, alias); + return $ChannelQueriesTable(attachedDatabase, alias); } } @@ -5105,9 +5114,10 @@ class ConnectionEventsCompanion extends UpdateCompanion { class $ConnectionEventsTable extends ConnectionEvents with TableInfo<$ConnectionEventsTable, ConnectionEventEntity> { - final GeneratedDatabase _db; + @override + final GeneratedDatabase attachedDatabase; final String? _alias; - $ConnectionEventsTable(this._db, [this._alias]); + $ConnectionEventsTable(this.attachedDatabase, [this._alias]); final VerificationMeta _idMeta = const VerificationMeta('id'); @override late final GeneratedColumn id = GeneratedColumn( @@ -5215,7 +5225,7 @@ class $ConnectionEventsTable extends ConnectionEvents @override $ConnectionEventsTable createAlias(String alias) { - return $ConnectionEventsTable(_db, alias); + return $ConnectionEventsTable(attachedDatabase, alias); } static TypeConverter, String> $converter0 = diff --git a/packages/stream_chat_persistence/pubspec.yaml b/packages/stream_chat_persistence/pubspec.yaml index 05872dab..839888ad 100644 --- a/packages/stream_chat_persistence/pubspec.yaml +++ b/packages/stream_chat_persistence/pubspec.yaml @@ -10,7 +10,7 @@ environment: flutter: ">=1.17.0" dependencies: - drift: ">=1.3.0 < 1.4.0" + drift: ^1.5.0 flutter: sdk: flutter logging: ^1.0.1 @@ -24,8 +24,8 @@ dependencies: dev_dependencies: build_runner: ^2.0.1 dart_code_metrics: ^4.4.0 - drift_dev: ">=1.3.0 < 1.4.0" + drift_dev: ^1.5.2 flutter_test: sdk: flutter - mocktail: ^0.2.0 + mocktail: ^0.3.0 \ No newline at end of file