diff --git a/.github/workflows/dart_code_metrics.yaml b/.github/workflows/dart_code_metrics.yaml index a4296e8b..7e3e41fd 100644 --- a/.github/workflows/dart_code_metrics.yaml +++ b/.github/workflows/dart_code_metrics.yaml @@ -39,36 +39,36 @@ jobs: run: melos bootstrap - name: "Stream Chat Metrics" - uses: dart-code-checker/dart-code-metrics-action@v1 + uses: dart-code-checker/dart-code-metrics-action@v2.0.0 with: github_token: ${{ secrets.GITHUB_TOKEN }} relative_path: 'packages/stream_chat' folders: ${{ env.folders }} - name: "Stream Chat Flutter Core Metrics" - uses: dart-code-checker/dart-code-metrics-action@v1 + uses: dart-code-checker/dart-code-metrics-action@v2.0.0 with: github_token: ${{ secrets.GITHUB_TOKEN }} relative_path: 'packages/stream_chat_flutter_core' folders: ${{ env.folders }} - name: "Stream Chat Flutter Metrics" - uses: dart-code-checker/dart-code-metrics-action@v1 + uses: dart-code-checker/dart-code-metrics-action@v2.0.0 with: github_token: ${{ secrets.GITHUB_TOKEN }} relative_path: 'packages/stream_chat_flutter' folders: ${{ env.folders }} - name: "Stream Chat Localizations Metrics" - uses: dart-code-checker/dart-code-metrics-action@v1 + uses: dart-code-checker/dart-code-metrics-action@v2.0.0 with: github_token: ${{ secrets.GITHUB_TOKEN }} relative_path: 'packages/stream_chat_localizations' folders: ${{ env.folders }} - name: "Stream Chat Persistence Metrics" - uses: dart-code-checker/dart-code-metrics-action@v1 + uses: dart-code-checker/dart-code-metrics-action@v2.0.0 with: github_token: ${{ secrets.GITHUB_TOKEN }} relative_path: 'packages/stream_chat_persistence' - folders: ${{ env.folders }} \ No newline at end of file + folders: ${{ env.folders }} diff --git a/.github/workflows/scripts/remove-from-coverage.sh b/.github/workflows/scripts/remove-from-coverage.sh index c6850e89..0ea18f97 100755 --- a/.github/workflows/scripts/remove-from-coverage.sh +++ b/.github/workflows/scripts/remove-from-coverage.sh @@ -3,4 +3,4 @@ # Fast fail the script on failures. set -e -pub global run remove_from_coverage:remove_from_coverage -f coverage/lcov.info -r '\.g\.dart$' -r '\.freezed\.dart$' +flutter pub global run remove_from_coverage:remove_from_coverage -f coverage/lcov.info -r '\.g\.dart$' -r '\.freezed\.dart$' diff --git a/.github/workflows/stream_flutter_workflow.yml b/.github/workflows/stream_flutter_workflow.yml index 81039fd1..e9138e36 100644 --- a/.github/workflows/stream_flutter_workflow.yml +++ b/.github/workflows/stream_flutter_workflow.yml @@ -94,7 +94,7 @@ jobs: - name: "Install Tools" run: | flutter pub global activate melos ${{ env.melos_version }} - pub global activate remove_from_coverage + flutter pub global activate remove_from_coverage - name: "Bootstrap Workspace" run: melos bootstrap - name: "Flutter Test" diff --git a/analysis_options.yaml b/analysis_options.yaml index 336d222e..52f50e45 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -147,6 +147,21 @@ linter: - tighten_type_of_initializing_formals - null_check_on_nullable_type_parameter + - conditional_uri_does_not_exist + - secure_pubspec_urls + - sized_box_shrink_expand + - unnecessary_constructor_name + - unnecessary_late + - use_colored_box + - use_decorated_box + - use_enums + - use_super_parameters + - avoid_escaping_inner_quotes + - unnecessary_overrides + - prefer_null_aware_method_calls + - use_named_constants + - use_raw_strings + # https://dartcodemetrics.dev/docs/getting-started/introduction dart_code_metrics: rules: diff --git a/docusaurus/docs/Flutter/guides/error_reporting_with_sentry.mdx b/docusaurus/docs/Flutter/guides/error_reporting_with_sentry.mdx new file mode 100644 index 00000000..a192a613 --- /dev/null +++ b/docusaurus/docs/Flutter/guides/error_reporting_with_sentry.mdx @@ -0,0 +1,144 @@ +--- +id: error_reporting_with_sentry +sidebar_position: 15 +title: Error Reporting With Sentry +--- + +Error Reporting With Sentry + +## Introduction + +While one always tries to create apps that are free of bugs, they're sure to crop up from time to time. Since buggy apps lead to unhappy users and customers, it's important to understand how often your users experience bugs and where those bugs occur. That way, you can prioritize the bugs with the highest impact and work to fix them. + +Whenever an error occurs, create a report containing the error that occurred and the associated stack trace. You can then send the report to an error tracking service, such as [Sentry](https://sentry.io/), [Rollbar](https://rollbar.com/), or [Firebase Crashlytics](https://firebase.google.com/docs/crashlytics). + +The error tracking service aggregates all of the crashes your users experience and groups them together. This allows you to know how often your app fails and where your users run into trouble. + +In this guide, learn how to report Stream Chat errors to the [Sentry](https://sentry.io/welcome/) crash reporting service using the following steps. + +### 1. Get a DSN From Sentry + +Before reporting errors to Sentry, you need a “DSN” to uniquely identify your app with the Sentry service: +To get a DSN, use the following steps: + +- [Create an account with Sentry](https://sentry.io/signup/). +- Log in to the account. +- Create a new Flutter project. +- Copy the code snippet that includes the DSN. + +### 2. Import the Sentry package + +Import the `sentry_flutter` package into your app. The sentry package makes it easier to send error reports to the Sentry error tracking service. + +```yaml +dependencies: + sentry_flutter: +``` + +### 3. Initialize the Sentry SDK + +Initialize the SDK to capture different unhandled errors automatically. + +```dart +import 'package:sentry_flutter/sentry_flutter.dart'; + +Future main() async { + await SentryFlutter.init( + (options) => options.dsn = 'https://example@sentry.io/example', + appRunner: () => runApp(const MyApp()), + ); +} +``` + +Or, if you want to run your app in your own error zone, use `runZonedGuarded`: + +```dart +void main() async { + /// Captures errors reported by the Flutter framework. + FlutterError.onError = (FlutterErrorDetails details) { + if (kDebugMode) { + // In development mode, simply print to console. + FlutterError.dumpErrorToConsole(details); + } else { + // In production mode, report to the application zone to report to Sentry. + Zone.current.handleUncaughtError(details.exception, details.stack!); + } + }; + + Future _reportError(dynamic error, StackTrace stackTrace) async { + // Print the exception to the console. + if (kDebugMode) { + // Print the full stack trace in debug mode. + print(stackTrace); + return; + } else { + // Send the Exception and Stacktrace to sentry in Production mode. + await Sentry.captureException(error, stackTrace: stackTrace); + } + } + + runZonedGuarded( + () async { + await SentryFlutter.init( + (options) => options.dsn = 'https://example@sentry.io/example', + ); + runApp(const MyApp()); + }, + _reportError, + ); +} +``` + +Alternatively, you can pass the DSN to Flutter using the **dart-define** tag: + +```bash +--dart-define SENTRY_DSN=https://example@sentry.io/example +``` + +### 4. Integration With StreamChat Applications + +Override the default `logHandlerFunction` to send errors to Sentry. + +```dart +void sampleAppLogHandler(LogRecord record) async { + if (kDebugMode) StreamChatClient.defaultLogHandler(record); + + // Report errors to Sentry + if (record.error != null || record.stackTrace != null) { + await Sentry.captureException( + record.error, + stackTrace: record.stackTrace, + ); + } +} + +StreamChatClient buildStreamChatClient( + String apiKey, { + Level logLevel = Level.SEVERE, +}) { + return StreamChatClient( + apiKey, + logLevel: logLevel, + logHandlerFunction: sampleAppLogHandler, // Pass the overridden logHandlerFunction + ); +} +``` + +### 5. Capture Errors Programmatically + +Besides the automatic error reporting that Sentry generates by importing and initializing the SDK, +you can use the API to manually report errors to Sentry: + +```dart +await Sentry.captureException(exception, stackTrace: stackTrace); +``` + +For more information, see the [Sentry API](https://pub.dev/documentation/sentry_flutter/latest/sentry_flutter/sentry_flutter-library.html) docs on Pub. + +### Complete Example + +To view a working example, see the [Stream Sample app](https://github.com/GetStream/flutter-samples/tree/main/packages/stream_chat_v1). + +### Learn More + +Extensive documentation about using the Sentry SDK can be found on [Sentry's site](https://docs.sentry.io/platforms/flutter/). diff --git a/melos b/melos deleted file mode 100644 index e69de29b..00000000 diff --git a/melos.yaml b/melos.yaml index 4e1c08ac..10e7ca7b 100644 --- a/melos.yaml +++ b/melos.yaml @@ -1,4 +1,5 @@ name: stream_chat_flutter +repository: https://github.com/GetStream/stream-chat-flutter versioning: mode: independent @@ -7,6 +8,10 @@ packages: - packages/** scripts: + postclean: + run: melos run clean:flutter --no-select + description: Runs "flutter clean" in all Flutter packages + lint:all: run: melos run analyze && melos run format description: Run all static analysis checks @@ -74,6 +79,12 @@ scripts: flutter: true dir-exists: test + clean:flutter: + run: melos exec -c 4 --fail-fast -- "flutter clean" + description: Run Flutter clean for a specific package in this project. + select-package: + flutter: true + coverage:ignore-file: run: | melos exec -c 5 --fail-fast -- "\$MELOS_ROOT_PATH/.github/workflows/scripts/remove-from-coverage.sh" @@ -91,5 +102,5 @@ dev_dependencies: dart_code_metrics: ^4.4.0 environment: - sdk: '>=2.12.0 <3.0.0' - flutter: '>=1.17.0 <2.0.0' \ No newline at end of file + sdk: '>=2.17.0 <3.0.0' + flutter: '>=1.17.0 <3.0.0' \ No newline at end of file diff --git a/packages/stream_chat/CHANGELOG.md b/packages/stream_chat/CHANGELOG.md index 7609e0c3..df797b1d 100644 --- a/packages/stream_chat/CHANGELOG.md +++ b/packages/stream_chat/CHANGELOG.md @@ -1,3 +1,25 @@ +## 4.2.0 + +✅ Added + +- Added `PaginationParams.createdAtAfterOrEqual` for message pagination. +- Added `PaginationParams.createdAtAfter` for message pagination. +- Added `PaginationParams.createdAtBeforeOrEqual` for message pagination. +- Added `PaginationParams.createdAtBefore` for message pagination. +- Added `PaginationParams.createdAtAround` for message pagination. +- Added support for `channel.disabled`, `channel.hidden` and `channel.truncatedAt` in `Channel`. +- Added support for `channel.membership` and `channel.membershipStream` in `Channel`. +- `Channel` now listens for `member.updated` events and updates the `Channel.members` accordingly. + +🔄 Changed + +- Deprecated `PaginationParams.before` and `PaginationParams.after`. Use `PaginationParams.limit` instead. + +🐞 Fixed + +- [[#1147]](https://github.com/GetStream/stream-chat-flutter/issues/1147) `channel.unset` not updating the extra data + stream. + ## 4.1.0 ✅ Added diff --git a/packages/stream_chat/example/lib/main.dart b/packages/stream_chat/example/lib/main.dart index 629f4a32..8dde5c0d 100644 --- a/packages/stream_chat/example/lib/main.dart +++ b/packages/stream_chat/example/lib/main.dart @@ -43,10 +43,10 @@ class StreamExample extends StatelessWidget { /// To initialize this example, an instance of /// [client] and [channel] is required. const StreamExample({ - Key? key, + super.key, required this.client, required this.channel, - }) : super(key: key); + }); /// Instance of [StreamChatClient] we created earlier. /// This contains information about our application and connection state. @@ -67,9 +67,9 @@ class StreamExample extends StatelessWidget { class HomeScreen extends StatelessWidget { /// [HomeScreen] is constructed using the [Channel] we defined earlier. const HomeScreen({ - Key? key, + super.key, required this.channel, - }) : super(key: key); + }); /// Channel object containing the [Channel.id] we'd like to observe. final Channel channel; @@ -119,10 +119,10 @@ class HomeScreen extends StatelessWidget { class MessageView extends StatefulWidget { /// Message takes the latest list of messages and the current channel. const MessageView({ - Key? key, + super.key, required this.messages, required this.channel, - }) : super(key: key); + }); /// List of messages sent in the given channel. final List messages; diff --git a/packages/stream_chat/example/pubspec.yaml b/packages/stream_chat/example/pubspec.yaml index f3fad2d1..9faa8ec7 100644 --- a/packages/stream_chat/example/pubspec.yaml +++ b/packages/stream_chat/example/pubspec.yaml @@ -5,7 +5,7 @@ publish_to: "none" version: 1.0.0+1 environment: - sdk: '>=2.12.0 <3.0.0' + sdk: '>=2.17.0 <3.0.0' dependencies: cupertino_icons: ^1.0.0 diff --git a/packages/stream_chat/lib/src/client/channel.dart b/packages/stream_chat/lib/src/client/channel.dart index a27b672f..b4e1379d 100644 --- a/packages/stream_chat/lib/src/client/channel.dart +++ b/packages/stream_chat/lib/src/client/channel.dart @@ -171,6 +171,18 @@ class Channel { return state!.channelStateStream.map((cs) => cs.channel?.config); } + /// Relationship of the current user to this channel. + Member? get membership { + _checkInitialized(); + return state!._channelState.membership; + } + + /// Relationship of the current user to this channel as a stream. + Stream get membershipStream { + _checkInitialized(); + return state!.channelStateStream.map((cs) => cs.membership); + } + /// Channel user creator. User? get createdBy { _checkInitialized(); @@ -195,6 +207,42 @@ class Channel { return state!.channelStateStream.map((cs) => cs.channel?.frozen == true); } + /// Channel disabled status. + bool get disabled { + _checkInitialized(); + return state!._channelState.channel?.disabled == true; + } + + /// Channel disabled status as a stream. + Stream get disabledStream { + _checkInitialized(); + return state!.channelStateStream.map((cs) => cs.channel?.disabled == true); + } + + /// Channel hidden status. + bool get hidden { + _checkInitialized(); + return state!._channelState.channel?.hidden == true; + } + + /// Channel hidden status as a stream. + Stream get hiddenStream { + _checkInitialized(); + return state!.channelStateStream.map((cs) => cs.channel?.hidden == true); + } + + /// The last date at which the channel got truncated. + DateTime? get truncatedAt { + _checkInitialized(); + return state!._channelState.channel?.truncatedAt; + } + + /// The last date at which the channel got truncated as a stream. + Stream get truncatedAtStream { + _checkInitialized(); + return state!.channelStateStream.map((cs) => cs.channel?.truncatedAt); + } + /// Cooldown count int get cooldown { _checkInitialized(); @@ -1540,6 +1588,8 @@ class ChannelClientState { _listenMemberRemoved(); + _listenMemberUpdated(); + _listenMemberBanned(); _listenMemberUnbanned(); @@ -1632,6 +1682,18 @@ class ChannelClientState { })); } + void _listenMemberUpdated() { + _subscriptions.add(_channel.on(EventType.memberUpdated).listen((Event e) { + final member = e.member; + final existingMembers = channelState.members ?? []; + updateChannelState(channelState.copyWith( + members: existingMembers + .map((m) => m.userId == member!.userId ? member : m) + .toList(growable: false), + )); + })); + } + void _listenChannelUpdated() { _subscriptions.add(_channel.on(EventType.channelUpdated).listen((Event e) { final channel = e.channel!; @@ -2173,7 +2235,7 @@ class ChannelClientState { /// The channel threads related to this channel. Map> get threads => - _threadsController.value.map((key, value) => MapEntry(key, value)); + _threadsController.value.map(MapEntry.new); /// The channel threads related to this channel as a stream. Stream>> get threadsStream => diff --git a/packages/stream_chat/lib/src/core/api/device_api.dart b/packages/stream_chat/lib/src/core/api/device_api.dart index df137cdc..cc0a1952 100644 --- a/packages/stream_chat/lib/src/core/api/device_api.dart +++ b/packages/stream_chat/lib/src/core/api/device_api.dart @@ -10,15 +10,6 @@ enum PushProvider { apn, } -/// Helper extension for [PushProvider] -extension PushProviderX on PushProvider { - /// Returns the string notion for [PushProvider]. - String get name => { - PushProvider.apn: 'apn', - PushProvider.firebase: 'firebase', - }[this]!; -} - /// Defines the api dedicated to device operations class DeviceApi { /// Initialize a new device api diff --git a/packages/stream_chat/lib/src/core/api/requests.dart b/packages/stream_chat/lib/src/core/api/requests.dart index 3f4e79de..fa83ff73 100644 --- a/packages/stream_chat/lib/src/core/api/requests.dart +++ b/packages/stream_chat/lib/src/core/api/requests.dart @@ -1,3 +1,5 @@ +// ignore_for_file: deprecated_member_use_from_same_package + import 'package:equatable/equatable.dart'; import 'package:json_annotation/json_annotation.dart'; @@ -69,6 +71,11 @@ class PaginationParams extends Equatable { this.greaterThanOrEqual, this.lessThan, this.lessThanOrEqual, + this.createdAtAfterOrEqual, + this.createdAtAfter, + this.createdAtBeforeOrEqual, + this.createdAtBefore, + this.createdAtAround, }) : assert( offset == null || offset == 0 || next == null, 'Cannot specify non-zero `offset` with `next` parameter', @@ -82,9 +89,11 @@ class PaginationParams extends Equatable { final int limit; /// The amount of items requested before message ID from the APIs. + @Deprecated('before is deprecated, use limit instead') final int before; /// The amount of items requested after message ID from the APIs. + @Deprecated('after is deprecated, use limit instead') final int after; /// The offset of requesting items. @@ -113,6 +122,26 @@ class PaginationParams extends Equatable { @JsonKey(name: 'id_lte') final String? lessThanOrEqual; + /// Filter on createdAt greater than or equal the given value. + @JsonKey(name: 'created_at_after_or_equal') + final DateTime? createdAtAfterOrEqual; + + /// Filter on createdAt greater than the given value. + @JsonKey(name: 'created_at_after') + final DateTime? createdAtAfter; + + /// Filter on createdAt smaller than or equal the given value. + @JsonKey(name: 'created_at_before_or_equal') + final DateTime? createdAtBeforeOrEqual; + + /// Filter on createdAt smaller than the given value. + @JsonKey(name: 'created_at_before') + final DateTime? createdAtBefore; + + /// Filter on createdAt around the given value. + @JsonKey(name: 'created_at_around') + final DateTime? createdAtAround; + /// Serialize model to json Map toJson() => _$PaginationParamsToJson(this); @@ -128,6 +157,11 @@ class PaginationParams extends Equatable { String? greaterThanOrEqual, String? lessThan, String? lessThanOrEqual, + DateTime? createdAtAfterOrEqual, + DateTime? createdAtAfter, + DateTime? createdAtBeforeOrEqual, + DateTime? createdAtBefore, + DateTime? createdAtAround, }) => PaginationParams( limit: limit ?? this.limit, @@ -140,6 +174,13 @@ class PaginationParams extends Equatable { greaterThanOrEqual: greaterThanOrEqual ?? this.greaterThanOrEqual, lessThan: lessThan ?? this.lessThan, lessThanOrEqual: lessThanOrEqual ?? this.lessThanOrEqual, + createdAtAfterOrEqual: + createdAtAfterOrEqual ?? this.createdAtAfterOrEqual, + createdAtAfter: createdAtAfter ?? this.createdAtAfter, + createdAtBeforeOrEqual: + createdAtBeforeOrEqual ?? this.createdAtBeforeOrEqual, + createdAtBefore: createdAtBefore ?? this.createdAtBefore, + createdAtAround: createdAtAround ?? this.createdAtAround, ); @override diff --git a/packages/stream_chat/lib/src/core/api/requests.g.dart b/packages/stream_chat/lib/src/core/api/requests.g.dart index 62ec12b3..90bd789d 100644 --- a/packages/stream_chat/lib/src/core/api/requests.g.dart +++ b/packages/stream_chat/lib/src/core/api/requests.g.dart @@ -30,6 +30,21 @@ PaginationParams _$PaginationParamsFromJson(Map json) => greaterThanOrEqual: json['id_gte'] as String?, lessThan: json['id_lt'] as String?, lessThanOrEqual: json['id_lte'] as String?, + createdAtAfterOrEqual: json['created_at_after_or_equal'] == null + ? null + : DateTime.parse(json['created_at_after_or_equal'] as String), + createdAtAfter: json['created_at_after'] == null + ? null + : DateTime.parse(json['created_at_after'] as String), + createdAtBeforeOrEqual: json['created_at_before_or_equal'] == null + ? null + : DateTime.parse(json['created_at_before_or_equal'] as String), + createdAtBefore: json['created_at_before'] == null + ? null + : DateTime.parse(json['created_at_before'] as String), + createdAtAround: json['created_at_around'] == null + ? null + : DateTime.parse(json['created_at_around'] as String), ); Map _$PaginationParamsToJson(PaginationParams instance) { @@ -52,6 +67,15 @@ Map _$PaginationParamsToJson(PaginationParams instance) { writeNotNull('id_gte', instance.greaterThanOrEqual); writeNotNull('id_lt', instance.lessThan); writeNotNull('id_lte', instance.lessThanOrEqual); + writeNotNull('created_at_after_or_equal', + instance.createdAtAfterOrEqual?.toIso8601String()); + writeNotNull('created_at_after', instance.createdAtAfter?.toIso8601String()); + writeNotNull('created_at_before_or_equal', + instance.createdAtBeforeOrEqual?.toIso8601String()); + writeNotNull( + 'created_at_before', instance.createdAtBefore?.toIso8601String()); + writeNotNull( + 'created_at_around', instance.createdAtAround?.toIso8601String()); return val; } diff --git a/packages/stream_chat/lib/src/core/error/stream_chat_error.dart b/packages/stream_chat/lib/src/core/error/stream_chat_error.dart index bebea751..80e83079 100644 --- a/packages/stream_chat/lib/src/core/error/stream_chat_error.dart +++ b/packages/stream_chat/lib/src/core/error/stream_chat_error.dart @@ -21,9 +21,9 @@ class StreamChatError with EquatableMixin implements Exception { class StreamWebSocketError extends StreamChatError { /// const StreamWebSocketError( - String message, { + super.message, { this.data, - }) : super(message); + }); /// factory StreamWebSocketError.fromStreamError(Map error) { diff --git a/packages/stream_chat/lib/src/core/http/interceptor/auth_interceptor.dart b/packages/stream_chat/lib/src/core/http/interceptor/auth_interceptor.dart index 0ef1a408..7748f96f 100644 --- a/packages/stream_chat/lib/src/core/http/interceptor/auth_interceptor.dart +++ b/packages/stream_chat/lib/src/core/http/interceptor/auth_interceptor.dart @@ -36,7 +36,7 @@ class AuthInterceptor extends Interceptor { final params = {'user_id': token.userId}; final headers = { 'Authorization': token.rawValue, - 'stream-auth-type': token.authType.raw, + 'stream-auth-type': token.authType.name, }; options ..queryParameters.addAll(params) diff --git a/packages/stream_chat/lib/src/core/http/stream_chat_dio_error.dart b/packages/stream_chat/lib/src/core/http/stream_chat_dio_error.dart index a8ee0988..b494671c 100644 --- a/packages/stream_chat/lib/src/core/http/stream_chat_dio_error.dart +++ b/packages/stream_chat/lib/src/core/http/stream_chat_dio_error.dart @@ -6,14 +6,11 @@ class StreamChatDioError extends DioError { /// Initialize a stream chat dio error StreamChatDioError({ required this.error, - required RequestOptions requestOptions, - Response? response, - DioErrorType type = DioErrorType.other, + required super.requestOptions, + super.response, + super.type, }) : super( error: error, - requestOptions: requestOptions, - response: response, - type: type, ); @override diff --git a/packages/stream_chat/lib/src/core/http/token.dart b/packages/stream_chat/lib/src/core/http/token.dart index eba49b82..2472a1f7 100644 --- a/packages/stream_chat/lib/src/core/http/token.dart +++ b/packages/stream_chat/lib/src/core/http/token.dart @@ -18,15 +18,6 @@ enum AuthType { anonymous, } -/// Extension for returning the AuthType as a string -extension AuthTypeX on AuthType { - /// Returns the AuthType as a string - String get raw => { - AuthType.jwt: 'jwt', - AuthType.anonymous: 'anonymous', - }[this]!; -} - /// Token designed to store the JWT and the user it is related to. class Token extends Equatable { const Token._({ diff --git a/packages/stream_chat/lib/src/core/models/attachment_file.dart b/packages/stream_chat/lib/src/core/models/attachment_file.dart index 71cdec29..1684e005 100644 --- a/packages/stream_chat/lib/src/core/models/attachment_file.dart +++ b/packages/stream_chat/lib/src/core/models/attachment_file.dart @@ -90,6 +90,9 @@ class AttachmentFile { /// Union class to hold various [UploadState] of a attachment. @freezed class UploadState with _$UploadState { + // Dummy private constructor in order to use getters + const UploadState._(); + /// Preparing state of the union const factory UploadState.preparing() = Preparing; @@ -108,10 +111,7 @@ class UploadState with _$UploadState { /// Creates a new instance from a json factory UploadState.fromJson(Map json) => _$UploadStateFromJson(json); -} -/// Helper extension for UploadState -extension UploadStateX on UploadState? { /// Returns true if state is [Preparing] bool get isPreparing => this is Preparing; 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 f6442a53..2ea50924 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 @@ -103,25 +103,29 @@ class _$UploadStateCopyWithImpl<$Res> implements $UploadStateCopyWith<$Res> { } /// @nodoc -abstract class $PreparingCopyWith<$Res> { - factory $PreparingCopyWith(Preparing value, $Res Function(Preparing) then) = - _$PreparingCopyWithImpl<$Res>; +abstract class _$$PreparingCopyWith<$Res> { + factory _$$PreparingCopyWith( + _$Preparing value, $Res Function(_$Preparing) then) = + __$$PreparingCopyWithImpl<$Res>; } /// @nodoc -class _$PreparingCopyWithImpl<$Res> extends _$UploadStateCopyWithImpl<$Res> - implements $PreparingCopyWith<$Res> { - _$PreparingCopyWithImpl(Preparing _value, $Res Function(Preparing) _then) - : super(_value, (v) => _then(v as Preparing)); +class __$$PreparingCopyWithImpl<$Res> extends _$UploadStateCopyWithImpl<$Res> + implements _$$PreparingCopyWith<$Res> { + __$$PreparingCopyWithImpl( + _$Preparing _value, $Res Function(_$Preparing) _then) + : super(_value, (v) => _then(v as _$Preparing)); @override - Preparing get _value => super._value as Preparing; + _$Preparing get _value => super._value as _$Preparing; } /// @nodoc @JsonSerializable() -class _$Preparing implements Preparing { - const _$Preparing({final String? $type}) : $type = $type ?? 'preparing'; +class _$Preparing extends Preparing { + const _$Preparing({final String? $type}) + : $type = $type ?? 'preparing', + super._(); factory _$Preparing.fromJson(Map json) => _$$PreparingFromJson(json); @@ -137,7 +141,7 @@ class _$Preparing implements Preparing { @override bool operator ==(dynamic other) { return identical(this, other) || - (other.runtimeType == runtimeType && other is Preparing); + (other.runtimeType == runtimeType && other is _$Preparing); } @JsonKey(ignore: true) @@ -224,35 +228,37 @@ class _$Preparing implements Preparing { } } -abstract class Preparing implements UploadState { +abstract class Preparing extends UploadState { const factory Preparing() = _$Preparing; + const Preparing._() : super._(); factory Preparing.fromJson(Map json) = _$Preparing.fromJson; } /// @nodoc -abstract class $InProgressCopyWith<$Res> { - factory $InProgressCopyWith( - InProgress value, $Res Function(InProgress) then) = - _$InProgressCopyWithImpl<$Res>; +abstract class _$$InProgressCopyWith<$Res> { + factory _$$InProgressCopyWith( + _$InProgress value, $Res Function(_$InProgress) then) = + __$$InProgressCopyWithImpl<$Res>; $Res call({int uploaded, int total}); } /// @nodoc -class _$InProgressCopyWithImpl<$Res> extends _$UploadStateCopyWithImpl<$Res> - implements $InProgressCopyWith<$Res> { - _$InProgressCopyWithImpl(InProgress _value, $Res Function(InProgress) _then) - : super(_value, (v) => _then(v as InProgress)); +class __$$InProgressCopyWithImpl<$Res> extends _$UploadStateCopyWithImpl<$Res> + implements _$$InProgressCopyWith<$Res> { + __$$InProgressCopyWithImpl( + _$InProgress _value, $Res Function(_$InProgress) _then) + : super(_value, (v) => _then(v as _$InProgress)); @override - InProgress get _value => super._value as InProgress; + _$InProgress get _value => super._value as _$InProgress; @override $Res call({ Object? uploaded = freezed, Object? total = freezed, }) { - return _then(InProgress( + return _then(_$InProgress( uploaded: uploaded == freezed ? _value.uploaded : uploaded // ignore: cast_nullable_to_non_nullable @@ -267,10 +273,11 @@ class _$InProgressCopyWithImpl<$Res> extends _$UploadStateCopyWithImpl<$Res> /// @nodoc @JsonSerializable() -class _$InProgress implements InProgress { +class _$InProgress extends InProgress { const _$InProgress( {required this.uploaded, required this.total, final String? $type}) - : $type = $type ?? 'inProgress'; + : $type = $type ?? 'inProgress', + super._(); factory _$InProgress.fromJson(Map json) => _$$InProgressFromJson(json); @@ -292,7 +299,7 @@ class _$InProgress implements InProgress { bool operator ==(dynamic other) { return identical(this, other) || (other.runtimeType == runtimeType && - other is InProgress && + other is _$InProgress && const DeepCollectionEquality().equals(other.uploaded, uploaded) && const DeepCollectionEquality().equals(other.total, total)); } @@ -306,8 +313,8 @@ class _$InProgress implements InProgress { @JsonKey(ignore: true) @override - $InProgressCopyWith get copyWith => - _$InProgressCopyWithImpl(this, _$identity); + _$$InProgressCopyWith<_$InProgress> get copyWith => + __$$InProgressCopyWithImpl<_$InProgress>(this, _$identity); @override @optionalTypeArgs @@ -389,9 +396,10 @@ class _$InProgress implements InProgress { } } -abstract class InProgress implements UploadState { +abstract class InProgress extends UploadState { const factory InProgress( {required final int uploaded, required final int total}) = _$InProgress; + const InProgress._() : super._(); factory InProgress.fromJson(Map json) = _$InProgress.fromJson; @@ -399,30 +407,32 @@ abstract class InProgress implements UploadState { int get uploaded => throw _privateConstructorUsedError; int get total => throw _privateConstructorUsedError; @JsonKey(ignore: true) - $InProgressCopyWith get copyWith => + _$$InProgressCopyWith<_$InProgress> get copyWith => throw _privateConstructorUsedError; } /// @nodoc -abstract class $SuccessCopyWith<$Res> { - factory $SuccessCopyWith(Success value, $Res Function(Success) then) = - _$SuccessCopyWithImpl<$Res>; +abstract class _$$SuccessCopyWith<$Res> { + factory _$$SuccessCopyWith(_$Success value, $Res Function(_$Success) then) = + __$$SuccessCopyWithImpl<$Res>; } /// @nodoc -class _$SuccessCopyWithImpl<$Res> extends _$UploadStateCopyWithImpl<$Res> - implements $SuccessCopyWith<$Res> { - _$SuccessCopyWithImpl(Success _value, $Res Function(Success) _then) - : super(_value, (v) => _then(v as Success)); +class __$$SuccessCopyWithImpl<$Res> extends _$UploadStateCopyWithImpl<$Res> + implements _$$SuccessCopyWith<$Res> { + __$$SuccessCopyWithImpl(_$Success _value, $Res Function(_$Success) _then) + : super(_value, (v) => _then(v as _$Success)); @override - Success get _value => super._value as Success; + _$Success get _value => super._value as _$Success; } /// @nodoc @JsonSerializable() -class _$Success implements Success { - const _$Success({final String? $type}) : $type = $type ?? 'success'; +class _$Success extends Success { + const _$Success({final String? $type}) + : $type = $type ?? 'success', + super._(); factory _$Success.fromJson(Map json) => _$$SuccessFromJson(json); @@ -438,7 +448,7 @@ class _$Success implements Success { @override bool operator ==(dynamic other) { return identical(this, other) || - (other.runtimeType == runtimeType && other is Success); + (other.runtimeType == runtimeType && other is _$Success); } @JsonKey(ignore: true) @@ -525,33 +535,34 @@ class _$Success implements Success { } } -abstract class Success implements UploadState { +abstract class Success extends UploadState { const factory Success() = _$Success; + const Success._() : super._(); factory Success.fromJson(Map json) = _$Success.fromJson; } /// @nodoc -abstract class $FailedCopyWith<$Res> { - factory $FailedCopyWith(Failed value, $Res Function(Failed) then) = - _$FailedCopyWithImpl<$Res>; +abstract class _$$FailedCopyWith<$Res> { + factory _$$FailedCopyWith(_$Failed value, $Res Function(_$Failed) then) = + __$$FailedCopyWithImpl<$Res>; $Res call({String error}); } /// @nodoc -class _$FailedCopyWithImpl<$Res> extends _$UploadStateCopyWithImpl<$Res> - implements $FailedCopyWith<$Res> { - _$FailedCopyWithImpl(Failed _value, $Res Function(Failed) _then) - : super(_value, (v) => _then(v as Failed)); +class __$$FailedCopyWithImpl<$Res> extends _$UploadStateCopyWithImpl<$Res> + implements _$$FailedCopyWith<$Res> { + __$$FailedCopyWithImpl(_$Failed _value, $Res Function(_$Failed) _then) + : super(_value, (v) => _then(v as _$Failed)); @override - Failed get _value => super._value as Failed; + _$Failed get _value => super._value as _$Failed; @override $Res call({ Object? error = freezed, }) { - return _then(Failed( + return _then(_$Failed( error: error == freezed ? _value.error : error // ignore: cast_nullable_to_non_nullable @@ -562,9 +573,10 @@ class _$FailedCopyWithImpl<$Res> extends _$UploadStateCopyWithImpl<$Res> /// @nodoc @JsonSerializable() -class _$Failed implements Failed { +class _$Failed extends Failed { const _$Failed({required this.error, final String? $type}) - : $type = $type ?? 'failed'; + : $type = $type ?? 'failed', + super._(); factory _$Failed.fromJson(Map json) => _$$FailedFromJson(json); @@ -584,7 +596,7 @@ class _$Failed implements Failed { bool operator ==(dynamic other) { return identical(this, other) || (other.runtimeType == runtimeType && - other is Failed && + other is _$Failed && const DeepCollectionEquality().equals(other.error, error)); } @@ -595,8 +607,8 @@ class _$Failed implements Failed { @JsonKey(ignore: true) @override - $FailedCopyWith get copyWith => - _$FailedCopyWithImpl(this, _$identity); + _$$FailedCopyWith<_$Failed> get copyWith => + __$$FailedCopyWithImpl<_$Failed>(this, _$identity); @override @optionalTypeArgs @@ -678,12 +690,14 @@ class _$Failed implements Failed { } } -abstract class Failed implements UploadState { +abstract class Failed extends UploadState { const factory Failed({required final String error}) = _$Failed; + const Failed._() : super._(); factory Failed.fromJson(Map json) = _$Failed.fromJson; String get error => throw _privateConstructorUsedError; @JsonKey(ignore: true) - $FailedCopyWith get copyWith => throw _privateConstructorUsedError; + _$$FailedCopyWith<_$Failed> get copyWith => + throw _privateConstructorUsedError; } diff --git a/packages/stream_chat/lib/src/core/models/channel_model.dart b/packages/stream_chat/lib/src/core/models/channel_model.dart index c3e83435..942b9e63 100644 --- a/packages/stream_chat/lib/src/core/models/channel_model.dart +++ b/packages/stream_chat/lib/src/core/models/channel_model.dart @@ -22,9 +22,12 @@ class ChannelModel { DateTime? updatedAt, this.deletedAt, this.memberCount = 0, - this.extraData = const {}, + Map extraData = const {}, this.team, this.cooldown = 0, + bool? disabled, + bool? hidden, + DateTime? truncatedAt, }) : assert( (cid != null && cid.contains(':')) || (id != null && type != null), 'provide either a cid or an id and type', @@ -34,7 +37,18 @@ class ChannelModel { cid = cid ?? '$type:$id', config = config ?? ChannelConfig(), createdAt = createdAt ?? DateTime.now(), - updatedAt = updatedAt ?? DateTime.now(); + updatedAt = updatedAt ?? DateTime.now(), + + // TODO: Make them top-level fields in v5 + // For backwards compatibility, set 'disabled', 'hidden' + // and 'truncated_at' in [extraData]. + extraData = { + ...extraData, + if (disabled != null) 'disabled': disabled, + if (hidden != null) 'hidden': hidden, + if (truncatedAt != null) + 'truncated_at': truncatedAt.toIso8601String(), + }; /// Create a new instance from a json factory ChannelModel.fromJson(Map json) => @@ -92,6 +106,22 @@ class ChannelModel { @JsonKey(includeIfNull: false) final int cooldown; + /// True if the channel is disabled + @JsonKey(ignore: true) + bool? get disabled => extraData['disabled'] as bool?; + + /// True if the channel is hidden + @JsonKey(ignore: true) + bool? get hidden => extraData['hidden'] as bool?; + + /// The date of the last time channel got truncated + @JsonKey(ignore: true) + DateTime? get truncatedAt { + final truncatedAt = extraData['truncated_at'] as String?; + if (truncatedAt == null) return null; + return DateTime.parse(truncatedAt); + } + /// Map of custom channel extraData @JsonKey(includeIfNull: false) final Map extraData; @@ -145,6 +175,9 @@ class ChannelModel { Map? extraData, String? team, int? cooldown, + bool? disabled, + bool? hidden, + DateTime? truncatedAt, }) => ChannelModel( id: id ?? this.id, @@ -162,6 +195,14 @@ class ChannelModel { extraData: extraData ?? this.extraData, team: team ?? this.team, cooldown: cooldown ?? this.cooldown, + disabled: disabled ?? extraData?['disabled'] as bool? ?? this.disabled, + hidden: hidden ?? extraData?['hidden'] as bool? ?? this.hidden, + truncatedAt: truncatedAt ?? + (extraData?['truncated_at'] == null + ? null + // ignore: cast_nullable_to_non_nullable + : DateTime.parse(extraData?['truncated_at'] as String)) ?? + this.truncatedAt, ); /// Returns a new [ChannelModel] that is a combination of this channelModel @@ -181,9 +222,12 @@ class ChannelModel { updatedAt: other.updatedAt, deletedAt: other.deletedAt, memberCount: other.memberCount, - extraData: {...extraData, ...other.extraData}, + extraData: other.extraData, team: other.team, cooldown: other.cooldown, + disabled: other.disabled, + hidden: other.hidden, + truncatedAt: other.truncatedAt, ); } } diff --git a/packages/stream_chat/lib/src/core/models/channel_state.dart b/packages/stream_chat/lib/src/core/models/channel_state.dart index 3ba3c5f8..65e22f38 100644 --- a/packages/stream_chat/lib/src/core/models/channel_state.dart +++ b/packages/stream_chat/lib/src/core/models/channel_state.dart @@ -19,6 +19,7 @@ class ChannelState { this.watcherCount, this.watchers, this.read, + this.membership, }); /// The channel to which this state belongs @@ -42,6 +43,9 @@ class ChannelState { /// The list of channel reads final List? read; + /// Relationship of the current user to this channel. + final Member? membership; + /// Create a new instance from a json static ChannelState fromJson(Map json) => _$ChannelStateFromJson(json); @@ -58,6 +62,7 @@ class ChannelState { int? watcherCount, List? watchers, List? read, + Member? membership, }) => ChannelState( channel: channel ?? this.channel, @@ -67,5 +72,6 @@ class ChannelState { watcherCount: watcherCount ?? this.watcherCount, watchers: watchers ?? this.watchers, read: read ?? this.read, + membership: membership ?? this.membership, ); } diff --git a/packages/stream_chat/lib/src/core/models/channel_state.g.dart b/packages/stream_chat/lib/src/core/models/channel_state.g.dart index afec76c4..40e11a32 100644 --- a/packages/stream_chat/lib/src/core/models/channel_state.g.dart +++ b/packages/stream_chat/lib/src/core/models/channel_state.g.dart @@ -26,6 +26,9 @@ ChannelState _$ChannelStateFromJson(Map json) => ChannelState( read: (json['read'] as List?) ?.map((e) => Read.fromJson(e as Map)) .toList(), + membership: json['membership'] == null + ? null + : Member.fromJson(json['membership'] as Map), ); Map _$ChannelStateToJson(ChannelState instance) => @@ -38,4 +41,5 @@ Map _$ChannelStateToJson(ChannelState instance) => 'watcher_count': instance.watcherCount, 'watchers': instance.watchers?.map((e) => e.toJson()).toList(), 'read': instance.read?.map((e) => e.toJson()).toList(), + 'membership': instance.membership?.toJson(), }; diff --git a/packages/stream_chat/lib/src/core/models/event.dart b/packages/stream_chat/lib/src/core/models/event.dart index 1801ceae..13aec2b9 100644 --- a/packages/stream_chat/lib/src/core/models/event.dart +++ b/packages/stream_chat/lib/src/core/models/event.dart @@ -177,36 +177,25 @@ class EventChannel extends ChannelModel { /// Constructor used for json serialization EventChannel({ this.members, - String? id, - String? type, - required String cid, - required ChannelConfig config, - User? createdBy, - bool frozen = false, - DateTime? lastMessageAt, - required DateTime createdAt, - required DateTime updatedAt, - DateTime? deletedAt, - int memberCount = 0, + super.id, + super.type, + required String super.cid, + super.ownCapabilities, + required ChannelConfig super.config, + super.createdBy, + super.frozen, + super.lastMessageAt, + required DateTime super.createdAt, + required DateTime super.updatedAt, + super.deletedAt, + super.memberCount, Map? extraData, - int cooldown = 0, - String? team, - }) : super( - id: id, - type: type, - cid: cid, - config: config, - createdBy: createdBy, - frozen: frozen, - lastMessageAt: lastMessageAt, - createdAt: createdAt, - updatedAt: updatedAt, - deletedAt: deletedAt, - memberCount: memberCount, - extraData: extraData ?? {}, - cooldown: cooldown, - team: team, - ); + super.cooldown, + super.team, + super.disabled, + super.hidden, + super.truncatedAt, + }) : super(extraData: extraData ?? {}); /// Create a new instance from a json factory EventChannel.fromJson(Map json) => diff --git a/packages/stream_chat/lib/src/core/models/event.g.dart b/packages/stream_chat/lib/src/core/models/event.g.dart index d3a531fe..524b5bd9 100644 --- a/packages/stream_chat/lib/src/core/models/event.g.dart +++ b/packages/stream_chat/lib/src/core/models/event.g.dart @@ -81,6 +81,9 @@ EventChannel _$EventChannelFromJson(Map json) => EventChannel( id: json['id'] as String?, type: json['type'] as String?, cid: json['cid'] as String, + ownCapabilities: (json['own_capabilities'] as List?) + ?.map((e) => e as String) + .toList(), config: ChannelConfig.fromJson(json['config'] as Map), createdBy: json['created_by'] == null ? null diff --git a/packages/stream_chat/lib/src/core/models/filter.dart b/packages/stream_chat/lib/src/core/models/filter.dart index 108efcb2..2122519d 100644 --- a/packages/stream_chat/lib/src/core/models/filter.dart +++ b/packages/stream_chat/lib/src/core/models/filter.dart @@ -53,29 +53,43 @@ enum FilterOperator { nor, /// Matches any list that contains the specified value - contains, -} + contains; -/// Helper extension for [FilterOperator] -extension FilterOperatorX on FilterOperator { - /// Converts [FilterOperator] into rew values - String get rawValue => { - FilterOperator.equal: '\$eq', - FilterOperator.notEqual: '\$ne', - FilterOperator.greater: '\$gt', - FilterOperator.greaterOrEqual: '\$gte', - FilterOperator.less: '\$lt', - FilterOperator.lessOrEqual: '\$lte', - FilterOperator.in_: '\$in', - FilterOperator.notIn: '\$nin', - FilterOperator.query: '\$q', - FilterOperator.autoComplete: '\$autocomplete', - FilterOperator.exists: '\$exists', - FilterOperator.and: '\$and', - FilterOperator.or: '\$or', - FilterOperator.nor: '\$nor', - FilterOperator.contains: '\$contains', - }[this]!; + @override + String toString() { + switch (this) { + case FilterOperator.equal: + return r'$eq'; + case FilterOperator.notEqual: + return r'$ne'; + case FilterOperator.greater: + return r'$gt'; + case FilterOperator.greaterOrEqual: + return r'$gte'; + case FilterOperator.less: + return r'$lt'; + case FilterOperator.lessOrEqual: + return r'$lte'; + case FilterOperator.in_: + return r'$in'; + case FilterOperator.notIn: + return r'$nin'; + case FilterOperator.query: + return r'$q'; + case FilterOperator.autoComplete: + return r'$autocomplete'; + case FilterOperator.exists: + return r'$exists'; + case FilterOperator.and: + return r'$and'; + case FilterOperator.or: + return r'$or'; + case FilterOperator.nor: + return r'$nor'; + case FilterOperator.contains: + return r'$contains'; + } + } } /// Stream supports a limited set of filters for querying channels, @@ -96,11 +110,11 @@ class Filter extends Equatable { this.key, }); - Filter._({ + const Filter._({ required FilterOperator operator, required this.value, this.key, - }) : operator = operator.rawValue; + }) : operator = '$operator'; /// An empty filter const Filter.empty() @@ -215,7 +229,7 @@ class Filter extends Equatable { /// Serializes to json object Map toJson() { final json = {}; - final groupOperators = _groupOperators.map((it) => it.rawValue); + final groupOperators = _groupOperators.map((it) => '$it'); if (groupOperators.contains(operator)) { // Filters with group operators are encoded in the following form: diff --git a/packages/stream_chat/lib/src/core/models/own_user.dart b/packages/stream_chat/lib/src/core/models/own_user.dart index 6133dd76..60d15278 100644 --- a/packages/stream_chat/lib/src/core/models/own_user.dart +++ b/packages/stream_chat/lib/src/core/models/own_user.dart @@ -17,34 +17,20 @@ class OwnUser extends User { this.totalUnreadCount = 0, this.unreadChannels = 0, this.channelMutes = const [], - required String id, - String? role, - String? name, - String? image, - DateTime? createdAt, - DateTime? updatedAt, - DateTime? lastActive, - bool online = false, - Map extraData = const {}, - bool banned = false, - DateTime? banExpires, - List teams = const [], - String? language, - }) : super( - id: id, - role: role, - name: name, - image: image, - createdAt: createdAt, - updatedAt: updatedAt, - lastActive: lastActive, - online: online, - extraData: extraData, - banned: banned, - banExpires: banExpires, - teams: teams, - language: language, - ); + required super.id, + super.role, + super.name, + super.image, + super.createdAt, + super.updatedAt, + super.lastActive, + super.online, + super.extraData, + super.banned, + super.banExpires, + super.teams, + super.language, + }); /// Create a new instance from json. factory OwnUser.fromJson(Map json) => _$OwnUserFromJson( @@ -55,6 +41,9 @@ class OwnUser extends User { factory OwnUser.fromUser(User user) => OwnUser( id: user.id, role: user.role, + // Using extraData value in order to not use id as name. + name: user.extraData['name'] as String?, + image: user.image, createdAt: user.createdAt, updatedAt: user.updatedAt, lastActive: user.lastActive, @@ -90,10 +79,11 @@ class OwnUser extends User { OwnUser( id: id ?? this.id, role: role ?? this.role, - // if null, it will be retrieved from extraData['name'] - name: name, - // if null, it will be retrieved from extraData['image'] - image: image, + name: name ?? + extraData?['name'] as String? ?? + // Using extraData value in order to not use id as name. + this.extraData['name'] as String?, + image: image ?? extraData?['image'] as String? ?? this.image, banned: banned ?? this.banned, banExpires: banExpires ?? this.banExpires, createdAt: createdAt ?? this.createdAt, @@ -117,6 +107,9 @@ class OwnUser extends User { return copyWith( id: other.id, role: other.role, + // Using extraData value in order to not use id as name. + name: other.extraData['name'] as String?, + image: other.image, banned: other.banned, channelMutes: other.channelMutes, createdAt: other.createdAt, diff --git a/packages/stream_chat/lib/src/core/models/user.dart b/packages/stream_chat/lib/src/core/models/user.dart index 0d19d59d..ff435f67 100644 --- a/packages/stream_chat/lib/src/core/models/user.dart +++ b/packages/stream_chat/lib/src/core/models/user.dart @@ -46,6 +46,7 @@ class User extends Equatable { this.language, }) : createdAt = createdAt ?? DateTime.now(), updatedAt = updatedAt ?? DateTime.now(), + // TODO: Make them top-level fields in v5 // For backwards compatibility, set 'name', 'image' in [extraData]. extraData = { ...extraData, @@ -171,10 +172,11 @@ class User extends Equatable { User( id: id ?? this.id, role: role ?? this.role, - // if null, it will be retrieved from extraData['name'] - name: name, - // if null, it will be retrieved from extraData['image'] - image: image, + name: name ?? + extraData?['name'] as String? ?? + // Using extraData value in order to not use id as name. + this.extraData['name'] as String?, + image: image ?? extraData?['image'] as String? ?? this.image, createdAt: createdAt ?? this.createdAt, updatedAt: updatedAt ?? this.updatedAt, lastActive: lastActive ?? this.lastActive, diff --git a/packages/stream_chat/lib/src/event_type.dart b/packages/stream_chat/lib/src/event_type.dart index 80628f2f..b553943e 100644 --- a/packages/stream_chat/lib/src/event_type.dart +++ b/packages/stream_chat/lib/src/event_type.dart @@ -73,6 +73,9 @@ class EventType { /// Event sent when a member is removed to a channel static const String memberRemoved = 'member.removed'; + /// Event sent when a member is updated in a channel + static const String memberUpdated = 'member.updated'; + /// Event sent when a member is removed to a channel static const String userBanned = 'user.banned'; diff --git a/packages/stream_chat/lib/src/location.dart b/packages/stream_chat/lib/src/location.dart deleted file mode 100644 index 86813a0a..00000000 --- a/packages/stream_chat/lib/src/location.dart +++ /dev/null @@ -1,29 +0,0 @@ -/// -enum Location { - /// - usEast, - - /// - euWest, - - /// - mumbai, - - /// - sydney, - - /// - singapore, -} - -/// -extension LocationX on Location { - /// - String get name => { - Location.usEast: 'us-east', - Location.euWest: 'dublin', - Location.mumbai: 'mumbai', - Location.sydney: 'sydney', - Location.singapore: 'singapore', - }[this]!; -} diff --git a/packages/stream_chat/lib/src/ws/websocket.dart b/packages/stream_chat/lib/src/ws/websocket.dart index a26bd1f6..2287481e 100644 --- a/packages/stream_chat/lib/src/ws/websocket.dart +++ b/packages/stream_chat/lib/src/ws/websocket.dart @@ -6,7 +6,6 @@ import 'package:logging/logging.dart'; import 'package:meta/meta.dart'; import 'package:rxdart/rxdart.dart'; import 'package:stream_chat/src/core/error/error.dart'; -import 'package:stream_chat/src/core/http/token.dart'; import 'package:stream_chat/src/core/http/token_manager.dart'; import 'package:stream_chat/src/core/models/event.dart'; import 'package:stream_chat/src/core/models/user.dart'; @@ -163,7 +162,7 @@ class WebSocket with TimerHelper { 'json': jsonEncode(params), 'api_key': apiKey, 'authorization': token.rawValue, - 'stream-auth-type': token.authType.raw, + 'stream-auth-type': token.authType.name, ...queryParameters, }; final scheme = baseUrl.startsWith('https') ? 'wss' : 'ws'; diff --git a/packages/stream_chat/lib/stream_chat.dart b/packages/stream_chat/lib/stream_chat.dart index 0fce9d63..0479a378 100644 --- a/packages/stream_chat/lib/stream_chat.dart +++ b/packages/stream_chat/lib/stream_chat.dart @@ -36,7 +36,6 @@ export './src/core/models/user.dart'; export './src/core/util/extension.dart'; export './src/db/chat_persistence_client.dart'; export './src/event_type.dart'; -export './src/location.dart'; export './src/permission_type.dart'; export './src/ws/connection_status.dart'; export 'src/client/channel.dart'; @@ -67,5 +66,4 @@ export 'src/core/models/user.dart'; export 'src/core/util/extension.dart'; export 'src/db/chat_persistence_client.dart'; export 'src/event_type.dart'; -export 'src/location.dart'; export 'src/ws/connection_status.dart'; diff --git a/packages/stream_chat/lib/version.dart b/packages/stream_chat/lib/version.dart index 360c57e9..43c39af1 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/client.dart'; /// Current package version /// Used in [StreamChatClient] to build the `x-stream-client` header // ignore: constant_identifier_names -const PACKAGE_VERSION = '4.1.0'; +const PACKAGE_VERSION = '4.2.0'; diff --git a/packages/stream_chat/pubspec.yaml b/packages/stream_chat/pubspec.yaml index 1689550a..4ab80885 100644 --- a/packages/stream_chat/pubspec.yaml +++ b/packages/stream_chat/pubspec.yaml @@ -1,22 +1,22 @@ name: stream_chat homepage: https://getstream.io/ description: The official Dart client for Stream Chat, a service for building chat applications. -version: 4.1.0 +version: 4.2.0 repository: https://github.com/GetStream/stream-chat-flutter issue_tracker: https://github.com/GetStream/stream-chat-flutter/issues environment: - sdk: '>=2.12.0 <3.0.0' + sdk: '>=2.17.0 <3.0.0' dependencies: async: ^2.5.0 collection: ^1.15.0 dio: ^4.0.0 equatable: ^2.0.0 - freezed_annotation: ^1.0.0 + freezed_annotation: ^2.0.3 http_parser: ^4.0.0 jose: ^0.3.2 - json_annotation: ^4.3.0 + json_annotation: ^4.5.0 logging: ^1.0.1 meta: ^1.3.0 mime: ^1.0.0 @@ -28,7 +28,7 @@ dependencies: dev_dependencies: build_runner: ^2.0.1 dart_code_metrics: ^4.4.0 - freezed: ^1.0.0 - json_serializable: ^6.0.1 + freezed: ^2.0.3 + json_serializable: ^6.2.0 mocktail: ^0.3.0 test: ^1.17.12 \ No newline at end of file diff --git a/packages/stream_chat/test/fixtures/channel_state_to_json.json b/packages/stream_chat/test/fixtures/channel_state_to_json.json index ebb74fb6..c0c06f9e 100644 --- a/packages/stream_chat/test/fixtures/channel_state_to_json.json +++ b/packages/stream_chat/test/fixtures/channel_state_to_json.json @@ -11,6 +11,7 @@ }, "watchers": [], "read": [], + "membership": null, "messages": [ { "id": "dry-meadow-0-2b73cc8b-cd86-4a01-8d40-bd82ad07a030", diff --git a/packages/stream_chat/test/src/client/client_test.dart b/packages/stream_chat/test/src/client/client_test.dart index 4947bc72..65c0fe26 100644 --- a/packages/stream_chat/test/src/client/client_test.dart +++ b/packages/stream_chat/test/src/client/client_test.dart @@ -1,5 +1,4 @@ import 'package:mocktail/mocktail.dart'; -import 'package:stream_chat/src/core/api/device_api.dart'; import 'package:stream_chat/src/core/http/token.dart'; import 'package:stream_chat/src/core/models/banned_user.dart'; import 'package:stream_chat/stream_chat.dart'; @@ -2514,7 +2513,7 @@ void main() { }); test( - '''setting the `currentUser` should also compute and update the unreadCounts''', + 'setting the `currentUser` should also compute and update the unreadCounts', () { final state = client.state; final initialUser = OwnUser.fromUser(user); diff --git a/packages/stream_chat/test/src/core/http/interceptor/auth_interceptor_test.dart b/packages/stream_chat/test/src/core/http/interceptor/auth_interceptor_test.dart index 82dcdfb9..1e88ea1e 100644 --- a/packages/stream_chat/test/src/core/http/interceptor/auth_interceptor_test.dart +++ b/packages/stream_chat/test/src/core/http/interceptor/auth_interceptor_test.dart @@ -46,7 +46,7 @@ void main() { expect(updateHeaders.containsKey('Authorization'), isTrue); expect(updateHeaders['Authorization'], token.rawValue); expect(updateHeaders.containsKey('stream-auth-type'), isTrue); - expect(updateHeaders['stream-auth-type'], token.authType.raw); + expect(updateHeaders['stream-auth-type'], token.authType.name); expect(updatedQueryParams.containsKey('user_id'), isTrue); expect(updatedQueryParams['user_id'], token.userId); diff --git a/packages/stream_chat/test/src/core/http/token_test.dart b/packages/stream_chat/test/src/core/http/token_test.dart index b448884e..0f0e0425 100644 --- a/packages/stream_chat/test/src/core/http/token_test.dart +++ b/packages/stream_chat/test/src/core/http/token_test.dart @@ -10,7 +10,7 @@ void main() { expect(token.userId, userId); expect(token.rawValue, isEmpty); expect(token.authType, AuthType.anonymous); - expect(token.authType.raw, AuthType.anonymous.raw); + expect(token.authType.name, AuthType.anonymous.name); }); test('`.fromRawValue` should create token from rawValue', () { @@ -36,7 +36,7 @@ void main() { expect(token.userId, userId); expect(token.rawValue, isNotEmpty); expect(token.authType, AuthType.jwt); - expect(token.authType.raw, AuthType.jwt.raw); + expect(token.authType.name, AuthType.jwt.name); }); test( @@ -51,7 +51,7 @@ void main() { expect(token.userId, user.id); expect(token.rawValue, isNotEmpty); expect(token.authType, AuthType.jwt); - expect(token.authType.raw, AuthType.jwt.raw); + expect(token.authType.name, AuthType.jwt.name); }, ); } diff --git a/packages/stream_chat/test/src/core/models/channel_state_test.dart b/packages/stream_chat/test/src/core/models/channel_state_test.dart index 65a589b8..c8b92a0b 100644 --- a/packages/stream_chat/test/src/core/models/channel_state_test.dart +++ b/packages/stream_chat/test/src/core/models/channel_state_test.dart @@ -49,6 +49,7 @@ void main() { channel: ChannelModel.fromJson(j['channel']), members: [], messages: + // ignore: unnecessary_lambdas (j['messages'] as List).map((m) => Message.fromJson(m)).toList(), read: [], watcherCount: 5, diff --git a/packages/stream_chat/test/src/core/models/channel_test.dart b/packages/stream_chat/test/src/core/models/channel_test.dart index e27f5970..e67c185e 100644 --- a/packages/stream_chat/test/src/core/models/channel_test.dart +++ b/packages/stream_chat/test/src/core/models/channel_test.dart @@ -55,4 +55,140 @@ void main() { ); }); }); + + test('hidden property and extraData manipulation', () { + final channel = ChannelModel(cid: 'test:cid', hidden: false); + + expect(channel.hidden, false); + expect(channel.extraData['hidden'], false); + print(channel.toJson()); + expect(channel.toJson(), { + 'id': 'cid', + 'type': 'test', + 'frozen': false, + 'cooldown': 0, + 'hidden': false, + }); + expect(ChannelModel.fromJson(channel.toJson()).toJson(), { + 'id': 'cid', + 'type': 'test', + 'frozen': false, + 'cooldown': 0, + 'hidden': false, + }); + + var newChannel = channel.copyWith( + extraData: {'hidden': true}, + ); + + expect(newChannel.extraData['hidden'], true); + expect(newChannel.hidden, true); + + newChannel = channel.copyWith( + hidden: false, + ); + + expect(newChannel.extraData['hidden'], false); + expect(newChannel.hidden, false); + + newChannel = channel.copyWith( + hidden: true, + extraData: {'hidden': true}, + ); + + expect(newChannel.extraData['hidden'], true); + expect(newChannel.hidden, true); + }); + + test('disabled property and extraData manipulation', () { + final channel = ChannelModel(cid: 'test:cid', disabled: false); + + expect(channel.disabled, false); + expect(channel.extraData['disabled'], false); + print(channel.toJson()); + expect(channel.toJson(), { + 'id': 'cid', + 'type': 'test', + 'frozen': false, + 'cooldown': 0, + 'disabled': false, + }); + expect(ChannelModel.fromJson(channel.toJson()).toJson(), { + 'id': 'cid', + 'type': 'test', + 'frozen': false, + 'cooldown': 0, + 'disabled': false, + }); + + var newChannel = channel.copyWith( + extraData: {'disabled': true}, + ); + + expect(newChannel.extraData['disabled'], true); + expect(newChannel.disabled, true); + + newChannel = channel.copyWith( + hidden: false, + ); + + expect(newChannel.extraData['disabled'], false); + expect(newChannel.disabled, false); + + newChannel = channel.copyWith( + hidden: true, + extraData: {'disabled': true}, + ); + + expect(newChannel.extraData['disabled'], true); + expect(newChannel.disabled, true); + }); + + test('truncatedAt property and extraData manipulation', () { + final currentDate = DateTime.now(); + final channel = ChannelModel(cid: 'test:cid', truncatedAt: currentDate); + + expect(channel.truncatedAt, currentDate); + expect(channel.extraData['truncated_at'], currentDate.toIso8601String()); + print(channel.toJson()); + expect(channel.toJson(), { + 'id': 'cid', + 'type': 'test', + 'frozen': false, + 'cooldown': 0, + 'truncated_at': currentDate.toIso8601String(), + }); + expect(ChannelModel.fromJson(channel.toJson()).toJson(), { + 'id': 'cid', + 'type': 'test', + 'frozen': false, + 'cooldown': 0, + 'truncated_at': currentDate.toIso8601String(), + }); + + final dateOne = DateTime.now(); + var newChannel = channel.copyWith( + extraData: {'truncated_at': dateOne.toIso8601String()}, + ); + + expect(newChannel.extraData['truncated_at'], dateOne.toIso8601String()); + expect(newChannel.truncatedAt, dateOne); + + final dateTwo = DateTime.now(); + newChannel = channel.copyWith( + truncatedAt: dateTwo, + ); + + expect(newChannel.extraData['truncated_at'], dateTwo.toIso8601String()); + expect(newChannel.truncatedAt, dateTwo); + + final dateThree = DateTime.now(); + newChannel = channel.copyWith( + truncatedAt: dateThree, + extraData: {'truncated_at': dateThree.toIso8601String()}, + ); + + expect(newChannel.extraData['truncated_at'], dateThree.toIso8601String()); + expect(newChannel.truncatedAt, dateThree); + }); } diff --git a/packages/stream_chat/test/src/core/models/filter_test.dart b/packages/stream_chat/test/src/core/models/filter_test.dart index f836d845..3a82eadc 100644 --- a/packages/stream_chat/test/src/core/models/filter_test.dart +++ b/packages/stream_chat/test/src/core/models/filter_test.dart @@ -11,7 +11,7 @@ void main() { final filter = Filter.equal(key, value); expect(filter.key, key); expect(filter.value, value); - expect(filter.operator, FilterOperator.equal.rawValue); + expect(filter.operator, FilterOperator.equal.toString()); }); test('notEqual', () { @@ -20,7 +20,7 @@ void main() { final filter = Filter.notEqual(key, value); expect(filter.key, key); expect(filter.value, value); - expect(filter.operator, FilterOperator.notEqual.rawValue); + expect(filter.operator, FilterOperator.notEqual.toString()); }); test('greater', () { @@ -29,7 +29,7 @@ void main() { final filter = Filter.greater(key, value); expect(filter.key, key); expect(filter.value, value); - expect(filter.operator, FilterOperator.greater.rawValue); + expect(filter.operator, FilterOperator.greater.toString()); }); test('greaterOrEqual', () { @@ -38,7 +38,7 @@ void main() { final filter = Filter.greaterOrEqual(key, value); expect(filter.key, key); expect(filter.value, value); - expect(filter.operator, FilterOperator.greaterOrEqual.rawValue); + expect(filter.operator, FilterOperator.greaterOrEqual.toString()); }); test('less', () { @@ -47,7 +47,7 @@ void main() { final filter = Filter.less(key, value); expect(filter.key, key); expect(filter.value, value); - expect(filter.operator, FilterOperator.less.rawValue); + expect(filter.operator, FilterOperator.less.toString()); }); test('lessOrEqual', () { @@ -56,7 +56,7 @@ void main() { final filter = Filter.lessOrEqual(key, value); expect(filter.key, key); expect(filter.value, value); - expect(filter.operator, FilterOperator.lessOrEqual.rawValue); + expect(filter.operator, FilterOperator.lessOrEqual.toString()); }); test('in', () { @@ -65,7 +65,7 @@ void main() { final filter = Filter.in_(key, values); expect(filter.key, key); expect(filter.value, values); - expect(filter.operator, FilterOperator.in_.rawValue); + expect(filter.operator, FilterOperator.in_.toString()); }); test('in', () { @@ -74,7 +74,7 @@ void main() { final filter = Filter.in_(key, values); expect(filter.key, key); expect(filter.value, values); - expect(filter.operator, FilterOperator.in_.rawValue); + expect(filter.operator, FilterOperator.in_.toString()); }); test('notIn', () { @@ -83,7 +83,7 @@ void main() { final filter = Filter.notIn(key, values); expect(filter.key, key); expect(filter.value, values); - expect(filter.operator, FilterOperator.notIn.rawValue); + expect(filter.operator, FilterOperator.notIn.toString()); }); test('query', () { @@ -92,7 +92,7 @@ void main() { final filter = Filter.query(key, value); expect(filter.key, key); expect(filter.value, value); - expect(filter.operator, FilterOperator.query.rawValue); + expect(filter.operator, FilterOperator.query.toString()); }); test('autoComplete', () { @@ -101,7 +101,7 @@ void main() { final filter = Filter.autoComplete(key, value); expect(filter.key, key); expect(filter.value, value); - expect(filter.operator, FilterOperator.autoComplete.rawValue); + expect(filter.operator, FilterOperator.autoComplete.toString()); }); test('exists', () { @@ -109,7 +109,7 @@ void main() { final filter = Filter.exists(key); expect(filter.key, key); expect(filter.value, isTrue); - expect(filter.operator, FilterOperator.exists.rawValue); + expect(filter.operator, FilterOperator.exists.toString()); }); test('notExists', () { @@ -117,13 +117,13 @@ void main() { final filter = Filter.notExists(key); expect(filter.key, key); expect(filter.value, isFalse); - expect(filter.operator, FilterOperator.exists.rawValue); + expect(filter.operator, FilterOperator.exists.toString()); }); test('custom', () { const key = 'testKey'; const value = 'testValue'; - const operator = '\$customOperator'; + const operator = r'$customOperator'; const filter = Filter.custom(operator: operator, key: key, value: value); expect(filter.key, key); expect(filter.value, value); @@ -149,7 +149,7 @@ void main() { final filter = Filter.contains(key, values); expect(filter.key, key); expect(filter.value, values); - expect(filter.operator, FilterOperator.contains.rawValue); + expect(filter.operator, FilterOperator.contains.toString()); }); group('groupedOperator', () { @@ -161,21 +161,21 @@ void main() { final filter = Filter.and(filters); expect(filter.key, isNull); expect(filter.value, filters); - expect(filter.operator, FilterOperator.and.rawValue); + expect(filter.operator, FilterOperator.and.toString()); }); test('or', () { final filter = Filter.or(filters); expect(filter.key, isNull); expect(filter.value, filters); - expect(filter.operator, FilterOperator.or.rawValue); + expect(filter.operator, FilterOperator.or.toString()); }); test('nor', () { final filter = Filter.nor(filters); expect(filter.key, isNull); expect(filter.value, filters); - expect(filter.operator, FilterOperator.nor.rawValue); + expect(filter.operator, FilterOperator.nor.toString()); }); }); }); @@ -189,7 +189,7 @@ void main() { final encoded = json.encode(filter); expect( encoded, - '{"$key":{"${FilterOperator.equal.rawValue}":${json.encode(value)}}}', + '''{"$key":{"${FilterOperator.equal.toString()}":${json.encode(value)}}}''', ); }); test('listValue', () { @@ -199,7 +199,7 @@ void main() { final encoded = json.encode(filter); expect( encoded, - '{"$key":{"${FilterOperator.in_.rawValue}":${json.encode(values)}}}', + '''{"$key":{"${FilterOperator.in_.toString()}":${json.encode(values)}}}''', ); }); @@ -243,7 +243,7 @@ void main() { final encoded = json.encode(filter); expect( encoded, - '{"${FilterOperator.and.rawValue}":${json.encode(filters)}}', + '{"${FilterOperator.and.toString()}":${json.encode(filters)}}', ); }); diff --git a/packages/stream_chat_flutter/CHANGELOG.md b/packages/stream_chat_flutter/CHANGELOG.md index f41d94f6..3f9509fb 100644 --- a/packages/stream_chat_flutter/CHANGELOG.md +++ b/packages/stream_chat_flutter/CHANGELOG.md @@ -1,3 +1,9 @@ +## 4.2.0 + +🐞 Fixed + +- [[#1133]](https://github.com/GetStream/stream-chat-flutter/issues/1133) Visibility override flags not being passed to `StreamMessageActionsModal` + ## 4.1.0 ✅ Added @@ -8,7 +14,9 @@ 🐞 Fixed - Fixed attachment picker ui. +- Fixed StreamChannelHeader and StreamThreadHeader subtitle alignment. - Fixed message widget thread indicator in reverse mode. +- [[#1044]](https://github.com/GetStream/stream-chat-flutter/issues/1044): Refactor StreamMessageWidget bottom row to use Text.rich. 🔄 Changed diff --git a/packages/stream_chat_flutter/example/lib/main.dart b/packages/stream_chat_flutter/example/lib/main.dart index ab8d0dfc..8864858f 100644 --- a/packages/stream_chat_flutter/example/lib/main.dart +++ b/packages/stream_chat_flutter/example/lib/main.dart @@ -47,10 +47,10 @@ class MyApp extends StatelessWidget { /// If you'd prefer using minimal wrapper widgets for your app, please see /// our other package, `stream_chat_flutter_core`. const MyApp({ - Key? key, + super.key, required this.client, required this.channel, - }) : super(key: key); + }); /// Instance of Stream Client. /// @@ -94,8 +94,8 @@ class MyApp extends StatelessWidget { class ChannelPage extends StatelessWidget { /// Creates the page that shows the list of messages const ChannelPage({ - Key? key, - }) : super(key: key); + super.key, + }); @override Widget build(BuildContext context) => Scaffold( diff --git a/packages/stream_chat_flutter/example/lib/split_view.dart b/packages/stream_chat_flutter/example/lib/split_view.dart index 6f4c51e6..5b9cc6fb 100644 --- a/packages/stream_chat_flutter/example/lib/split_view.dart +++ b/packages/stream_chat_flutter/example/lib/split_view.dart @@ -22,9 +22,9 @@ void main() async { class MyApp extends StatelessWidget { const MyApp({ - Key? key, + super.key, required this.client, - }) : super(key: key); + }); final StreamChatClient client; @@ -40,8 +40,8 @@ class MyApp extends StatelessWidget { class SplitView extends StatefulWidget { const SplitView({ - Key? key, - }) : super(key: key); + super.key, + }); @override _SplitViewState createState() => _SplitViewState(); @@ -86,9 +86,9 @@ class _SplitViewState extends State { class ChannelListPage extends StatefulWidget { const ChannelListPage({ - Key? key, + super.key, this.onTap, - }) : super(key: key); + }); final void Function(Channel)? onTap; @@ -118,8 +118,8 @@ class _ChannelListPageState extends State { class ChannelPage extends StatelessWidget { const ChannelPage({ - Key? key, - }) : super(key: key); + super.key, + }); @override Widget build(BuildContext context) => Navigator( diff --git a/packages/stream_chat_flutter/example/lib/tutorial_part_1.dart b/packages/stream_chat_flutter/example/lib/tutorial_part_1.dart index 94524ebb..2b388d6a 100644 --- a/packages/stream_chat_flutter/example/lib/tutorial_part_1.dart +++ b/packages/stream_chat_flutter/example/lib/tutorial_part_1.dart @@ -58,10 +58,10 @@ void main() async { class MyApp extends StatelessWidget { const MyApp({ - Key? key, + super.key, required this.client, required this.channel, - }) : super(key: key); + }); final StreamChatClient client; @@ -86,8 +86,8 @@ class MyApp extends StatelessWidget { class ChannelPage extends StatelessWidget { const ChannelPage({ - Key? key, - }) : super(key: key); + super.key, + }); @override Widget build(BuildContext context) => Scaffold( diff --git a/packages/stream_chat_flutter/example/lib/tutorial_part_2.dart b/packages/stream_chat_flutter/example/lib/tutorial_part_2.dart index 15f7914c..6992527f 100644 --- a/packages/stream_chat_flutter/example/lib/tutorial_part_2.dart +++ b/packages/stream_chat_flutter/example/lib/tutorial_part_2.dart @@ -51,9 +51,9 @@ void main() async { class MyApp extends StatelessWidget { const MyApp({ - Key? key, + super.key, required this.client, - }) : super(key: key); + }); final StreamChatClient client; @@ -73,9 +73,9 @@ class MyApp extends StatelessWidget { class ChannelListPage extends StatefulWidget { const ChannelListPage({ - Key? key, + super.key, required this.client, - }) : super(key: key); + }); final StreamChatClient client; @@ -121,8 +121,8 @@ class _ChannelListPageState extends State { class ChannelPage extends StatelessWidget { const ChannelPage({ - Key? key, - }) : super(key: key); + super.key, + }); @override Widget build(BuildContext context) => Scaffold( diff --git a/packages/stream_chat_flutter/example/lib/tutorial_part_3.dart b/packages/stream_chat_flutter/example/lib/tutorial_part_3.dart index 7d994ae1..fbadcf0a 100644 --- a/packages/stream_chat_flutter/example/lib/tutorial_part_3.dart +++ b/packages/stream_chat_flutter/example/lib/tutorial_part_3.dart @@ -51,9 +51,9 @@ Future main() async { class MyApp extends StatelessWidget { const MyApp({ - Key? key, + super.key, required this.client, - }) : super(key: key); + }); final StreamChatClient client; @@ -71,8 +71,8 @@ class MyApp extends StatelessWidget { class ChannelListPage extends StatefulWidget { const ChannelListPage({ - Key? key, - }) : super(key: key); + super.key, + }); @override State createState() => _ChannelListPageState(); @@ -164,8 +164,8 @@ class _ChannelListPageState extends State { class ChannelPage extends StatelessWidget { const ChannelPage({ - Key? key, - }) : super(key: key); + super.key, + }); @override Widget build(BuildContext context) { diff --git a/packages/stream_chat_flutter/example/lib/tutorial_part_4.dart b/packages/stream_chat_flutter/example/lib/tutorial_part_4.dart index 376b0ba8..e4886df3 100644 --- a/packages/stream_chat_flutter/example/lib/tutorial_part_4.dart +++ b/packages/stream_chat_flutter/example/lib/tutorial_part_4.dart @@ -38,9 +38,9 @@ Future main() async { class MyApp extends StatelessWidget { const MyApp({ - Key? key, + super.key, required this.client, - }) : super(key: key); + }); final StreamChatClient client; @@ -58,8 +58,8 @@ class MyApp extends StatelessWidget { class ChannelListPage extends StatefulWidget { const ChannelListPage({ - Key? key, - }) : super(key: key); + super.key, + }); @override State createState() => _ChannelListPageState(); @@ -102,8 +102,8 @@ class _ChannelListPageState extends State { class ChannelPage extends StatelessWidget { const ChannelPage({ - Key? key, - }) : super(key: key); + super.key, + }); @override Widget build(BuildContext context) => Scaffold( @@ -125,9 +125,9 @@ class ChannelPage extends StatelessWidget { class ThreadPage extends StatelessWidget { const ThreadPage({ - Key? key, + super.key, this.parent, - }) : super(key: key); + }); final Message? parent; diff --git a/packages/stream_chat_flutter/example/lib/tutorial_part_5.dart b/packages/stream_chat_flutter/example/lib/tutorial_part_5.dart index 7977d3be..ae11a8a0 100644 --- a/packages/stream_chat_flutter/example/lib/tutorial_part_5.dart +++ b/packages/stream_chat_flutter/example/lib/tutorial_part_5.dart @@ -41,9 +41,9 @@ Future main() async { class MyApp extends StatelessWidget { const MyApp({ - Key? key, + super.key, required this.client, - }) : super(key: key); + }); final StreamChatClient client; @@ -61,8 +61,8 @@ class MyApp extends StatelessWidget { class ChannelListPage extends StatefulWidget { const ChannelListPage({ - Key? key, - }) : super(key: key); + super.key, + }); @override State createState() => _ChannelListPageState(); @@ -105,8 +105,8 @@ class _ChannelListPageState extends State { class ChannelPage extends StatelessWidget { const ChannelPage({ - Key? key, - }) : super(key: key); + super.key, + }); @override Widget build(BuildContext context) { @@ -139,7 +139,7 @@ class ChannelPage extends StatelessWidget { return Padding( padding: const EdgeInsets.all(5), - child: Container( + child: DecoratedBox( decoration: BoxDecoration( border: Border.all( color: color, diff --git a/packages/stream_chat_flutter/example/lib/tutorial_part_6.dart b/packages/stream_chat_flutter/example/lib/tutorial_part_6.dart index a3d02a1d..1b416e91 100644 --- a/packages/stream_chat_flutter/example/lib/tutorial_part_6.dart +++ b/packages/stream_chat_flutter/example/lib/tutorial_part_6.dart @@ -48,9 +48,9 @@ Future main() async { class MyApp extends StatelessWidget { const MyApp({ - Key? key, + super.key, required this.client, - }) : super(key: key); + }); final StreamChatClient client; @@ -101,8 +101,8 @@ class MyApp extends StatelessWidget { class ChannelListPage extends StatefulWidget { const ChannelListPage({ - Key? key, - }) : super(key: key); + super.key, + }); @override State createState() => _ChannelListPageState(); @@ -145,8 +145,8 @@ class _ChannelListPageState extends State { class ChannelPage extends StatelessWidget { const ChannelPage({ - Key? key, - }) : super(key: key); + super.key, + }); @override Widget build(BuildContext context) => Scaffold( @@ -168,9 +168,9 @@ class ChannelPage extends StatelessWidget { class ThreadPage extends StatelessWidget { const ThreadPage({ - Key? key, + super.key, this.parent, - }) : super(key: key); + }); final Message? parent; diff --git a/packages/stream_chat_flutter/example/pubspec.yaml b/packages/stream_chat_flutter/example/pubspec.yaml index ead5158a..12a7dc63 100644 --- a/packages/stream_chat_flutter/example/pubspec.yaml +++ b/packages/stream_chat_flutter/example/pubspec.yaml @@ -18,7 +18,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev version: 1.0.0+1 environment: - sdk: '>=2.12.0 <3.0.0' + sdk: '>=2.17.0 <3.0.0' dependencies: # The following adds the Cupertino Icons font to your application. diff --git a/packages/stream_chat_flutter/lib/scrollable_positioned_list/src/positioned_list.dart b/packages/stream_chat_flutter/lib/scrollable_positioned_list/src/positioned_list.dart index bc24ed46..b2549500 100644 --- a/packages/stream_chat_flutter/lib/scrollable_positioned_list/src/positioned_list.dart +++ b/packages/stream_chat_flutter/lib/scrollable_positioned_list/src/positioned_list.dart @@ -320,7 +320,7 @@ class _PositionedListState extends State { void _schedulePositionNotificationUpdate() { if (!updateScheduled) { updateScheduled = true; - SchedulerBinding.instance!.addPostFrameCallback((_) { + SchedulerBinding.instance.addPostFrameCallback((_) { if (registeredElements.value == null) { updateScheduled = false; return; diff --git a/packages/stream_chat_flutter/lib/scrollable_positioned_list/src/scrollable_positioned_list.dart b/packages/stream_chat_flutter/lib/scrollable_positioned_list/src/scrollable_positioned_list.dart index ab3ab00d..d38b4255 100644 --- a/packages/stream_chat_flutter/lib/scrollable_positioned_list/src/scrollable_positioned_list.dart +++ b/packages/stream_chat_flutter/lib/scrollable_positioned_list/src/scrollable_positioned_list.dart @@ -439,7 +439,7 @@ class _ScrollablePositionedListState extends State } if (_isTransitioning) { _stopScroll(canceled: true); - SchedulerBinding.instance!.addPostFrameCallback((_) { + SchedulerBinding.instance.addPostFrameCallback((_) { _startScroll( index: index, alignment: alignment, @@ -488,7 +488,7 @@ class _ScrollablePositionedListState extends State final startCompleter = Completer(); final endCompleter = Completer(); startAnimationCallback = () { - SchedulerBinding.instance!.addPostFrameCallback((_) { + SchedulerBinding.instance.addPostFrameCallback((_) { startAnimationCallback = () {}; opacity.parent = _opacityAnimation(opacityAnimationWeights).animate( diff --git a/packages/stream_chat_flutter/lib/src/attachment/attachment.dart b/packages/stream_chat_flutter/lib/src/attachment/attachment.dart index fb771317..5550004d 100644 --- a/packages/stream_chat_flutter/lib/src/attachment/attachment.dart +++ b/packages/stream_chat_flutter/lib/src/attachment/attachment.dart @@ -1,6 +1,5 @@ export 'attachment_upload_state_builder.dart'; -export 'attachment_widget.dart' - show AttachmentError, AttachmentSource, AttachmentSourceX; +export 'attachment_widget.dart' show AttachmentError, AttachmentSource; export 'file_attachment.dart'; export 'giphy_attachment.dart'; export 'image_attachment.dart'; diff --git a/packages/stream_chat_flutter/lib/src/attachment/attachment_title.dart b/packages/stream_chat_flutter/lib/src/attachment/attachment_title.dart index 6852cdb6..831053b3 100644 --- a/packages/stream_chat_flutter/lib/src/attachment/attachment_title.dart +++ b/packages/stream_chat_flutter/lib/src/attachment/attachment_title.dart @@ -11,10 +11,10 @@ typedef AttachmentTitle = StreamAttachmentTitle; class StreamAttachmentTitle extends StatelessWidget { /// Supply attachment and theme for constructing title const StreamAttachmentTitle({ - Key? key, + super.key, required this.attachment, required this.messageTheme, - }) : super(key: key); + }); /// Theme to apply to text final StreamMessageThemeData messageTheme; diff --git a/packages/stream_chat_flutter/lib/src/attachment/attachment_upload_state_builder.dart b/packages/stream_chat_flutter/lib/src/attachment/attachment_upload_state_builder.dart index a1aa60bc..822e7e79 100644 --- a/packages/stream_chat_flutter/lib/src/attachment/attachment_upload_state_builder.dart +++ b/packages/stream_chat_flutter/lib/src/attachment/attachment_upload_state_builder.dart @@ -19,14 +19,14 @@ typedef AttachmentUploadStateBuilder = StreamAttachmentUploadStateBuilder; class StreamAttachmentUploadStateBuilder extends StatelessWidget { /// Constructor for creating an [StreamAttachmentUploadStateBuilder] widget const StreamAttachmentUploadStateBuilder({ - Key? key, + super.key, required this.message, required this.attachment, this.failedBuilder, this.successBuilder, this.inProgressBuilder, this.preparingBuilder, - }) : super(key: key); + }); /// Message which attachment is added to final Message message; @@ -85,30 +85,24 @@ class StreamAttachmentUploadStateBuilder extends StatelessWidget { class _IconButton extends StatelessWidget { const _IconButton({ - Key? key, this.icon, - this.iconSize = 24.0, this.onPressed, - this.fillColor, - }) : super(key: key); + }); final Widget? icon; - final double iconSize; final VoidCallback? onPressed; - final Color? fillColor; @override Widget build(BuildContext context) => SizedBox( - height: iconSize, - width: iconSize, + height: 24, + width: 24, child: RawMaterialButton( elevation: 0, highlightElevation: 0, focusElevation: 0, hoverElevation: 0, onPressed: onPressed, - fillColor: - fillColor ?? StreamChatTheme.of(context).colorTheme.overlayDark, + fillColor: StreamChatTheme.of(context).colorTheme.overlayDark, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(16), ), @@ -118,10 +112,7 @@ class _IconButton extends StatelessWidget { } class _PreparingState extends StatelessWidget { - const _PreparingState({ - Key? key, - required this.attachmentId, - }) : super(key: key); + const _PreparingState({required this.attachmentId}); final String attachmentId; @@ -155,11 +146,10 @@ class _PreparingState extends StatelessWidget { class _InProgressState extends StatelessWidget { const _InProgressState({ - Key? key, required this.sent, required this.total, required this.attachmentId, - }) : super(key: key); + }); final int sent; final int total; @@ -195,11 +185,10 @@ class _InProgressState extends StatelessWidget { class _FailedState extends StatelessWidget { const _FailedState({ - Key? key, this.error, required this.messageId, required this.attachmentId, - }) : super(key: key); + }); final String? error; final String messageId; @@ -222,7 +211,7 @@ class _FailedState extends StatelessWidget { }, ), Center( - child: Container( + child: DecoratedBox( decoration: BoxDecoration( borderRadius: BorderRadius.circular(12), color: theme.colorTheme.overlayDark.withOpacity(0.6), diff --git a/packages/stream_chat_flutter/lib/src/attachment/attachment_widget.dart b/packages/stream_chat_flutter/lib/src/attachment/attachment_widget.dart index 0021fc76..bf1d0f67 100644 --- a/packages/stream_chat_flutter/lib/src/attachment/attachment_widget.dart +++ b/packages/stream_chat_flutter/lib/src/attachment/attachment_widget.dart @@ -7,14 +7,10 @@ enum AttachmentSource { local, /// Attachment is uploaded - network, -} + network; -/// Extension for identifying type of attachment -extension AttachmentSourceX on AttachmentSource { /// The [when] method is the equivalent to pattern matching. /// Its prototype depends on the AttachmentSource defined. - // ignore: missing_return T when({ required T Function() local, required T Function() network, @@ -38,13 +34,12 @@ typedef AttachmentWidget = StreamAttachmentWidget; abstract class StreamAttachmentWidget extends StatelessWidget { /// Constructor for creating attachment widget const StreamAttachmentWidget({ - Key? key, + super.key, required this.message, required this.attachment, this.size, AttachmentSource? source, - }) : _source = source, - super(key: key); + }) : _source = source; /// Size of attachments final Size? size; @@ -68,9 +63,9 @@ abstract class StreamAttachmentWidget extends StatelessWidget { class AttachmentError extends StatelessWidget { /// Constructor for creating AttachmentError const AttachmentError({ - Key? key, + super.key, this.size, - }) : super(key: key); + }); /// Size of error final Size? size; diff --git a/packages/stream_chat_flutter/lib/src/attachment/file_attachment.dart b/packages/stream_chat_flutter/lib/src/attachment/file_attachment.dart index 6bac62e9..3d0c3314 100644 --- a/packages/stream_chat_flutter/lib/src/attachment/file_attachment.dart +++ b/packages/stream_chat_flutter/lib/src/attachment/file_attachment.dart @@ -20,19 +20,14 @@ typedef FileAttachment = StreamFileAttachment; class StreamFileAttachment extends StreamAttachmentWidget { /// Constructor for creating a widget when attachment is of type 'file' const StreamFileAttachment({ - Key? key, - required Message message, - required Attachment attachment, - Size? size, + super.key, + required super.message, + required super.attachment, + super.size, this.title, this.trailing, this.onAttachmentTap, - }) : super( - key: key, - message: message, - attachment: attachment, - size: size, - ); + }); /// Title for attachment final Widget? title; diff --git a/packages/stream_chat_flutter/lib/src/attachment/giphy_attachment.dart b/packages/stream_chat_flutter/lib/src/attachment/giphy_attachment.dart index dc354432..f788b351 100644 --- a/packages/stream_chat_flutter/lib/src/attachment/giphy_attachment.dart +++ b/packages/stream_chat_flutter/lib/src/attachment/giphy_attachment.dart @@ -15,19 +15,14 @@ typedef GiphyAttachment = StreamGiphyAttachment; class StreamGiphyAttachment extends StreamAttachmentWidget { /// Constructor for creating a [StreamGiphyAttachment] widget const StreamGiphyAttachment({ - Key? key, - required Message message, - required Attachment attachment, - Size? size, + super.key, + required super.message, + required super.attachment, + super.size, this.onShowMessage, this.onReturnAction, this.onAttachmentTap, - }) : super( - key: key, - message: message, - attachment: attachment, - size: size, - ); + }); /// Callback when show message is tapped final ShowMessageCallback? onShowMessage; diff --git a/packages/stream_chat_flutter/lib/src/attachment/image_attachment.dart b/packages/stream_chat_flutter/lib/src/attachment/image_attachment.dart index bb4d8161..c022ee48 100644 --- a/packages/stream_chat_flutter/lib/src/attachment/image_attachment.dart +++ b/packages/stream_chat_flutter/lib/src/attachment/image_attachment.dart @@ -15,21 +15,16 @@ typedef ImageAttachment = StreamImageAttachment; class StreamImageAttachment extends StreamAttachmentWidget { /// Constructor for creating a [StreamImageAttachment] widget const StreamImageAttachment({ - Key? key, - required Message message, - required Attachment attachment, + super.key, + required super.message, + required super.attachment, required this.messageTheme, - Size? size, + super.size, this.showTitle = false, this.onShowMessage, this.onReturnAction, this.onAttachmentTap, - }) : super( - key: key, - message: message, - attachment: attachment, - size: size, - ); + }); /// [StreamMessageThemeData] for showing image title final StreamMessageThemeData messageTheme; diff --git a/packages/stream_chat_flutter/lib/src/attachment/url_attachment.dart b/packages/stream_chat_flutter/lib/src/attachment/url_attachment.dart index 00f29c02..68500d82 100644 --- a/packages/stream_chat_flutter/lib/src/attachment/url_attachment.dart +++ b/packages/stream_chat_flutter/lib/src/attachment/url_attachment.dart @@ -12,7 +12,7 @@ typedef UrlAttachment = StreamUrlAttachment; class StreamUrlAttachment extends StatelessWidget { /// Constructor for creating a [StreamUrlAttachment] const StreamUrlAttachment({ - Key? key, + super.key, required this.urlAttachment, required this.hostDisplayName, required this.messageTheme, @@ -21,7 +21,7 @@ class StreamUrlAttachment extends StatelessWidget { vertical: 8, ), this.onLinkTap, - }) : super(key: key); + }); /// Attachment to be displayed final Attachment urlAttachment; @@ -70,7 +70,7 @@ class StreamUrlAttachment extends StatelessWidget { Positioned( left: 0, bottom: -1, - child: Container( + child: DecoratedBox( decoration: BoxDecoration( borderRadius: const BorderRadius.only( topRight: Radius.circular(16), diff --git a/packages/stream_chat_flutter/lib/src/attachment/video_attachment.dart b/packages/stream_chat_flutter/lib/src/attachment/video_attachment.dart index 620ae66b..31f236e1 100644 --- a/packages/stream_chat_flutter/lib/src/attachment/video_attachment.dart +++ b/packages/stream_chat_flutter/lib/src/attachment/video_attachment.dart @@ -14,20 +14,15 @@ typedef VideoAttachment = StreamVideoAttachment; class StreamVideoAttachment extends StreamAttachmentWidget { /// Constructor for creating a [StreamVideoAttachment] widget const StreamVideoAttachment({ - Key? key, - required Message message, - required Attachment attachment, + super.key, + required super.message, + required super.attachment, required this.messageTheme, - Size? size, + super.size, this.onShowMessage, this.onReturnAction, this.onAttachmentTap, - }) : super( - key: key, - message: message, - attachment: attachment, - size: size, - ); + }); /// [StreamMessageThemeData] for showing title final StreamMessageThemeData messageTheme; diff --git a/packages/stream_chat_flutter/lib/src/attachment_actions_modal.dart b/packages/stream_chat_flutter/lib/src/attachment_actions_modal.dart index cf8e65ca..a3d60483 100644 --- a/packages/stream_chat_flutter/lib/src/attachment_actions_modal.dart +++ b/packages/stream_chat_flutter/lib/src/attachment_actions_modal.dart @@ -19,7 +19,7 @@ typedef DownloadedPathCallback = void Function(String? path); class AttachmentActionsModal extends StatelessWidget { /// Returns a new [AttachmentActionsModal] const AttachmentActionsModal({ - Key? key, + super.key, required this.attachment, required this.message, this.onShowMessage, @@ -30,7 +30,7 @@ class AttachmentActionsModal extends StatelessWidget { this.showSave = true, this.showDelete = true, this.customActions = const [], - }) : super(key: key); + }); /// The attachment object for which the actions are to be performed final Attachment attachment; diff --git a/packages/stream_chat_flutter/lib/src/back_button.dart b/packages/stream_chat_flutter/lib/src/back_button.dart index b7cd4552..6d54695d 100644 --- a/packages/stream_chat_flutter/lib/src/back_button.dart +++ b/packages/stream_chat_flutter/lib/src/back_button.dart @@ -6,11 +6,11 @@ import 'package:stream_chat_flutter/stream_chat_flutter.dart'; class StreamBackButton extends StatelessWidget { /// Constructor for creating back button const StreamBackButton({ - Key? key, + super.key, this.onPressed, this.showUnreads = false, this.cid, - }) : super(key: key); + }); /// Callback for when button is pressed final VoidCallback? onPressed; diff --git a/packages/stream_chat_flutter/lib/src/channel_avatar.dart b/packages/stream_chat_flutter/lib/src/channel_avatar.dart index cf0c74b1..fcd20e68 100644 --- a/packages/stream_chat_flutter/lib/src/channel_avatar.dart +++ b/packages/stream_chat_flutter/lib/src/channel_avatar.dart @@ -52,7 +52,7 @@ import 'package:stream_chat_flutter/stream_chat_flutter.dart'; class ChannelAvatar extends StatelessWidget { /// Instantiate a new ChannelImage const ChannelAvatar({ - Key? key, + super.key, this.channel, this.constraints, this.onTap, @@ -60,7 +60,7 @@ class ChannelAvatar extends StatelessWidget { this.selected = false, this.selectionColor, this.selectionThickness = 4, - }) : super(key: key); + }); /// [BorderRadius] to display the widget final BorderRadius? borderRadius; diff --git a/packages/stream_chat_flutter/lib/src/channel_bottom_sheet.dart b/packages/stream_chat_flutter/lib/src/channel_bottom_sheet.dart index 8b273fe2..a4275f88 100644 --- a/packages/stream_chat_flutter/lib/src/channel_bottom_sheet.dart +++ b/packages/stream_chat_flutter/lib/src/channel_bottom_sheet.dart @@ -7,7 +7,7 @@ import 'package:stream_chat_flutter/stream_chat_flutter.dart'; @Deprecated("Use 'StreamChannelInfoBottomSheet' instead") class ChannelBottomSheet extends StatefulWidget { /// Constructor for creating bottom sheet - const ChannelBottomSheet({Key? key, this.onViewInfoTap}) : super(key: key); + const ChannelBottomSheet({super.key, this.onViewInfoTap}); /// Callback when 'View Info' is tapped final VoidCallback? onViewInfoTap; diff --git a/packages/stream_chat_flutter/lib/src/channel_header.dart b/packages/stream_chat_flutter/lib/src/channel_header.dart index 12f84e1f..8d9205d2 100644 --- a/packages/stream_chat_flutter/lib/src/channel_header.dart +++ b/packages/stream_chat_flutter/lib/src/channel_header.dart @@ -60,7 +60,7 @@ class StreamChannelHeader extends StatelessWidget implements PreferredSizeWidget { /// Creates a channel header const StreamChannelHeader({ - Key? key, + super.key, this.showBackButton = true, this.onBackPressed, this.onTitleTap, @@ -74,8 +74,7 @@ class StreamChannelHeader extends StatelessWidget this.actions, this.backgroundColor, this.elevation = 1, - }) : preferredSize = const Size.fromHeight(kToolbarHeight), - super(key: key); + }) : preferredSize = const Size.fromHeight(kToolbarHeight); /// True if this header shows the leading back button final bool showBackButton; diff --git a/packages/stream_chat_flutter/lib/src/channel_info.dart b/packages/stream_chat_flutter/lib/src/channel_info.dart index b30058b9..2d45d327 100644 --- a/packages/stream_chat_flutter/lib/src/channel_info.dart +++ b/packages/stream_chat_flutter/lib/src/channel_info.dart @@ -13,12 +13,12 @@ typedef ChannelInfo = StreamChannelInfo; class StreamChannelInfo extends StatelessWidget { /// Constructor which creates a [StreamChannelInfo] widget const StreamChannelInfo({ - Key? key, + super.key, required this.channel, this.textStyle, this.showTypingIndicator = true, this.parentId, - }) : super(key: key); + }); /// The channel about which the info is to be displayed final Channel channel; @@ -100,12 +100,10 @@ class StreamChannelInfo extends StatelessWidget { return alternativeWidget ?? const Offstage(); } - return Align( - child: StreamTypingIndicator( - parentId: parentId, - style: textStyle, - alternativeWidget: alternativeWidget, - ), + return StreamTypingIndicator( + parentId: parentId, + style: textStyle, + alternativeWidget: alternativeWidget, ); } @@ -140,7 +138,7 @@ class StreamChannelInfo extends StatelessWidget { ), TextButton( style: TextButton.styleFrom( - padding: const EdgeInsets.all(0), + padding: EdgeInsets.zero, tapTargetSize: MaterialTapTargetSize.shrinkWrap, visualDensity: const VisualDensity( horizontal: VisualDensity.minimumDensity, diff --git a/packages/stream_chat_flutter/lib/src/channel_list_header.dart b/packages/stream_chat_flutter/lib/src/channel_list_header.dart index 4835cad0..0701c08d 100644 --- a/packages/stream_chat_flutter/lib/src/channel_list_header.dart +++ b/packages/stream_chat_flutter/lib/src/channel_list_header.dart @@ -54,7 +54,7 @@ class StreamChannelListHeader extends StatelessWidget implements PreferredSizeWidget { /// Instantiates a ChannelListHeader const StreamChannelListHeader({ - Key? key, + super.key, this.client, this.titleBuilder, this.onUserAvatarTap, @@ -67,7 +67,7 @@ class StreamChannelListHeader extends StatelessWidget this.actions, this.backgroundColor, this.elevation = 1, - }) : super(key: key); + }); /// Pass this if you don't have a [StreamChatClient] in your widget tree. final StreamChatClient? client; @@ -155,9 +155,7 @@ class StreamChannelListHeader extends StatelessWidget showOnlineStatus: false, onTap: onUserAvatarTap ?? (_) { - if (preNavigationCallback != null) { - preNavigationCallback!(); - } + preNavigationCallback?.call(); Scaffold.of(context).openDrawer(); }, borderRadius: channelListHeaderThemeData diff --git a/packages/stream_chat_flutter/lib/src/channel_list_view.dart b/packages/stream_chat_flutter/lib/src/channel_list_view.dart index f70badc1..3f504331 100644 --- a/packages/stream_chat_flutter/lib/src/channel_list_view.dart +++ b/packages/stream_chat_flutter/lib/src/channel_list_view.dart @@ -57,8 +57,9 @@ typedef ViewInfoCallback = void Function(Channel); @Deprecated("Use 'StreamChannelListView' instead") class ChannelListView extends StatefulWidget { /// Instantiate a new ChannelListView + @Deprecated("Use 'StreamChannelListView' instead") ChannelListView({ - Key? key, + super.key, this.filter, this.sort, this.state = true, @@ -93,8 +94,7 @@ class ChannelListView extends StatefulWidget { this.onDeletePressed, this.swipeActions, this.channelListController, - }) : limit = limit ?? pagination?.limit ?? 25, - super(key: key); + }) : limit = limit ?? pagination?.limit ?? 25; /// If true a default swipe to action behaviour will be added to this widget final bool swipeToAction; @@ -688,7 +688,7 @@ class _ChannelListViewState extends State { initialData: false, errorBuilder: (context, err) { final theme = StreamChatTheme.of(context); - return Container( + return ColoredBox( color: theme.colorTheme.textLowEmphasis.withOpacity(0.9), child: Padding( padding: const EdgeInsets.all(16), diff --git a/packages/stream_chat_flutter/lib/src/channel_name.dart b/packages/stream_chat_flutter/lib/src/channel_name.dart index f496b28a..546524c3 100644 --- a/packages/stream_chat_flutter/lib/src/channel_name.dart +++ b/packages/stream_chat_flutter/lib/src/channel_name.dart @@ -10,10 +10,10 @@ import 'package:stream_chat_flutter/stream_chat_flutter.dart'; class ChannelName extends StatelessWidget { /// Instantiate a new ChannelName const ChannelName({ - Key? key, + super.key, this.textStyle, this.textOverflow = TextOverflow.ellipsis, - }) : super(key: key); + }); /// The style of the text displayed final TextStyle? textStyle; diff --git a/packages/stream_chat_flutter/lib/src/channel_preview.dart b/packages/stream_chat_flutter/lib/src/channel_preview.dart index ed5fe9f8..b84979cb 100644 --- a/packages/stream_chat_flutter/lib/src/channel_preview.dart +++ b/packages/stream_chat_flutter/lib/src/channel_preview.dart @@ -25,7 +25,7 @@ class ChannelPreview extends StatelessWidget { /// Constructor for creating [ChannelPreview] const ChannelPreview({ required this.channel, - Key? key, + super.key, this.onTap, this.onLongPress, this.onImageTap, @@ -34,7 +34,7 @@ class ChannelPreview extends StatelessWidget { this.leading, this.sendingIndicator, this.trailing, - }) : super(key: key); + }); /// Function called when tapping this widget final void Function(Channel)? onTap; diff --git a/packages/stream_chat_flutter/lib/src/commands_overlay.dart b/packages/stream_chat_flutter/lib/src/commands_overlay.dart index 6234f696..64121e31 100644 --- a/packages/stream_chat_flutter/lib/src/commands_overlay.dart +++ b/packages/stream_chat_flutter/lib/src/commands_overlay.dart @@ -17,8 +17,8 @@ class StreamCommandsOverlay extends StatelessWidget { required this.onCommandResult, required this.size, required this.channel, - Key? key, - }) : super(key: key); + super.key, + }); /// The size of the overlay final Size size; @@ -60,7 +60,7 @@ class StreamCommandsOverlay extends StatelessWidget { borderRadius: BorderRadius.circular(8), ), child: ListView( - padding: const EdgeInsets.all(0), + padding: EdgeInsets.zero, shrinkWrap: true, children: [ if (commands.isNotEmpty) diff --git a/packages/stream_chat_flutter/lib/src/connection_status_builder.dart b/packages/stream_chat_flutter/lib/src/connection_status_builder.dart index 6f234547..dd47a626 100644 --- a/packages/stream_chat_flutter/lib/src/connection_status_builder.dart +++ b/packages/stream_chat_flutter/lib/src/connection_status_builder.dart @@ -15,12 +15,12 @@ typedef ConnectionStatusBuilder = StreamConnectionStatusBuilder; class StreamConnectionStatusBuilder extends StatelessWidget { /// Creates a new ConnectionStatusBuilder const StreamConnectionStatusBuilder({ - Key? key, + super.key, required this.statusBuilder, this.connectionStatusStream, this.errorBuilder, this.loadingBuilder, - }) : super(key: key); + }); /// The asynchronous computation to which this builder is currently connected. final Stream? connectionStatusStream; diff --git a/packages/stream_chat_flutter/lib/src/date_divider.dart b/packages/stream_chat_flutter/lib/src/date_divider.dart index 64396ceb..6cdb034d 100644 --- a/packages/stream_chat_flutter/lib/src/date_divider.dart +++ b/packages/stream_chat_flutter/lib/src/date_divider.dart @@ -13,10 +13,10 @@ typedef DateDivider = StreamDateDivider; class StreamDateDivider extends StatelessWidget { /// Constructor for creating a [StreamDateDivider] const StreamDateDivider({ - Key? key, + super.key, required this.dateTime, this.uppercase = false, - }) : super(key: key); + }); /// [DateTime] to display final DateTime dateTime; diff --git a/packages/stream_chat_flutter/lib/src/deleted_message.dart b/packages/stream_chat_flutter/lib/src/deleted_message.dart index 667d101d..0e47f903 100644 --- a/packages/stream_chat_flutter/lib/src/deleted_message.dart +++ b/packages/stream_chat_flutter/lib/src/deleted_message.dart @@ -13,13 +13,13 @@ typedef DeletedMessage = StreamDeletedMessage; class StreamDeletedMessage extends StatelessWidget { /// Constructor to create [StreamDeletedMessage] const StreamDeletedMessage({ - Key? key, + super.key, required this.messageTheme, this.borderRadiusGeometry, this.shape, this.borderSide, this.reverse = false, - }) : super(key: key); + }); /// The theme of the message final StreamMessageThemeData messageTheme; diff --git a/packages/stream_chat_flutter/lib/src/emoji_overlay.dart b/packages/stream_chat_flutter/lib/src/emoji_overlay.dart index b4e50974..04af4179 100644 --- a/packages/stream_chat_flutter/lib/src/emoji_overlay.dart +++ b/packages/stream_chat_flutter/lib/src/emoji_overlay.dart @@ -17,8 +17,8 @@ class StreamEmojiOverlay extends StatelessWidget { required this.query, required this.onEmojiResult, required this.size, - Key? key, - }) : super(key: key); + super.key, + }); /// The size of the overlay final Size size; @@ -65,7 +65,7 @@ class StreamEmojiOverlay extends StatelessWidget { color: _streamChatTheme.colorTheme.barsBg, ), child: ListView.builder( - padding: const EdgeInsets.all(0), + padding: EdgeInsets.zero, shrinkWrap: true, itemCount: emojis.length + 1, itemBuilder: (context, i) { diff --git a/packages/stream_chat_flutter/lib/src/full_screen_media.dart b/packages/stream_chat_flutter/lib/src/full_screen_media.dart index 340392b7..cb54c464 100644 --- a/packages/stream_chat_flutter/lib/src/full_screen_media.dart +++ b/packages/stream_chat_flutter/lib/src/full_screen_media.dart @@ -31,15 +31,14 @@ typedef FullScreenMedia = StreamFullScreenMedia; class StreamFullScreenMedia extends StatefulWidget { /// Instantiate a new FullScreenImage const StreamFullScreenMedia({ - Key? key, + super.key, required this.mediaAttachmentPackages, this.startIndex = 0, String? userName, this.onShowMessage, this.attachmentActionsModalBuilder, this.autoplayVideos = false, - }) : userName = userName ?? '', - super(key: key); + }) : userName = userName ?? ''; /// The url of the image final List mediaAttachmentPackages; diff --git a/packages/stream_chat_flutter/lib/src/gallery_footer.dart b/packages/stream_chat_flutter/lib/src/gallery_footer.dart index 24cea1f2..1b78f262 100644 --- a/packages/stream_chat_flutter/lib/src/gallery_footer.dart +++ b/packages/stream_chat_flutter/lib/src/gallery_footer.dart @@ -20,7 +20,7 @@ class StreamGalleryFooter extends StatefulWidget implements PreferredSizeWidget { /// Creates a StreamGalleryFooter const StreamGalleryFooter({ - Key? key, + super.key, this.onBackPressed, this.onTitleTap, this.onImageTap, @@ -29,8 +29,7 @@ class StreamGalleryFooter extends StatefulWidget required this.mediaAttachmentPackages, this.mediaSelectedCallBack, this.backgroundColor, - }) : preferredSize = const Size.fromHeight(kToolbarHeight), - super(key: key); + }) : preferredSize = const Size.fromHeight(kToolbarHeight); /// Callback to call when pressing the back button. /// By default it calls [Navigator.pop] diff --git a/packages/stream_chat_flutter/lib/src/gallery_header.dart b/packages/stream_chat_flutter/lib/src/gallery_header.dart index 4f9b83dc..3b25f969 100644 --- a/packages/stream_chat_flutter/lib/src/gallery_header.dart +++ b/packages/stream_chat_flutter/lib/src/gallery_header.dart @@ -26,7 +26,7 @@ class StreamGalleryHeader extends StatelessWidget implements PreferredSizeWidget { /// Creates a channel header const StreamGalleryHeader({ - Key? key, + super.key, required this.message, required this.attachment, this.showBackButton = true, @@ -38,8 +38,7 @@ class StreamGalleryHeader extends StatelessWidget this.sentAt = '', this.backgroundColor, this.attachmentActionsModalBuilder, - }) : preferredSize = const Size.fromHeight(kToolbarHeight), - super(key: key); + }) : preferredSize = const Size.fromHeight(kToolbarHeight); /// True if this header shows the leading back button final bool showBackButton; diff --git a/packages/stream_chat_flutter/lib/src/gradient_avatar.dart b/packages/stream_chat_flutter/lib/src/gradient_avatar.dart index aca07c92..53249ec4 100644 --- a/packages/stream_chat_flutter/lib/src/gradient_avatar.dart +++ b/packages/stream_chat_flutter/lib/src/gradient_avatar.dart @@ -13,10 +13,10 @@ typedef GradientAvatar = StreamGradientAvatar; class StreamGradientAvatar extends StatefulWidget { /// Constructor for [StreamGradientAvatar] const StreamGradientAvatar({ - Key? key, + super.key, required this.name, required this.userId, - }) : super(key: key); + }); /// Name of user to shorten and display final String name; diff --git a/packages/stream_chat_flutter/lib/src/group_avatar.dart b/packages/stream_chat_flutter/lib/src/group_avatar.dart index f7efa32d..a07d60d8 100644 --- a/packages/stream_chat_flutter/lib/src/group_avatar.dart +++ b/packages/stream_chat_flutter/lib/src/group_avatar.dart @@ -11,7 +11,7 @@ typedef GroupAvatar = StreamGroupAvatar; class StreamGroupAvatar extends StatelessWidget { /// Constructor for creating a [StreamGroupAvatar] const StreamGroupAvatar({ - Key? key, + super.key, this.channel, required this.members, this.constraints, @@ -20,7 +20,7 @@ class StreamGroupAvatar extends StatelessWidget { this.selected = false, this.selectionColor, this.selectionThickness = 4, - }) : super(key: key); + }); /// The channel of the avatar final Channel? channel; diff --git a/packages/stream_chat_flutter/lib/src/image_group.dart b/packages/stream_chat_flutter/lib/src/image_group.dart index 9a803c88..cb8f6edd 100644 --- a/packages/stream_chat_flutter/lib/src/image_group.dart +++ b/packages/stream_chat_flutter/lib/src/image_group.dart @@ -11,7 +11,7 @@ typedef ImageGroup = StreamImageGroup; class StreamImageGroup extends StatelessWidget { /// Constructor for creating [StreamImageGroup] widget const StreamImageGroup({ - Key? key, + super.key, required this.images, required this.message, required this.messageTheme, @@ -19,7 +19,7 @@ class StreamImageGroup extends StatelessWidget { this.onReturnAction, this.onShowMessage, this.onAttachmentTap, - }) : super(key: key); + }); /// List of attachments to show final List images; diff --git a/packages/stream_chat_flutter/lib/src/info_tile.dart b/packages/stream_chat_flutter/lib/src/info_tile.dart index fee76d5c..a100f7e3 100644 --- a/packages/stream_chat_flutter/lib/src/info_tile.dart +++ b/packages/stream_chat_flutter/lib/src/info_tile.dart @@ -12,7 +12,7 @@ typedef InfoTile = StreamInfoTile; class StreamInfoTile extends StatelessWidget { /// Constructor for creating an [StreamInfoTile] widget const StreamInfoTile({ - Key? key, + super.key, required this.message, required this.child, required this.showMessage, @@ -20,7 +20,7 @@ class StreamInfoTile extends StatelessWidget { this.childAnchor, this.textStyle, this.backgroundColor, - }) : super(key: key); + }); /// String to display final String message; diff --git a/packages/stream_chat_flutter/lib/src/localization/translations.dart b/packages/stream_chat_flutter/lib/src/localization/translations.dart index 3d12b73b..3f29704f 100644 --- a/packages/stream_chat_flutter/lib/src/localization/translations.dart +++ b/packages/stream_chat_flutter/lib/src/localization/translations.dart @@ -391,7 +391,7 @@ class DefaultTranslations implements Translations { @override String get sendMessagePermissionError => - 'You don\'t have permission to send messages'; + "You don't have permission to send messages"; @override String get emptyMessagesText => 'There are no messages currently'; @@ -528,7 +528,7 @@ class DefaultTranslations implements Translations { @override String get operationCouldNotBeCompletedText => - 'The operation couldn\'t be completed.'; + "The operation couldn't be completed."; @override String get replyLabel => 'Reply'; diff --git a/packages/stream_chat_flutter/lib/src/media_list_view.dart b/packages/stream_chat_flutter/lib/src/media_list_view.dart index 72378c1c..34b512c4 100644 --- a/packages/stream_chat_flutter/lib/src/media_list_view.dart +++ b/packages/stream_chat_flutter/lib/src/media_list_view.dart @@ -18,11 +18,11 @@ typedef MediaListView = StreamMediaListView; class StreamMediaListView extends StatefulWidget { /// Constructor for creating a [StreamMediaListView] widget const StreamMediaListView({ - Key? key, + super.key, this.selectedIds = const [], this.onSelect, this.controller, - }) : super(key: key); + }); /// Stores the media selected final List selectedIds; @@ -67,11 +67,9 @@ class _StreamMediaListViewState extends State { return Padding( padding: const EdgeInsets.symmetric(horizontal: 1, vertical: 1), child: InkWell( - onTap: () { - if (widget.onSelect != null) { - widget.onSelect!(media); - } - }, + onTap: widget.onSelect == null + ? null + : () => widget.onSelect!(media), child: Stack( children: [ AspectRatio( diff --git a/packages/stream_chat_flutter/lib/src/message_actions_modal.dart b/packages/stream_chat_flutter/lib/src/message_actions_modal.dart index ffd8f386..ec9b8a2e 100644 --- a/packages/stream_chat_flutter/lib/src/message_actions_modal.dart +++ b/packages/stream_chat_flutter/lib/src/message_actions_modal.dart @@ -13,7 +13,7 @@ typedef MessageActionsModal = StreamMessageActionsModal; class StreamMessageActionsModal extends StatefulWidget { /// Constructor for creating a [StreamMessageActionsModal] widget const StreamMessageActionsModal({ - Key? key, + super.key, required this.message, required this.messageWidget, required this.messageTheme, @@ -32,7 +32,7 @@ class StreamMessageActionsModal extends StatefulWidget { this.reverse = false, this.customActions = const [], this.onCopyTap, - }) : super(key: key); + }); /// Widget that shows the message final Widget messageWidget; @@ -252,7 +252,7 @@ class _StreamMessageActionsModalState extends State { sigmaX: 10, sigmaY: 10, ), - child: Container( + child: ColoredBox( color: streamChatThemeData.colorTheme.overlay, ), ), @@ -406,9 +406,7 @@ class _StreamMessageActionsModalState extends State { return InkWell( onTap: () { Navigator.pop(context); - if (widget.onReplyTap != null) { - widget.onReplyTap!(widget.message); - } + widget.onReplyTap?.call(widget.message); }, child: Padding( padding: const EdgeInsets.symmetric(vertical: 11, horizontal: 16), @@ -660,9 +658,7 @@ class _StreamMessageActionsModalState extends State { return InkWell( onTap: () { Navigator.pop(context); - if (widget.onThreadReplyTap != null) { - widget.onThreadReplyTap!(widget.message); - } + widget.onThreadReplyTap?.call(widget.message); }, child: Padding( padding: const EdgeInsets.symmetric(vertical: 11, horizontal: 16), diff --git a/packages/stream_chat_flutter/lib/src/message_input.dart b/packages/stream_chat_flutter/lib/src/message_input.dart index b830ab37..921a54dd 100644 --- a/packages/stream_chat_flutter/lib/src/message_input.dart +++ b/packages/stream_chat_flutter/lib/src/message_input.dart @@ -163,7 +163,7 @@ const _kDefaultMaxAttachmentSize = 20971520; // 20MB in Bytes class MessageInput extends StatefulWidget { /// Instantiate a new MessageInput const MessageInput({ - Key? key, + super.key, this.onMessageSent, this.preMessageSending, this.parentMessage, @@ -197,11 +197,10 @@ class MessageInput extends StatefulWidget { this.customOverlays = const [], this.mentionAllAppUsers = false, this.shouldKeepFocusAfterMessage, - }) : assert( + }) : assert( initialMessage == null || editMessage == null, "Can't provide both `initialMessage` and `editMessage`", - ), - super(key: key); + ); /// List of options for showing overlays final List customOverlays; @@ -628,7 +627,7 @@ class MessageInputState extends State { color: _messageInputTheme.expandButtonColor, ), ), - padding: const EdgeInsets.all(0), + padding: EdgeInsets.zero, constraints: const BoxConstraints.tightFor( height: 24, width: 24, @@ -797,7 +796,7 @@ class MessageInputState extends State { child: IconButton( icon: StreamSvgIcon.closeSmall(), splashRadius: 24, - padding: const EdgeInsets.all(0), + padding: EdgeInsets.zero, constraints: const BoxConstraints.tightFor( height: 24, width: 24, @@ -980,7 +979,7 @@ class MessageInputState extends State { return AnimatedContainer( duration: _openFilePickerSection ? const Duration(milliseconds: 300) - : const Duration(), + : Duration.zero, curve: Curves.easeOut, height: _openFilePickerSection ? _kMinMediaPickerSize : 0, child: SingleChildScrollView( @@ -1034,7 +1033,7 @@ class MessageInputState extends State { }, ), IconButton( - padding: const EdgeInsets.all(0), + padding: EdgeInsets.zero, icon: StreamSvgIcon.record( color: _getIconColor(3), ), @@ -1436,9 +1435,9 @@ class MessageInputState extends State { ], ); default: - return Container( + return const ColoredBox( color: Colors.black26, - child: const Icon(Icons.insert_drive_file), + child: Icon(Icons.insert_drive_file), ); } } @@ -1453,7 +1452,7 @@ class MessageInputState extends State { ? _messageInputTheme.actionButtonColor : _messageInputTheme.actionButtonIdleColor), ), - padding: const EdgeInsets.all(0), + padding: EdgeInsets.zero, constraints: const BoxConstraints.tightFor( height: 24, width: 24, @@ -1482,7 +1481,7 @@ class MessageInputState extends State { ? _messageInputTheme.actionButtonColor : _messageInputTheme.actionButtonIdleColor, ), - padding: const EdgeInsets.all(0), + padding: EdgeInsets.zero, constraints: const BoxConstraints.tightFor( height: 24, width: 24, @@ -1699,7 +1698,7 @@ class MessageInputState extends State { padding: const EdgeInsets.all(8), child: IconButton( onPressed: sendMessage, - padding: const EdgeInsets.all(0), + padding: EdgeInsets.zero, splashRadius: 24, constraints: const BoxConstraints.tightFor( height: 24, @@ -1926,7 +1925,6 @@ class MessageInputState extends State { class _PickerWidget extends StatefulWidget { const _PickerWidget({ - Key? key, required this.filePickerIndex, required this.containsFile, required this.selectedMedias, @@ -1934,7 +1932,7 @@ class _PickerWidget extends StatefulWidget { required this.onMediaSelected, required this.streamChatTheme, required this.mediaListViewController, - }) : super(key: key); + }); final int filePickerIndex; final bool containsFile; @@ -2002,7 +2000,7 @@ class _PickerWidgetState extends State<_PickerWidget> { onTap: () async { PhotoManager.openSetting(); }, - child: Container( + child: ColoredBox( color: widget.streamChatTheme.colorTheme.inputBg, child: Column( mainAxisAlignment: MainAxisAlignment.center, @@ -2040,10 +2038,7 @@ class _PickerWidgetState extends State<_PickerWidget> { } class _CountdownButton extends StatelessWidget { - const _CountdownButton({ - Key? key, - required this.count, - }) : super(key: key); + const _CountdownButton({required this.count}); final int count; diff --git a/packages/stream_chat_flutter/lib/src/message_list_view.dart b/packages/stream_chat_flutter/lib/src/message_list_view.dart index 7d77b2ea..b2256190 100644 --- a/packages/stream_chat_flutter/lib/src/message_list_view.dart +++ b/packages/stream_chat_flutter/lib/src/message_list_view.dart @@ -169,7 +169,7 @@ typedef MessageListView = StreamMessageListView; class StreamMessageListView extends StatefulWidget { /// Instantiate a new StreamMessageListView. const StreamMessageListView({ - Key? key, + super.key, this.showScrollToBottom = true, this.scrollToBottomBuilder, this.messageBuilder, @@ -206,7 +206,7 @@ class StreamMessageListView extends StatefulWidget { this.paginationLoadingIndicatorBuilder, this.keyboardDismissBehavior = ScrollViewKeyboardDismissBehavior.onDrag, this.spacingWidgetBuilder, - }) : super(key: key); + }); /// [ScrollViewKeyboardDismissBehavior] the defines how this [PositionedList] will /// dismiss the keyboard automatically. @@ -751,7 +751,7 @@ class _StreamMessageListViewState extends State { StreamMessageListViewTheme.of(context).backgroundImage; if (backgroundColor != null || backgroundImage != null) { - return Container( + return DecoratedBox( decoration: BoxDecoration( color: backgroundColor, image: backgroundImage, @@ -889,7 +889,7 @@ class _StreamMessageListViewState extends State { initialIndex = 0; await streamChannel!.reloadChannel(); - WidgetsBinding.instance?.addPostFrameCallback((_) { + WidgetsBinding.instance.addPostFrameCallback((_) { _scrollController!.jumpTo(index: 0); }); } else { @@ -1039,9 +1039,7 @@ class _StreamMessageListViewState extends State { } }, onMessageTap: (message) { - if (widget.onMessageTap != null) { - widget.onMessageTap!(message); - } + widget.onMessageTap?.call(message); FocusScope.of(context).unfocus(); }, showPinButton: currentUserMember != null && @@ -1066,9 +1064,7 @@ class _StreamMessageListViewState extends State { StreamSystemMessage( message: message, onMessageTap: (message) { - if (widget.onSystemMessageTap != null) { - widget.onSystemMessageTap!(message); - } + widget.onSystemMessageTap?.call(message); FocusScope.of(context).unfocus(); }, ); @@ -1230,9 +1226,7 @@ class _StreamMessageListViewState extends State { } }, onMessageTap: (message) { - if (widget.onMessageTap != null) { - widget.onMessageTap!(message); - } + widget.onMessageTap?.call(message); FocusScope.of(context).unfocus(); }, showPinButton: currentUserMember != null && @@ -1287,8 +1281,8 @@ class _StreamMessageListViewState extends State { ), duration: const Duration(seconds: 3), onEnd: () => initialMessageHighlightComplete = true, - builder: (_, color, child) => Container( - color: color, + builder: (_, color, child) => ColoredBox( + color: color!, child: child, ), child: Padding( @@ -1341,7 +1335,7 @@ class _StreamMessageListViewState extends State { if (event.message?.parentId == widget.parentMessage?.id && event.message!.user!.id == streamChannel!.channel.client.state.currentUser!.id) { - WidgetsBinding.instance!.addPostFrameCallback((_) { + WidgetsBinding.instance.addPostFrameCallback((_) { _scrollController?.scrollTo( index: 0, duration: const Duration(seconds: 1), @@ -1389,11 +1383,10 @@ class _StreamMessageListViewState extends State { void _getOnThreadTap() { if (widget.onThreadTap != null) { _onThreadTap = (Message message) { + final threadBuilder = widget.threadBuilder; widget.onThreadTap!( message, - widget.threadBuilder != null - ? widget.threadBuilder!(context, message) - : null, + threadBuilder != null ? threadBuilder(context, message) : null, ); }; } else if (widget.threadBuilder != null) { @@ -1431,13 +1424,12 @@ class _StreamMessageListViewState extends State { class _LoadingIndicator extends StatelessWidget { const _LoadingIndicator({ - Key? key, required this.streamTheme, required this.isThreadConversation, required this.direction, required this.streamChannel, this.indicatorBuilder, - }) : super(key: key); + }); final StreamChatThemeData streamTheme; final bool isThreadConversation; @@ -1454,7 +1446,7 @@ class _LoadingIndicator extends StatelessWidget { key: Key('LOADING-INDICATOR $direction'), stream: stream, initialData: false, - errorBuilder: (context, error) => Container( + errorBuilder: (context, error) => ColoredBox( color: streamTheme.colorTheme.accentError.withOpacity(0.2), child: Center( child: Text(context.translations.loadingMessagesError), diff --git a/packages/stream_chat_flutter/lib/src/message_reactions_modal.dart b/packages/stream_chat_flutter/lib/src/message_reactions_modal.dart index f862048b..e4317b01 100644 --- a/packages/stream_chat_flutter/lib/src/message_reactions_modal.dart +++ b/packages/stream_chat_flutter/lib/src/message_reactions_modal.dart @@ -15,14 +15,14 @@ typedef MessageReactionsModal = StreamMessageReactionsModal; class StreamMessageReactionsModal extends StatelessWidget { /// Constructor for creating a [StreamMessageReactionsModal] reactions const StreamMessageReactionsModal({ - Key? key, + super.key, required this.message, required this.messageWidget, required this.messageTheme, this.showReactions, this.reverse = false, this.onUserAvatarTap, - }) : super(key: key); + }); /// Widget that shows the message final Widget messageWidget; diff --git a/packages/stream_chat_flutter/lib/src/message_search_item.dart b/packages/stream_chat_flutter/lib/src/message_search_item.dart index f8721d13..824c96a1 100644 --- a/packages/stream_chat_flutter/lib/src/message_search_item.dart +++ b/packages/stream_chat_flutter/lib/src/message_search_item.dart @@ -16,11 +16,11 @@ import 'package:stream_chat_flutter/stream_chat_flutter.dart'; class MessageSearchItem extends StatelessWidget { /// Instantiate a new MessageSearchItem const MessageSearchItem({ - Key? key, + super.key, required this.getMessageResponse, this.onTap, this.showOnlineStatus = true, - }) : super(key: key); + }); /// [Message] displayed final GetMessageResponse getMessageResponse; diff --git a/packages/stream_chat_flutter/lib/src/message_search_list_view.dart b/packages/stream_chat_flutter/lib/src/message_search_list_view.dart index 4cc436f4..665b23d0 100644 --- a/packages/stream_chat_flutter/lib/src/message_search_list_view.dart +++ b/packages/stream_chat_flutter/lib/src/message_search_list_view.dart @@ -54,8 +54,9 @@ typedef EmptyMessageSearchBuilder = Widget Function( @Deprecated("Use 'StreamMessageSearchListView' instead") class MessageSearchListView extends StatefulWidget { /// Instantiate a new MessageSearchListView + @Deprecated("Use 'StreamMessageSearchListView' instead") const MessageSearchListView({ - Key? key, + super.key, required this.filters, this.messageQuery, this.sortOptions, @@ -72,7 +73,7 @@ class MessageSearchListView extends StatefulWidget { this.loadingBuilder, this.childBuilder, this.messageSearchListController, - }) : super(key: key); + }); /// Message String to search on final String? messageQuery; @@ -238,7 +239,7 @@ class _MessageSearchListViewState extends State { initialData: false, builder: (context, snapshot) { if (snapshot.hasError) { - return Container( + return ColoredBox( color: StreamChatTheme.of(context) .colorTheme .accentError diff --git a/packages/stream_chat_flutter/lib/src/message_text.dart b/packages/stream_chat_flutter/lib/src/message_text.dart index b6fee801..bb45aaa1 100644 --- a/packages/stream_chat_flutter/lib/src/message_text.dart +++ b/packages/stream_chat_flutter/lib/src/message_text.dart @@ -14,12 +14,12 @@ typedef MessageText = StreamMessageText; class StreamMessageText extends StatelessWidget { /// Constructor for creating a [StreamMessageText] widget const StreamMessageText({ - Key? key, + super.key, required this.message, required this.messageTheme, this.onMentionTap, this.onLinkTap, - }) : super(key: key); + }); /// Message whose text is to be displayed final Message message; diff --git a/packages/stream_chat_flutter/lib/src/message_widget.dart b/packages/stream_chat_flutter/lib/src/message_widget.dart index ae6e652c..cebe9318 100644 --- a/packages/stream_chat_flutter/lib/src/message_widget.dart +++ b/packages/stream_chat_flutter/lib/src/message_widget.dart @@ -52,7 +52,7 @@ typedef MessageWidget = StreamMessageWidget; class StreamMessageWidget extends StatefulWidget { /// Creates a new instance of the message widget. StreamMessageWidget({ - Key? key, + super.key, required this.message, required this.messageTheme, this.reverse = false, @@ -105,7 +105,7 @@ class StreamMessageWidget extends StatefulWidget { this.customActions = const [], this.onAttachmentTap, this.usernameBuilder, - }) : attachmentBuilders = { + }) : attachmentBuilders = { 'image': (context, message, attachments) { final border = RoundedRectangleBorder( borderRadius: attachmentBorderRadiusGeometry ?? BorderRadius.zero, @@ -261,8 +261,7 @@ class StreamMessageWidget extends StatefulWidget { .toList(), ); }, - }..addAll(customAttachmentBuilders ?? {}), - super(key: key); + }..addAll(customAttachmentBuilders ?? {}); /// Function called on mention tap final void Function(User)? onMentionTap; @@ -878,7 +877,7 @@ class _StreamMessageWidgetState extends State const Offstage(); } - final children = []; + final children = []; final threadParticipants = widget.message.threadParticipants?.take(2); final showThreadParticipants = threadParticipants?.isNotEmpty == true; @@ -909,68 +908,72 @@ class _StreamMessageWidgetState extends State const usernameKey = Key('username'); children.addAll([ - if (showUsername) _buildUsername(usernameKey), + if (showUsername) WidgetSpan(child: _buildUsername(usernameKey)), if (showTimeStamp) - Text( - Jiffy(widget.message.createdAt.toLocal()).jm, - style: widget.messageTheme.createdAtStyle, + WidgetSpan( + child: Text( + Jiffy(widget.message.createdAt.toLocal()).jm, + style: widget.messageTheme.createdAtStyle, + ), + ), + if (showSendingIndicator) + WidgetSpan( + child: _buildSendingIndicator(), ), - if (showSendingIndicator) _buildSendingIndicator(), ]); final showThreadTail = !(hasUrlAttachments || isGiphy || isOnlyEmoji) && (showThreadReplyIndicator || showInChannel); - final threadIndicatorWidgets = [ + final threadIndicatorWidgets = [ if (showThreadTail) - Container( - margin: EdgeInsets.only( - bottom: context.textScaleFactor * - ((widget.messageTheme.repliesStyle?.fontSize ?? 1) / 2), - ), - child: CustomPaint( - size: const Size(16, 32) * context.textScaleFactor, - painter: _ThreadReplyPainter( - context: context, - color: widget.messageTheme.messageBorderColor, - reverse: widget.reverse, + WidgetSpan( + child: Container( + margin: EdgeInsets.only( + bottom: context.textScaleFactor * + ((widget.messageTheme.repliesStyle?.fontSize ?? 1) / 2), + ), + child: CustomPaint( + size: const Size(16, 32) * context.textScaleFactor, + painter: _ThreadReplyPainter( + context: context, + color: widget.messageTheme.messageBorderColor, + reverse: widget.reverse, + ), ), ), ), if (showInChannel || showThreadReplyIndicator) ...[ if (showThreadParticipants) - SizedBox.fromSize( - size: Size((threadParticipants!.length * 8.0) + 8, 16), - child: _buildThreadParticipantsIndicator(threadParticipants), + WidgetSpan( + child: SizedBox.fromSize( + size: Size((threadParticipants!.length * 8.0) + 8, 16), + child: _buildThreadParticipantsIndicator(threadParticipants), + ), + ), + WidgetSpan( + child: InkWell( + onTap: widget.onThreadTap != null ? onThreadTap : null, + child: Text(msg, style: widget.messageTheme.repliesStyle), ), - InkWell( - onTap: widget.onThreadTap != null ? onThreadTap : null, - child: Text(msg, style: widget.messageTheme.repliesStyle), ), ], ]; - return Row( - crossAxisAlignment: CrossAxisAlignment.end, - mainAxisAlignment: - widget.reverse ? MainAxisAlignment.end : MainAxisAlignment.start, - children: [ - if (showThreadTail && !widget.reverse) ...threadIndicatorWidgets, - ...children.map( - (child) { - Widget mappedChild = SizedBox( - height: context.textScaleFactor * 14, - child: child, - ); - if (child.key == usernameKey) { - mappedChild = Flexible(child: mappedChild); - } - return mappedChild; - }, - ), - if (showThreadTail && widget.reverse) - ...threadIndicatorWidgets.reversed, - ].insertBetween(const SizedBox(width: 8)), + if (widget.reverse) { + children.addAll(threadIndicatorWidgets.reversed); + } else { + children.insertAll(0, threadIndicatorWidgets); + } + + return Text.rich( + TextSpan( + children: [ + ...children, + ].insertBetween(const WidgetSpan(child: SizedBox(width: 8))), + ), + maxLines: 1, + textAlign: widget.reverse ? TextAlign.right : TextAlign.left, ); } @@ -1076,7 +1079,7 @@ class _StreamMessageWidgetState extends State showTimestamp: false, translateUserAvatar: false, showSendingIndicator: false, - padding: const EdgeInsets.all(0), + padding: EdgeInsets.zero, showReactionPickerIndicator: widget.showReactions && (widget.message.status == MessageSendingStatus.sent) && channel.ownCapabilities.contains(PermissionType.sendReaction), @@ -1107,6 +1110,13 @@ class _StreamMessageWidgetState extends State widget.onThreadTap != null, showFlagButton: widget.showFlagButton, customActions: widget.customActions, + showDeleteMessage: widget.showDeleteMessage || isDeleteFailed, + showEditMessage: widget.showEditMessage && + !isDeleteFailed && + !widget.message.attachments + .any((element) => element.type == 'giphy'), + showPinButton: widget.showPinButton, + showReactions: widget.showReactions, ), ), ); @@ -1133,7 +1143,7 @@ class _StreamMessageWidgetState extends State showTimestamp: false, translateUserAvatar: false, showSendingIndicator: false, - padding: const EdgeInsets.all(0), + padding: EdgeInsets.zero, showReactionPickerIndicator: widget.showReactions && (widget.message.status == MessageSendingStatus.sent) && channel.ownCapabilities.contains(PermissionType.sendReaction), @@ -1259,6 +1269,7 @@ class _StreamMessageWidgetState extends State ); if (isMessageRead) { child = Row( + mainAxisSize: MainAxisSize.min, children: [ if (memberCount > 2) Text( @@ -1396,11 +1407,9 @@ class _StreamMessageWidgetState extends State class _ThreadParticipants extends StatelessWidget { const _ThreadParticipants({ - Key? key, required StreamChatThemeData streamChatTheme, required this.threadParticipants, - }) : _streamChatTheme = streamChatTheme, - super(key: key); + }) : _streamChatTheme = streamChatTheme; final StreamChatThemeData _streamChatTheme; final Iterable threadParticipants; @@ -1423,7 +1432,7 @@ class _ThreadParticipants extends StatelessWidget { padding: const EdgeInsets.all(1), child: StreamUserAvatar( user: user, - constraints: BoxConstraints.loose(const Size.fromRadius(7)), + constraints: BoxConstraints.tight(const Size.fromRadius(7)), showOnlineStatus: false, ), ), diff --git a/packages/stream_chat_flutter/lib/src/multi_overlay.dart b/packages/stream_chat_flutter/lib/src/multi_overlay.dart index 71ed18d2..ef3757c8 100644 --- a/packages/stream_chat_flutter/lib/src/multi_overlay.dart +++ b/packages/stream_chat_flutter/lib/src/multi_overlay.dart @@ -17,12 +17,12 @@ class StreamMultiOverlay extends StatelessWidget { /// [childAnchor] - the anchor relative to the child /// [child] - the child widget const StreamMultiOverlay({ - Key? key, + super.key, required this.overlayOptions, required this.child, required this.overlayAnchor, required this.childAnchor, - }) : super(key: key); + }); /// The list of overlay options final List overlayOptions; diff --git a/packages/stream_chat_flutter/lib/src/option_list_tile.dart b/packages/stream_chat_flutter/lib/src/option_list_tile.dart index 185d40f8..c7e8bec0 100644 --- a/packages/stream_chat_flutter/lib/src/option_list_tile.dart +++ b/packages/stream_chat_flutter/lib/src/option_list_tile.dart @@ -11,7 +11,7 @@ typedef OptionListTile = StreamOptionListTile; class StreamOptionListTile extends StatelessWidget { /// Constructor for creating [StreamOptionListTile] const StreamOptionListTile({ - Key? key, + super.key, required this.title, this.leading, this.trailing, @@ -20,7 +20,7 @@ class StreamOptionListTile extends StatelessWidget { this.tileColor, this.separatorColor, this.titleTextStyle, - }) : super(key: key); + }); /// Title for tile final String title; 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 1a7bb2d0..44122b65 100644 --- a/packages/stream_chat_flutter/lib/src/quoted_message_widget.dart +++ b/packages/stream_chat_flutter/lib/src/quoted_message_widget.dart @@ -18,7 +18,7 @@ typedef QuotedMessageWidget = StreamQuotedMessageWidget; class StreamQuotedMessageWidget extends StatelessWidget { /// Creates a new instance of the widget. const StreamQuotedMessageWidget({ - Key? key, + super.key, required this.message, required this.messageTheme, this.reverse = false, @@ -27,7 +27,7 @@ class StreamQuotedMessageWidget extends StatelessWidget { this.attachmentThumbnailBuilders, this.padding = const EdgeInsets.all(8), this.onTap, - }) : super(key: key); + }); /// The message final Message message; @@ -251,12 +251,10 @@ class StreamQuotedMessageWidget extends StatelessWidget { class _VideoAttachmentThumbnail extends StatefulWidget { const _VideoAttachmentThumbnail({ - Key? key, + super.key, required this.attachment, - this.size = const Size(32, 32), - }) : super(key: key); + }); - final Size size; final Attachment attachment; @override @@ -285,8 +283,8 @@ class _VideoAttachmentThumbnailState extends State<_VideoAttachmentThumbnail> { @override Widget build(BuildContext context) => SizedBox( - height: widget.size.height, - width: widget.size.width, + height: 32, + width: 32, child: _controller.value.isInitialized ? VideoPlayer(_controller) : const CircularProgressIndicator(), diff --git a/packages/stream_chat_flutter/lib/src/reaction_bubble.dart b/packages/stream_chat_flutter/lib/src/reaction_bubble.dart index 99585001..2944482c 100644 --- a/packages/stream_chat_flutter/lib/src/reaction_bubble.dart +++ b/packages/stream_chat_flutter/lib/src/reaction_bubble.dart @@ -14,7 +14,7 @@ typedef ReactionBubble = StreamReactionBubble; class StreamReactionBubble extends StatelessWidget { /// Constructor for creating a [StreamReactionBubble] const StreamReactionBubble({ - Key? key, + super.key, required this.reactions, required this.borderColor, required this.backgroundColor, @@ -23,7 +23,7 @@ class StreamReactionBubble extends StatelessWidget { this.flipTail = false, this.highlightOwnReactions = true, this.tailCirclesSpacing = 0, - }) : super(key: key); + }); /// Reactions to show final List reactions; diff --git a/packages/stream_chat_flutter/lib/src/reaction_picker.dart b/packages/stream_chat_flutter/lib/src/reaction_picker.dart index 28053c01..a6eaab39 100644 --- a/packages/stream_chat_flutter/lib/src/reaction_picker.dart +++ b/packages/stream_chat_flutter/lib/src/reaction_picker.dart @@ -19,9 +19,9 @@ typedef ReactionPicker = StreamReactionPicker; class StreamReactionPicker extends StatefulWidget { /// Constructor for creating a [StreamReactionPicker] widget const StreamReactionPicker({ - Key? key, + super.key, required this.message, - }) : super(key: key); + }); /// Message to attach the reaction to final Message message; diff --git a/packages/stream_chat_flutter/lib/src/sending_indicator.dart b/packages/stream_chat_flutter/lib/src/sending_indicator.dart index 908c734d..0d4d7dec 100644 --- a/packages/stream_chat_flutter/lib/src/sending_indicator.dart +++ b/packages/stream_chat_flutter/lib/src/sending_indicator.dart @@ -11,11 +11,11 @@ typedef SendingIndicator = StreamSendingIndicator; class StreamSendingIndicator extends StatelessWidget { /// Constructor for creating a [StreamSendingIndicator] widget const StreamSendingIndicator({ - Key? key, + super.key, required this.message, this.isMessageRead = false, this.size = 12, - }) : super(key: key); + }); /// Message for sending indicator final Message message; diff --git a/packages/stream_chat_flutter/lib/src/stream_chat.dart b/packages/stream_chat_flutter/lib/src/stream_chat.dart index acc829e2..80176911 100644 --- a/packages/stream_chat_flutter/lib/src/stream_chat.dart +++ b/packages/stream_chat_flutter/lib/src/stream_chat.dart @@ -28,14 +28,14 @@ import 'package:stream_chat_flutter/stream_chat_flutter.dart'; class StreamChat extends StatefulWidget { /// Constructor for creating a [StreamChat] widget const StreamChat({ - Key? key, + super.key, required this.client, required this.child, this.streamChatThemeData, this.onBackgroundEventReceived, this.backgroundKeepAlive = const Duration(minutes: 1), this.connectivityStream, - }) : super(key: key); + }); /// Client to do chat ops with final StreamChatClient client; diff --git a/packages/stream_chat_flutter/lib/src/stream_chat_theme.dart b/packages/stream_chat_flutter/lib/src/stream_chat_theme.dart index 32b4830f..e3f44d22 100644 --- a/packages/stream_chat_flutter/lib/src/stream_chat_theme.dart +++ b/packages/stream_chat_flutter/lib/src/stream_chat_theme.dart @@ -5,19 +5,16 @@ import 'package:stream_chat_flutter/stream_chat_flutter.dart'; class StreamChatTheme extends InheritedWidget { /// Constructor for creating a [StreamChatTheme] const StreamChatTheme({ - Key? key, + super.key, required this.data, - required Widget child, - }) : super( - key: key, - child: child, - ); + required super.child, + }); /// Theme data final StreamChatThemeData data; @override - bool updateShouldNotify(StreamChatTheme old) => data != old.data; + bool updateShouldNotify(StreamChatTheme oldWidget) => data != oldWidget.data; /// Use this method to get the current [StreamChatThemeData] instance static StreamChatThemeData of(BuildContext context) { diff --git a/packages/stream_chat_flutter/lib/src/stream_neumorphic_button.dart b/packages/stream_chat_flutter/lib/src/stream_neumorphic_button.dart index 5867a4a1..b967f7e4 100644 --- a/packages/stream_chat_flutter/lib/src/stream_neumorphic_button.dart +++ b/packages/stream_chat_flutter/lib/src/stream_neumorphic_button.dart @@ -4,10 +4,10 @@ import 'package:flutter/material.dart'; class StreamNeumorphicButton extends StatelessWidget { /// Constructor for creating [StreamNeumorphicButton] const StreamNeumorphicButton({ - Key? key, + super.key, required this.child, this.backgroundColor = Colors.white, - }) : super(key: key); + }); /// Child contained in the button final Widget child; diff --git a/packages/stream_chat_flutter/lib/src/stream_svg_icon.dart b/packages/stream_chat_flutter/lib/src/stream_svg_icon.dart index 06b3b9a4..efe5a33e 100644 --- a/packages/stream_chat_flutter/lib/src/stream_svg_icon.dart +++ b/packages/stream_chat_flutter/lib/src/stream_svg_icon.dart @@ -5,12 +5,12 @@ import 'package:flutter_svg/flutter_svg.dart'; class StreamSvgIcon extends StatelessWidget { /// Constructor for creating a [StreamSvgIcon] const StreamSvgIcon({ - Key? key, + super.key, this.assetName, this.color, this.width = 24, this.height = 24, - }) : super(key: key); + }); /// [StreamSvgIcon] type factory StreamSvgIcon.settings({ diff --git a/packages/stream_chat_flutter/lib/src/swipeable.dart b/packages/stream_chat_flutter/lib/src/swipeable.dart index 041111e4..8d36f36c 100644 --- a/packages/stream_chat_flutter/lib/src/swipeable.dart +++ b/packages/stream_chat_flutter/lib/src/swipeable.dart @@ -7,14 +7,14 @@ import 'package:stream_chat_flutter/stream_chat_flutter.dart'; class Swipeable extends StatefulWidget { /// Constructor for creating a [Swipeable] widget const Swipeable({ - Key? key, + super.key, required this.child, required this.backgroundIcon, this.onSwipeStart, this.onSwipeCancel, this.onSwipeEnd, this.threshold = 82.0, - }) : super(key: key); + }); /// Child to make swipeable final Widget child; @@ -77,9 +77,7 @@ class _SwipeableState extends State with TickerProviderStateMixin { } void _handleDragStart(DragStartDetails details) { - if (widget.onSwipeStart != null) { - widget.onSwipeStart!(); - } + widget.onSwipeStart?.call(); } void _handleDragUpdate(DragUpdateDetails details) { diff --git a/packages/stream_chat_flutter/lib/src/system_message.dart b/packages/stream_chat_flutter/lib/src/system_message.dart index 4ec10aa4..1f720db2 100644 --- a/packages/stream_chat_flutter/lib/src/system_message.dart +++ b/packages/stream_chat_flutter/lib/src/system_message.dart @@ -11,10 +11,10 @@ typedef SystemMessage = StreamSystemMessage; class StreamSystemMessage extends StatelessWidget { /// Constructor for creating a [StreamSystemMessage] const StreamSystemMessage({ - Key? key, + super.key, required this.message, this.onMessageTap, - }) : super(key: key); + }); /// This message final Message message; @@ -28,11 +28,7 @@ class StreamSystemMessage extends StatelessWidget { final theme = StreamChatTheme.of(context); return GestureDetector( behavior: HitTestBehavior.opaque, - onTap: () { - if (onMessageTap != null) { - onMessageTap!(message); - } - }, + onTap: onMessageTap == null ? null : () => onMessageTap!(message), child: Text( message.text!, textAlign: TextAlign.center, diff --git a/packages/stream_chat_flutter/lib/src/theme/channel_header_theme.dart b/packages/stream_chat_flutter/lib/src/theme/channel_header_theme.dart index aa988c0f..8a7b6d11 100644 --- a/packages/stream_chat_flutter/lib/src/theme/channel_header_theme.dart +++ b/packages/stream_chat_flutter/lib/src/theme/channel_header_theme.dart @@ -20,10 +20,10 @@ class StreamChannelHeaderTheme extends InheritedTheme { /// /// The [data] parameter must not be null. const StreamChannelHeaderTheme({ - Key? key, + super.key, required this.data, - required Widget child, - }) : super(key: key, child: child); + required super.child, + }); /// The configuration of this theme. final StreamChannelHeaderThemeData data; diff --git a/packages/stream_chat_flutter/lib/src/theme/channel_list_header_theme.dart b/packages/stream_chat_flutter/lib/src/theme/channel_list_header_theme.dart index 87ba0127..265b2626 100644 --- a/packages/stream_chat_flutter/lib/src/theme/channel_list_header_theme.dart +++ b/packages/stream_chat_flutter/lib/src/theme/channel_list_header_theme.dart @@ -20,10 +20,10 @@ class StreamChannelListHeaderTheme extends InheritedTheme { /// /// The [data] parameter must not be null. const StreamChannelListHeaderTheme({ - Key? key, + super.key, required this.data, - required Widget child, - }) : super(key: key, child: child); + required super.child, + }); /// The configuration of this theme. final StreamChannelListHeaderThemeData data; diff --git a/packages/stream_chat_flutter/lib/src/theme/channel_list_view_theme.dart b/packages/stream_chat_flutter/lib/src/theme/channel_list_view_theme.dart index d3ed33eb..683f1d0d 100644 --- a/packages/stream_chat_flutter/lib/src/theme/channel_list_view_theme.dart +++ b/packages/stream_chat_flutter/lib/src/theme/channel_list_view_theme.dart @@ -18,10 +18,10 @@ class StreamChannelListViewTheme extends InheritedTheme { /// /// The [data] parameter must not be null. const StreamChannelListViewTheme({ - Key? key, + super.key, required this.data, - required Widget child, - }) : super(key: key, child: child); + required super.child, + }); /// The configuration of this theme. final StreamChannelListViewThemeData data; diff --git a/packages/stream_chat_flutter/lib/src/theme/channel_preview_theme.dart b/packages/stream_chat_flutter/lib/src/theme/channel_preview_theme.dart index e89ce4a6..0a041b67 100644 --- a/packages/stream_chat_flutter/lib/src/theme/channel_preview_theme.dart +++ b/packages/stream_chat_flutter/lib/src/theme/channel_preview_theme.dart @@ -19,10 +19,10 @@ class StreamChannelPreviewTheme extends InheritedTheme { /// /// The [data] parameter must not be null. const StreamChannelPreviewTheme({ - Key? key, + super.key, required this.data, - required Widget child, - }) : super(key: key, child: child); + required super.child, + }); /// The configuration of this theme. final StreamChannelPreviewThemeData data; diff --git a/packages/stream_chat_flutter/lib/src/theme/gallery_footer_theme.dart b/packages/stream_chat_flutter/lib/src/theme/gallery_footer_theme.dart index f68ceb45..f23bb317 100644 --- a/packages/stream_chat_flutter/lib/src/theme/gallery_footer_theme.dart +++ b/packages/stream_chat_flutter/lib/src/theme/gallery_footer_theme.dart @@ -18,10 +18,10 @@ class StreamGalleryFooterTheme extends InheritedTheme { /// /// The [data] parameter must not be null. const StreamGalleryFooterTheme({ - Key? key, + super.key, required this.data, - required Widget child, - }) : super(key: key, child: child); + required super.child, + }); /// The configuration of this theme. final StreamGalleryFooterThemeData data; diff --git a/packages/stream_chat_flutter/lib/src/theme/gallery_header_theme.dart b/packages/stream_chat_flutter/lib/src/theme/gallery_header_theme.dart index f03ebe9a..c190ebfe 100644 --- a/packages/stream_chat_flutter/lib/src/theme/gallery_header_theme.dart +++ b/packages/stream_chat_flutter/lib/src/theme/gallery_header_theme.dart @@ -18,10 +18,10 @@ class StreamGalleryHeaderTheme extends InheritedTheme { /// /// The [data] parameter must not be null. const StreamGalleryHeaderTheme({ - Key? key, + super.key, required this.data, - required Widget child, - }) : super(key: key, child: child); + required super.child, + }); /// The configuration of this theme. final StreamGalleryHeaderThemeData data; diff --git a/packages/stream_chat_flutter/lib/src/theme/message_input_theme.dart b/packages/stream_chat_flutter/lib/src/theme/message_input_theme.dart index bd78bd1b..f99831a0 100644 --- a/packages/stream_chat_flutter/lib/src/theme/message_input_theme.dart +++ b/packages/stream_chat_flutter/lib/src/theme/message_input_theme.dart @@ -21,10 +21,10 @@ class StreamMessageInputTheme extends InheritedTheme { /// /// The [data] parameter must not be null. const StreamMessageInputTheme({ - Key? key, + super.key, required this.data, - required Widget child, - }) : super(key: key, child: child); + required super.child, + }); /// The configuration of this theme. final StreamMessageInputThemeData data; diff --git a/packages/stream_chat_flutter/lib/src/theme/message_list_view_theme.dart b/packages/stream_chat_flutter/lib/src/theme/message_list_view_theme.dart index e882a9f6..a8cda568 100644 --- a/packages/stream_chat_flutter/lib/src/theme/message_list_view_theme.dart +++ b/packages/stream_chat_flutter/lib/src/theme/message_list_view_theme.dart @@ -18,10 +18,10 @@ class StreamMessageListViewTheme extends InheritedTheme { /// /// The [data] parameter must not be null. const StreamMessageListViewTheme({ - Key? key, + super.key, required this.data, - required Widget child, - }) : super(key: key, child: child); + required super.child, + }); /// The configuration of this theme. final StreamMessageListViewThemeData data; diff --git a/packages/stream_chat_flutter/lib/src/theme/message_search_list_view_theme.dart b/packages/stream_chat_flutter/lib/src/theme/message_search_list_view_theme.dart index 535846ae..e88cb96c 100644 --- a/packages/stream_chat_flutter/lib/src/theme/message_search_list_view_theme.dart +++ b/packages/stream_chat_flutter/lib/src/theme/message_search_list_view_theme.dart @@ -18,10 +18,10 @@ class StreamMessageSearchListViewTheme extends InheritedTheme { /// /// The [data] parameter must not be null. const StreamMessageSearchListViewTheme({ - Key? key, + super.key, required this.data, - required Widget child, - }) : super(key: key, child: child); + required super.child, + }); /// The configuration of this theme. final StreamMessageSearchListViewThemeData data; diff --git a/packages/stream_chat_flutter/lib/src/theme/user_list_view_theme.dart b/packages/stream_chat_flutter/lib/src/theme/user_list_view_theme.dart index fb57438b..325f9d88 100644 --- a/packages/stream_chat_flutter/lib/src/theme/user_list_view_theme.dart +++ b/packages/stream_chat_flutter/lib/src/theme/user_list_view_theme.dart @@ -18,10 +18,10 @@ class StreamUserListViewTheme extends InheritedTheme { /// /// The [data] parameter must not be null. const StreamUserListViewTheme({ - Key? key, + super.key, required this.data, - required Widget child, - }) : super(key: key, child: child); + required super.child, + }); /// The configuration of this theme. final StreamUserListViewThemeData data; diff --git a/packages/stream_chat_flutter/lib/src/thread_header.dart b/packages/stream_chat_flutter/lib/src/thread_header.dart index f6f77a32..85554eff 100644 --- a/packages/stream_chat_flutter/lib/src/thread_header.dart +++ b/packages/stream_chat_flutter/lib/src/thread_header.dart @@ -66,7 +66,7 @@ class StreamThreadHeader extends StatelessWidget implements PreferredSizeWidget { /// Instantiate a new ThreadHeader const StreamThreadHeader({ - Key? key, + super.key, required this.parent, this.showBackButton = true, this.onBackPressed, @@ -79,8 +79,7 @@ class StreamThreadHeader extends StatelessWidget this.showTypingIndicator = true, this.backgroundColor, this.elevation = 1, - }) : preferredSize = const Size.fromHeight(kToolbarHeight), - super(key: key); + }) : preferredSize = const Size.fromHeight(kToolbarHeight); /// True if this header shows the leading back button final bool showBackButton; @@ -186,13 +185,11 @@ class StreamThreadHeader extends StatelessWidget ), const SizedBox(height: 2), if (showTypingIndicator) - Align( - child: StreamTypingIndicator( - channel: StreamChannel.of(context).channel, - style: channelHeaderTheme.subtitleStyle, - parentId: parent.id, - alternativeWidget: defaultSubtitle, - ), + StreamTypingIndicator( + channel: StreamChannel.of(context).channel, + style: channelHeaderTheme.subtitleStyle, + parentId: parent.id, + alternativeWidget: defaultSubtitle, ) else defaultSubtitle, diff --git a/packages/stream_chat_flutter/lib/src/typing_indicator.dart b/packages/stream_chat_flutter/lib/src/typing_indicator.dart index 1ac99785..dfbceaff 100644 --- a/packages/stream_chat_flutter/lib/src/typing_indicator.dart +++ b/packages/stream_chat_flutter/lib/src/typing_indicator.dart @@ -13,13 +13,13 @@ typedef TypingIndicator = StreamTypingIndicator; class StreamTypingIndicator extends StatelessWidget { /// Instantiate a new TypingIndicator const StreamTypingIndicator({ - Key? key, + super.key, this.channel, this.alternativeWidget, this.style, - this.padding = const EdgeInsets.all(0), + this.padding = EdgeInsets.zero, this.parentId, - }) : super(key: key); + }); /// Style of the text widget final TextStyle? style; diff --git a/packages/stream_chat_flutter/lib/src/unread_indicator.dart b/packages/stream_chat_flutter/lib/src/unread_indicator.dart index bf23db1a..2e5c2ed6 100644 --- a/packages/stream_chat_flutter/lib/src/unread_indicator.dart +++ b/packages/stream_chat_flutter/lib/src/unread_indicator.dart @@ -11,9 +11,9 @@ typedef UnreadIndicator = StreamUnreadIndicator; class StreamUnreadIndicator extends StatelessWidget { /// Constructor for creating an [StreamUnreadIndicator] const StreamUnreadIndicator({ - Key? key, + super.key, this.cid, - }) : super(key: key); + }); /// Channel cid used to retrieve unread count final String? cid; diff --git a/packages/stream_chat_flutter/lib/src/upload_progress_indicator.dart b/packages/stream_chat_flutter/lib/src/upload_progress_indicator.dart index d11e9609..b6e2f97a 100644 --- a/packages/stream_chat_flutter/lib/src/upload_progress_indicator.dart +++ b/packages/stream_chat_flutter/lib/src/upload_progress_indicator.dart @@ -11,7 +11,7 @@ typedef UploadProgressIndicator = StreamUploadProgressIndicator; class StreamUploadProgressIndicator extends StatelessWidget { /// Constructor for creating an [StreamUploadProgressIndicator] const StreamUploadProgressIndicator({ - Key? key, + super.key, required this.uploaded, required this.total, this.progressIndicatorColor = const Color(0xffb2b2b2), @@ -23,7 +23,7 @@ class StreamUploadProgressIndicator extends StatelessWidget { ), this.showBackground = true, this.textStyle, - }) : super(key: key); + }); /// Bytes uploaded final int uploaded; @@ -72,7 +72,7 @@ class StreamUploadProgressIndicator extends StatelessWidget { ), ); if (showBackground) { - child = Container( + child = DecoratedBox( decoration: BoxDecoration( borderRadius: BorderRadius.circular(12), color: theme.colorTheme.overlayDark.withOpacity(0.6), diff --git a/packages/stream_chat_flutter/lib/src/user_avatar.dart b/packages/stream_chat_flutter/lib/src/user_avatar.dart index 8d634039..406f966f 100644 --- a/packages/stream_chat_flutter/lib/src/user_avatar.dart +++ b/packages/stream_chat_flutter/lib/src/user_avatar.dart @@ -12,7 +12,7 @@ typedef UserAvatar = StreamUserAvatar; class StreamUserAvatar extends StatelessWidget { /// Constructor to create a [StreamUserAvatar] const StreamUserAvatar({ - Key? key, + super.key, required this.user, this.constraints, this.onlineIndicatorConstraints, @@ -25,7 +25,7 @@ class StreamUserAvatar extends StatelessWidget { this.selectionColor, this.selectionThickness = 4, this.placeholder, - }) : super(key: key); + }); /// User whose avatar is to displayed final User user; @@ -91,7 +91,7 @@ class StreamUserAvatar extends StatelessWidget { placeholder: placeholder != null ? (context, __) => placeholder(context, user) : null, - imageBuilder: (context, imageProvider) => Container( + imageBuilder: (context, imageProvider) => DecoratedBox( decoration: BoxDecoration( borderRadius: borderRadius ?? streamChatTheme diff --git a/packages/stream_chat_flutter/lib/src/user_item.dart b/packages/stream_chat_flutter/lib/src/user_item.dart index 74ccacc2..e537f5d4 100644 --- a/packages/stream_chat_flutter/lib/src/user_item.dart +++ b/packages/stream_chat_flutter/lib/src/user_item.dart @@ -22,14 +22,14 @@ typedef UserItem = StreamUserItem; class StreamUserItem extends StatelessWidget { /// Instantiate a new UserItem const StreamUserItem({ - Key? key, + super.key, required this.user, this.onTap, this.onLongPress, this.onImageTap, this.selected = false, this.showLastOnline = true, - }) : super(key: key); + }); /// Function called when tapping this widget final void Function(User)? onTap; @@ -53,23 +53,11 @@ class StreamUserItem extends StatelessWidget { Widget build(BuildContext context) { final chatThemeData = StreamChatTheme.of(context); return ListTile( - onTap: () { - if (onTap != null) { - onTap!(user); - } - }, - onLongPress: () { - if (onLongPress != null) { - onLongPress!(user); - } - }, + onTap: onTap == null ? null : () => onTap!(user), + onLongPress: onLongPress == null ? null : () => onLongPress!(user), leading: StreamUserAvatar( user: user, - onTap: (user) { - if (onImageTap != null) { - onImageTap!(user); - } - }, + onTap: onImageTap, constraints: const BoxConstraints.tightFor( height: 40, width: 40, diff --git a/packages/stream_chat_flutter/lib/src/user_list_view.dart b/packages/stream_chat_flutter/lib/src/user_list_view.dart index 2b5b868e..55a77322 100644 --- a/packages/stream_chat_flutter/lib/src/user_list_view.dart +++ b/packages/stream_chat_flutter/lib/src/user_list_view.dart @@ -49,8 +49,9 @@ typedef UserItemBuilder = Widget Function(BuildContext, User, bool); @Deprecated("Use 'StreamUserListView' instead") class UserListView extends StatefulWidget { /// Instantiate a new UserListView + @Deprecated("Use 'StreamUserListView' instead") UserListView({ - Key? key, + super.key, this.filter = const Filter.empty(), this.sort, this.presence, @@ -79,8 +80,7 @@ class UserListView extends StatefulWidget { crossAxisCount == 1 || !groupAlphabetically, 'Cannot group alphabetically when crossAxisCount > 1', ), - limit = limit ?? pagination?.limit ?? 30, - super(key: key); + limit = limit ?? pagination?.limit ?? 30; /// The query filters to use. /// You can query on any of the custom fields you've defined on the [Channel]. @@ -315,7 +315,7 @@ class _UserListViewState extends State return item.when( headerItem: (header) { final chatThemeData = StreamChatTheme.of(context); - return Container( + return ColoredBox( key: ValueKey('HEADER-$header'), color: chatThemeData.colorTheme.textHighEmphasis.withOpacity(0.05), child: Padding( @@ -414,7 +414,7 @@ class _UserListViewState extends State initialData: false, builder: (context, snapshot) { if (snapshot.hasError) { - return Container( + return ColoredBox( color: StreamChatTheme.of(context) .colorTheme .accentError diff --git a/packages/stream_chat_flutter/lib/src/user_mention_tile.dart b/packages/stream_chat_flutter/lib/src/user_mention_tile.dart index b944d912..fd62d013 100644 --- a/packages/stream_chat_flutter/lib/src/user_mention_tile.dart +++ b/packages/stream_chat_flutter/lib/src/user_mention_tile.dart @@ -14,12 +14,12 @@ class StreamUserMentionTile extends StatelessWidget { /// Constructor for creating a [StreamUserMentionTile] widget const StreamUserMentionTile( this.user, { - Key? key, + super.key, this.title, this.subtitle, this.leading, this.trailing, - }) : super(key: key); + }); /// User to display in the tile final User user; diff --git a/packages/stream_chat_flutter/lib/src/user_mentions_overlay.dart b/packages/stream_chat_flutter/lib/src/user_mentions_overlay.dart index 59c86791..6a94a476 100644 --- a/packages/stream_chat_flutter/lib/src/user_mentions_overlay.dart +++ b/packages/stream_chat_flutter/lib/src/user_mentions_overlay.dart @@ -22,7 +22,7 @@ typedef UserMentionsOverlay = StreamUserMentionsOverlay; class StreamUserMentionsOverlay extends StatefulWidget { /// Constructor for creating a [StreamUserMentionsOverlay]. StreamUserMentionsOverlay({ - Key? key, + super.key, required this.query, required this.channel, required this.size, @@ -38,8 +38,7 @@ class StreamUserMentionsOverlay extends StatefulWidget { assert( !mentionAllAppUsers || (mentionAllAppUsers && client != null), 'StreamChatClient is required in order to use mentionAllAppUsers', - ), - super(key: key); + ); /// Query for searching users. final String query; @@ -113,7 +112,7 @@ class _StreamUserMentionsOverlayState extends State { if (!snapshot.hasData) return const Offstage(); final users = snapshot.data!; return ListView.builder( - padding: const EdgeInsets.all(0), + padding: EdgeInsets.zero, shrinkWrap: true, itemCount: users.length, itemBuilder: (context, index) { diff --git a/packages/stream_chat_flutter/lib/src/v4/message_input/countdown_button.dart b/packages/stream_chat_flutter/lib/src/v4/message_input/countdown_button.dart index aaf016a3..75416790 100644 --- a/packages/stream_chat_flutter/lib/src/v4/message_input/countdown_button.dart +++ b/packages/stream_chat_flutter/lib/src/v4/message_input/countdown_button.dart @@ -5,9 +5,9 @@ import 'package:stream_chat_flutter/stream_chat_flutter.dart'; class StreamCountdownButton extends StatelessWidget { /// Constructor for creating [StreamCountdownButton]. const StreamCountdownButton({ - Key? key, + super.key, required this.count, - }) : super(key: key); + }); /// Count of time remaining to show to the user. final int count; diff --git a/packages/stream_chat_flutter/lib/src/v4/message_input/simple_safe_area.dart b/packages/stream_chat_flutter/lib/src/v4/message_input/simple_safe_area.dart index 5f3d7391..013cf084 100644 --- a/packages/stream_chat_flutter/lib/src/v4/message_input/simple_safe_area.dart +++ b/packages/stream_chat_flutter/lib/src/v4/message_input/simple_safe_area.dart @@ -4,10 +4,10 @@ import 'package:flutter/material.dart'; class SimpleSafeArea extends StatelessWidget { /// Constructor for [SimpleSafeArea] const SimpleSafeArea({ - Key? key, + super.key, this.enabled = true, required this.child, - }) : super(key: key); + }); /// Wrap [child] with [SafeArea] final bool enabled; diff --git a/packages/stream_chat_flutter/lib/src/v4/message_input/stream_attachment_picker.dart b/packages/stream_chat_flutter/lib/src/v4/message_input/stream_attachment_picker.dart index 98762302..d34ba2f9 100644 --- a/packages/stream_chat_flutter/lib/src/v4/message_input/stream_attachment_picker.dart +++ b/packages/stream_chat_flutter/lib/src/v4/message_input/stream_attachment_picker.dart @@ -25,7 +25,7 @@ class StreamAttachmentPicker extends StatefulWidget { /// Default constructor for [StreamAttachmentPicker] which creates the Stream /// attachment picker widget. const StreamAttachmentPicker({ - Key? key, + super.key, required this.messageInputController, required this.onFilePicked, this.isOpen = false, @@ -40,7 +40,7 @@ class StreamAttachmentPicker extends StatefulWidget { DefaultAttachmentTypes.video, ], this.customAttachmentTypes = const [], - }) : super(key: key); + }); /// True if the picker is open. final bool isOpen; @@ -179,7 +179,7 @@ class _StreamAttachmentPickerState extends State { return AnimatedContainer( duration: - widget.isOpen ? const Duration(milliseconds: 300) : const Duration(), + widget.isOpen ? const Duration(milliseconds: 300) : Duration.zero, curve: Curves.easeOut, height: widget.isOpen ? widget.pickerSize : 0, child: SingleChildScrollView( @@ -245,7 +245,7 @@ class _StreamAttachmentPickerState extends State { if (widget.allowedAttachmentTypes .contains(DefaultAttachmentTypes.video)) IconButton( - padding: const EdgeInsets.all(0), + padding: EdgeInsets.zero, icon: StreamSvgIcon.record( color: _getIconColor(3), ), @@ -424,7 +424,6 @@ class _StreamAttachmentPickerState extends State { class _PickerWidget extends StatefulWidget { const _PickerWidget({ - Key? key, required this.filePickerIndex, required this.containsFile, required this.selectedMedias, @@ -434,7 +433,7 @@ class _PickerWidget extends StatefulWidget { required this.allowedAttachmentTypes, required this.customAttachmentTypes, required this.mediaListViewController, - }) : super(key: key); + }); final int filePickerIndex; final bool containsFile; @@ -506,7 +505,7 @@ class _PickerWidgetState extends State<_PickerWidget> { onTap: () async { PhotoManager.openSetting(); }, - child: Container( + child: ColoredBox( color: widget.streamChatTheme.colorTheme.inputBg, child: Column( mainAxisAlignment: MainAxisAlignment.center, diff --git a/packages/stream_chat_flutter/lib/src/v4/message_input/stream_message_input.dart b/packages/stream_chat_flutter/lib/src/v4/message_input/stream_message_input.dart index 808760c7..ef0ddffb 100644 --- a/packages/stream_chat_flutter/lib/src/v4/message_input/stream_message_input.dart +++ b/packages/stream_chat_flutter/lib/src/v4/message_input/stream_message_input.dart @@ -1,3 +1,5 @@ +// ignore_for_file: deprecated_member_use_from_same_package + import 'dart:async'; import 'dart:math'; @@ -173,7 +175,7 @@ const _kDefaultMaxAttachmentSize = 20971520; // 20MB in Bytes class StreamMessageInput extends StatefulWidget { /// Instantiate a new MessageInput const StreamMessageInput({ - Key? key, + super.key, this.onMessageSent, this.preMessageSending, this.maxHeight = 150, @@ -208,10 +210,11 @@ class StreamMessageInput extends StatefulWidget { this.elevation, this.shadow, this.autoCorrect = true, - this.disableEmojiSuggestionsOverlay = false, + @Deprecated('Please use enableEmojiSuggestionsOverlay') + this.disableEmojiSuggestionsOverlay = false, this.enableEmojiSuggestionsOverlay = true, this.enableMentionsOverlay = true, - }) : super(key: key); + }); /// List of options for showing overlays. final List customOverlays; @@ -744,7 +747,7 @@ class StreamMessageInputState extends State color: _messageInputTheme.expandButtonColor, ), ), - padding: const EdgeInsets.all(0), + padding: EdgeInsets.zero, constraints: const BoxConstraints.tightFor( height: 24, width: 24, @@ -916,7 +919,7 @@ class StreamMessageInputState extends State child: IconButton( icon: StreamSvgIcon.closeSmall(), splashRadius: 24, - padding: const EdgeInsets.all(0), + padding: EdgeInsets.zero, constraints: const BoxConstraints.tightFor( height: 24, width: 24, @@ -1402,9 +1405,9 @@ class StreamMessageInputState extends State ], ); default: - return Container( + return const ColoredBox( color: Colors.black26, - child: const Icon(Icons.insert_drive_file), + child: Icon(Icons.insert_drive_file), ); } } @@ -1419,7 +1422,7 @@ class StreamMessageInputState extends State ? _messageInputTheme.actionButtonColor : _messageInputTheme.actionButtonIdleColor), ), - padding: const EdgeInsets.all(0), + padding: EdgeInsets.zero, constraints: const BoxConstraints.tightFor( height: 24, width: 24, @@ -1448,7 +1451,7 @@ class StreamMessageInputState extends State ? _messageInputTheme.actionButtonColor : _messageInputTheme.actionButtonIdleColor, ), - padding: const EdgeInsets.all(0), + padding: EdgeInsets.zero, constraints: const BoxConstraints.tightFor( height: 24, width: 24, @@ -1809,10 +1812,10 @@ class StreamMessageInputState extends State class OGAttachmentPreview extends StatelessWidget { /// Returns a new instance of [OGAttachmentPreview] const OGAttachmentPreview({ - Key? key, + super.key, required this.attachment, this.onDismissPreviewPressed, - }) : super(key: key); + }); /// The attachment to be rendered. final Attachment attachment; diff --git a/packages/stream_chat_flutter/lib/src/v4/message_input/stream_message_send_button.dart b/packages/stream_chat_flutter/lib/src/v4/message_input/stream_message_send_button.dart index 67a06f67..6aa2650c 100644 --- a/packages/stream_chat_flutter/lib/src/v4/message_input/stream_message_send_button.dart +++ b/packages/stream_chat_flutter/lib/src/v4/message_input/stream_message_send_button.dart @@ -7,7 +7,7 @@ class StreamMessageSendButton extends StatelessWidget { /// [isCommandEnabled], [isEditEnabled], [idleSendButton], [activeSendButton], /// [onSendMessage]. const StreamMessageSendButton({ - Key? key, + super.key, this.timeOut = 0, this.isIdle = true, this.isCommandEnabled = false, @@ -15,7 +15,7 @@ class StreamMessageSendButton extends StatelessWidget { this.idleSendButton, this.activeSendButton, required this.onSendMessage, - }) : super(key: key); + }); /// Time out related to slow mode. final int timeOut; @@ -81,7 +81,7 @@ class StreamMessageSendButton extends StatelessWidget { padding: const EdgeInsets.all(8), child: IconButton( onPressed: onSendMessage, - padding: const EdgeInsets.all(0), + padding: EdgeInsets.zero, splashRadius: 24, constraints: const BoxConstraints.tightFor( height: 24, diff --git a/packages/stream_chat_flutter/lib/src/v4/message_input/stream_message_text_field.dart b/packages/stream_chat_flutter/lib/src/v4/message_input/stream_message_text_field.dart index 0aaccd0a..b9aa5df6 100644 --- a/packages/stream_chat_flutter/lib/src/v4/message_input/stream_message_text_field.dart +++ b/packages/stream_chat_flutter/lib/src/v4/message_input/stream_message_text_field.dart @@ -67,7 +67,7 @@ class StreamMessageTextField extends StatefulWidget { /// * [maxLength], which discusses the precise meaning of "number of /// characters" and how it may differ from the intuitive meaning. const StreamMessageTextField({ - Key? key, + super.key, this.controller, this.focusNode, this.decoration = const InputDecoration(), @@ -176,8 +176,7 @@ class StreamMessageTextField extends StatefulWidget { cut: true, selectAll: true, paste: true, - )), - super(key: key); + )); /// Controls the message being edited. /// diff --git a/packages/stream_chat_flutter/lib/src/v4/scroll_view/channel_scroll_view/stream_channel_grid_tile.dart b/packages/stream_chat_flutter/lib/src/v4/scroll_view/channel_scroll_view/stream_channel_grid_tile.dart index b8e2cf24..dc685d09 100644 --- a/packages/stream_chat_flutter/lib/src/v4/scroll_view/channel_scroll_view/stream_channel_grid_tile.dart +++ b/packages/stream_chat_flutter/lib/src/v4/scroll_view/channel_scroll_view/stream_channel_grid_tile.dart @@ -14,13 +14,13 @@ import 'package:stream_chat_flutter/stream_chat_flutter.dart'; class StreamChannelGridTile extends StatelessWidget { /// Creates a new instance of [StreamChannelGridTile] widget. const StreamChannelGridTile({ - Key? key, + super.key, required this.channel, this.child, this.footer, this.onTap, this.onLongPress, - }) : super(key: key); + }); /// The channel to display. final Channel channel; diff --git a/packages/stream_chat_flutter/lib/src/v4/scroll_view/channel_scroll_view/stream_channel_grid_view.dart b/packages/stream_chat_flutter/lib/src/v4/scroll_view/channel_scroll_view/stream_channel_grid_view.dart index d1969fa4..ab3089d8 100644 --- a/packages/stream_chat_flutter/lib/src/v4/scroll_view/channel_scroll_view/stream_channel_grid_view.dart +++ b/packages/stream_chat_flutter/lib/src/v4/scroll_view/channel_scroll_view/stream_channel_grid_view.dart @@ -44,7 +44,7 @@ typedef StreamChannelGridViewIndexedWidgetBuilder class StreamChannelGridView extends StatelessWidget { /// Creates a new instance of [StreamChannelGridView]. const StreamChannelGridView({ - Key? key, + super.key, required this.controller, this.gridDelegate = defaultChannelGridViewDelegate, this.itemBuilder, @@ -72,7 +72,7 @@ class StreamChannelGridView extends StatelessWidget { this.keyboardDismissBehavior = ScrollViewKeyboardDismissBehavior.manual, this.restorationId, this.clipBehavior = Clip.hardEdge, - }) : super(key: key); + }); /// The [StreamUserListController] used to control the grid of users. final StreamChannelListController controller; diff --git a/packages/stream_chat_flutter/lib/src/v4/scroll_view/channel_scroll_view/stream_channel_list_tile.dart b/packages/stream_chat_flutter/lib/src/v4/scroll_view/channel_scroll_view/stream_channel_list_tile.dart index 8a180fca..129875cf 100644 --- a/packages/stream_chat_flutter/lib/src/v4/scroll_view/channel_scroll_view/stream_channel_list_tile.dart +++ b/packages/stream_chat_flutter/lib/src/v4/scroll_view/channel_scroll_view/stream_channel_list_tile.dart @@ -17,7 +17,7 @@ import 'package:stream_chat_flutter/stream_chat_flutter.dart'; class StreamChannelListTile extends StatelessWidget { /// Creates a new instance of [StreamChannelListTile] widget. StreamChannelListTile({ - Key? key, + super.key, required this.channel, this.leading, this.title, @@ -30,11 +30,10 @@ class StreamChannelListTile extends StatelessWidget { this.contentPadding = const EdgeInsets.symmetric(horizontal: 8), this.unreadIndicatorBuilder, this.sendingIndicatorBuilder, - }) : assert( + }) : assert( channel.state != null, 'Channel ${channel.id} is not initialized', - ), - super(key: key); + ); /// The channel to display. final Channel channel; @@ -228,14 +227,13 @@ class StreamChannelListTile extends StatelessWidget { class ChannelLastMessageDate extends StatelessWidget { /// Creates a new instance of the [ChannelLastMessageDate] widget. ChannelLastMessageDate({ - Key? key, + super.key, required this.channel, this.textStyle, - }) : assert( + }) : assert( channel.state != null, 'Channel ${channel.id} is not initialized', - ), - super(key: key); + ); /// The channel to display the last message date for. final Channel channel; @@ -281,14 +279,13 @@ class ChannelLastMessageDate extends StatelessWidget { class ChannelListTileSubtitle extends StatelessWidget { /// Creates a new instance of [StreamChannelListTileSubtitle] widget. ChannelListTileSubtitle({ - Key? key, + super.key, required this.channel, this.textStyle, - }) : assert( + }) : assert( channel.state != null, 'Channel ${channel.id} is not initialized', - ), - super(key: key); + ); /// The channel to create the subtitle from. final Channel channel; @@ -325,14 +322,13 @@ class ChannelListTileSubtitle extends StatelessWidget { class ChannelLastMessageText extends StatelessWidget { /// Creates a new instance of [ChannelLastMessageText] widget. ChannelLastMessageText({ - Key? key, + super.key, required this.channel, this.textStyle, - }) : assert( + }) : assert( channel.state != null, 'Channel ${channel.id} is not initialized', - ), - super(key: key); + ); /// The channel to display the last message of. final Channel channel; diff --git a/packages/stream_chat_flutter/lib/src/v4/scroll_view/channel_scroll_view/stream_channel_list_view.dart b/packages/stream_chat_flutter/lib/src/v4/scroll_view/channel_scroll_view/stream_channel_list_view.dart index 2a511835..a45ae28b 100644 --- a/packages/stream_chat_flutter/lib/src/v4/scroll_view/channel_scroll_view/stream_channel_list_view.dart +++ b/packages/stream_chat_flutter/lib/src/v4/scroll_view/channel_scroll_view/stream_channel_list_view.dart @@ -52,7 +52,7 @@ typedef StreamChannelListViewIndexedWidgetBuilder class StreamChannelListView extends StatelessWidget { /// Creates a new instance of [StreamChannelListView]. const StreamChannelListView({ - Key? key, + super.key, required this.controller, this.itemBuilder, this.separatorBuilder = defaultChannelListViewSeparatorBuilder, @@ -77,7 +77,7 @@ class StreamChannelListView extends StatelessWidget { this.keyboardDismissBehavior = ScrollViewKeyboardDismissBehavior.manual, this.restorationId, this.clipBehavior = Clip.hardEdge, - }) : super(key: key); + }); /// The [StreamChannelListController] used to control the list of channels. final StreamChannelListController controller; @@ -375,7 +375,7 @@ class StreamChannelListView extends StatelessWidget { /// [StreamChannelListTile] items. class StreamChannelListSeparator extends StatelessWidget { /// Creates a new instance of [StreamChannelListSeparator]. - const StreamChannelListSeparator({Key? key}) : super(key: key); + const StreamChannelListSeparator({super.key}); @override Widget build(BuildContext context) { @@ -392,9 +392,9 @@ class StreamChannelListSeparator extends StatelessWidget { class StreamChannelListErrorWidget extends StatelessWidget { /// Creates a new instance of [StreamChannelListErrorWidget] widget. const StreamChannelListErrorWidget({ - Key? key, + super.key, this.onPressed, - }) : super(key: key); + }); /// The callback to invoke when the user taps on the retry button. final VoidCallback? onPressed; diff --git a/packages/stream_chat_flutter/lib/src/v4/scroll_view/message_search_scroll_view/stream_message_search_grid_view.dart b/packages/stream_chat_flutter/lib/src/v4/scroll_view/message_search_scroll_view/stream_message_search_grid_view.dart index 488148b5..355e3a32 100644 --- a/packages/stream_chat_flutter/lib/src/v4/scroll_view/message_search_scroll_view/stream_message_search_grid_view.dart +++ b/packages/stream_chat_flutter/lib/src/v4/scroll_view/message_search_scroll_view/stream_message_search_grid_view.dart @@ -37,7 +37,7 @@ typedef StreamMessageSearchGridViewIndexedWidgetBuilder class StreamMessageSearchGridView extends StatelessWidget { /// Creates a new instance of [StreamMessageSearchGridView]. const StreamMessageSearchGridView({ - Key? key, + super.key, required this.controller, required this.itemBuilder, this.gridDelegate = defaultMessageSearchGridViewDelegate, @@ -63,7 +63,7 @@ class StreamMessageSearchGridView extends StatelessWidget { this.keyboardDismissBehavior = ScrollViewKeyboardDismissBehavior.manual, this.restorationId, this.clipBehavior = Clip.hardEdge, - }) : super(key: key); + }); /// The [StreamUserListController] used to control the grid of users. final StreamMessageSearchListController controller; diff --git a/packages/stream_chat_flutter/lib/src/v4/scroll_view/message_search_scroll_view/stream_message_search_list_tile.dart b/packages/stream_chat_flutter/lib/src/v4/scroll_view/message_search_scroll_view/stream_message_search_list_tile.dart index c303add0..a380c136 100644 --- a/packages/stream_chat_flutter/lib/src/v4/scroll_view/message_search_scroll_view/stream_message_search_list_tile.dart +++ b/packages/stream_chat_flutter/lib/src/v4/scroll_view/message_search_scroll_view/stream_message_search_list_tile.dart @@ -15,7 +15,7 @@ import 'package:stream_chat_flutter/stream_chat_flutter.dart'; class StreamMessageSearchListTile extends StatelessWidget { /// Creates a new instance of [StreamMessageSearchListTile]. const StreamMessageSearchListTile({ - Key? key, + super.key, required this.messageResponse, this.leading, this.title, @@ -26,7 +26,7 @@ class StreamMessageSearchListTile extends StatelessWidget { this.tileColor, this.visualDensity = VisualDensity.compact, this.contentPadding = const EdgeInsets.symmetric(horizontal: 8), - }) : super(key: key); + }); /// The message response to display. final GetMessageResponse messageResponse; @@ -161,10 +161,10 @@ class StreamMessageSearchListTile extends StatelessWidget { class MessageSearchListTileTitle extends StatelessWidget { /// Creates a new [MessageSearchListTileTitle] instance. const MessageSearchListTileTitle({ - Key? key, + super.key, required this.messageResponse, this.textStyle, - }) : super(key: key); + }); /// The message response for the tile. final GetMessageResponse messageResponse; @@ -207,10 +207,10 @@ class MessageSearchListTileTitle extends StatelessWidget { class MessageSearchTileMessageDate extends StatelessWidget { /// Creates a new instance of [MessageSearchTileMessageDate]. const MessageSearchTileMessageDate({ - Key? key, + super.key, required this.message, this.textStyle, - }) : super(key: key); + }); /// The searched message response. final Message message; diff --git a/packages/stream_chat_flutter/lib/src/v4/scroll_view/message_search_scroll_view/stream_message_search_list_view.dart b/packages/stream_chat_flutter/lib/src/v4/scroll_view/message_search_scroll_view/stream_message_search_list_view.dart index 9c3f165d..b1a184ca 100644 --- a/packages/stream_chat_flutter/lib/src/v4/scroll_view/message_search_scroll_view/stream_message_search_list_view.dart +++ b/packages/stream_chat_flutter/lib/src/v4/scroll_view/message_search_scroll_view/stream_message_search_list_view.dart @@ -49,7 +49,7 @@ typedef StreamMessageSearchListViewIndexedWidgetBuilder class StreamMessageSearchListView extends StatelessWidget { /// Creates a new instance of [StreamMessageSearchListView]. const StreamMessageSearchListView({ - Key? key, + super.key, required this.controller, this.itemBuilder, this.separatorBuilder = defaultMessageSearchListViewSeparatorBuilder, @@ -74,7 +74,7 @@ class StreamMessageSearchListView extends StatelessWidget { this.keyboardDismissBehavior = ScrollViewKeyboardDismissBehavior.manual, this.restorationId, this.clipBehavior = Clip.hardEdge, - }) : super(key: key); + }); /// The [StreamUserListController] used to control the list of /// searched messages. @@ -373,7 +373,7 @@ class StreamMessageSearchListView extends StatelessWidget { /// [StreamMessageSearchListTile] items. class StreamMessageSearchListSeparator extends StatelessWidget { /// Creates a new instance of [StreamMessageSearchListSeparator]. - const StreamMessageSearchListSeparator({Key? key}) : super(key: key); + const StreamMessageSearchListSeparator({super.key}); @override Widget build(BuildContext context) { diff --git a/packages/stream_chat_flutter/lib/src/v4/scroll_view/stream_scroll_view_empty_widget.dart b/packages/stream_chat_flutter/lib/src/v4/scroll_view/stream_scroll_view_empty_widget.dart index 531eac79..f931dbbb 100644 --- a/packages/stream_chat_flutter/lib/src/v4/scroll_view/stream_scroll_view_empty_widget.dart +++ b/packages/stream_chat_flutter/lib/src/v4/scroll_view/stream_scroll_view_empty_widget.dart @@ -6,14 +6,14 @@ import 'package:stream_chat_flutter/src/stream_chat_theme.dart'; class StreamScrollViewEmptyWidget extends StatelessWidget { /// Creates a new instance of the [StreamScrollViewEmptyWidget]. const StreamScrollViewEmptyWidget({ - Key? key, + super.key, required this.emptyIcon, required this.emptyTitle, this.emptyTitleStyle, this.mainAxisSize = MainAxisSize.max, this.mainAxisAlignment = MainAxisAlignment.center, this.crossAxisAlignment = CrossAxisAlignment.center, - }) : super(key: key); + }); /// The title of the empty view. final Widget emptyTitle; diff --git a/packages/stream_chat_flutter/lib/src/v4/scroll_view/stream_scroll_view_error_widget.dart b/packages/stream_chat_flutter/lib/src/v4/scroll_view/stream_scroll_view_error_widget.dart index 9d6af29c..bb14d8dd 100644 --- a/packages/stream_chat_flutter/lib/src/v4/scroll_view/stream_scroll_view_error_widget.dart +++ b/packages/stream_chat_flutter/lib/src/v4/scroll_view/stream_scroll_view_error_widget.dart @@ -7,7 +7,7 @@ import 'package:stream_chat_flutter/src/stream_chat_theme.dart'; class StreamScrollViewErrorWidget extends StatelessWidget { /// Creates a new instance of the [StreamScrollViewErrorWidget]. const StreamScrollViewErrorWidget({ - Key? key, + super.key, this.errorTitle, this.errorTitleStyle, this.errorIcon, @@ -17,7 +17,7 @@ class StreamScrollViewErrorWidget extends StatelessWidget { this.mainAxisSize = MainAxisSize.max, this.mainAxisAlignment = MainAxisAlignment.center, this.crossAxisAlignment = CrossAxisAlignment.center, - }) : super(key: key); + }); /// The title of the error. final Widget? errorTitle; diff --git a/packages/stream_chat_flutter/lib/src/v4/scroll_view/stream_scroll_view_load_more_error.dart b/packages/stream_chat_flutter/lib/src/v4/scroll_view/stream_scroll_view_load_more_error.dart index 03575b1f..feec6f4e 100644 --- a/packages/stream_chat_flutter/lib/src/v4/scroll_view/stream_scroll_view_load_more_error.dart +++ b/packages/stream_chat_flutter/lib/src/v4/scroll_view/stream_scroll_view_load_more_error.dart @@ -7,7 +7,7 @@ import 'package:stream_chat_flutter/src/stream_svg_icon.dart'; class StreamScrollViewLoadMoreError extends StatelessWidget { /// Creates a new instance of [StreamScrollViewLoadMoreError.list]. const StreamScrollViewLoadMoreError.list({ - Key? key, + super.key, this.error, this.errorStyle, this.errorIcon, @@ -17,12 +17,11 @@ class StreamScrollViewLoadMoreError extends StatelessWidget { this.mainAxisSize = MainAxisSize.max, this.mainAxisAlignment = MainAxisAlignment.spaceBetween, this.crossAxisAlignment = CrossAxisAlignment.center, - }) : _isList = true, - super(key: key); + }) : _isList = true; /// Creates a new instance of [StreamScrollViewLoadMoreError.grid]. const StreamScrollViewLoadMoreError.grid({ - Key? key, + super.key, this.error, this.errorStyle, this.errorIcon, @@ -32,8 +31,7 @@ class StreamScrollViewLoadMoreError extends StatelessWidget { this.mainAxisSize = MainAxisSize.max, this.mainAxisAlignment = MainAxisAlignment.spaceEvenly, this.crossAxisAlignment = CrossAxisAlignment.center, - }) : _isList = false, - super(key: key); + }) : _isList = false; /// The error message to display. final Widget? error; @@ -86,7 +84,7 @@ class StreamScrollViewLoadMoreError extends StatelessWidget { return InkWell( onTap: onTap, - child: Container( + child: ColoredBox( color: backgroundColor, child: Padding( padding: padding, diff --git a/packages/stream_chat_flutter/lib/src/v4/scroll_view/stream_scroll_view_load_more_indicator.dart b/packages/stream_chat_flutter/lib/src/v4/scroll_view/stream_scroll_view_load_more_indicator.dart index 93bf8d06..72585225 100644 --- a/packages/stream_chat_flutter/lib/src/v4/scroll_view/stream_scroll_view_load_more_indicator.dart +++ b/packages/stream_chat_flutter/lib/src/v4/scroll_view/stream_scroll_view_load_more_indicator.dart @@ -5,10 +5,10 @@ import 'package:flutter/material.dart'; class StreamScrollViewLoadMoreIndicator extends StatelessWidget { /// Creates a new instance of [StreamScrollViewLoadMoreIndicator]. const StreamScrollViewLoadMoreIndicator({ - Key? key, + super.key, this.height = 16, this.width = 16, - }) : super(key: key); + }); /// The height of the indicator. final double height; diff --git a/packages/stream_chat_flutter/lib/src/v4/scroll_view/stream_scroll_view_loading_widget.dart b/packages/stream_chat_flutter/lib/src/v4/scroll_view/stream_scroll_view_loading_widget.dart index ae47b152..958eb80d 100644 --- a/packages/stream_chat_flutter/lib/src/v4/scroll_view/stream_scroll_view_loading_widget.dart +++ b/packages/stream_chat_flutter/lib/src/v4/scroll_view/stream_scroll_view_loading_widget.dart @@ -4,10 +4,10 @@ import 'package:flutter/material.dart'; class StreamScrollViewLoadingWidget extends StatelessWidget { /// Creates a new instance of [StreamScrollViewLoadingWidget]. const StreamScrollViewLoadingWidget({ - Key? key, + super.key, this.height = 42, this.width = 42, - }) : super(key: key); + }); /// The height of the indicator. final double height; diff --git a/packages/stream_chat_flutter/lib/src/v4/scroll_view/user_scroll_view/stream_user_grid_tile.dart b/packages/stream_chat_flutter/lib/src/v4/scroll_view/user_scroll_view/stream_user_grid_tile.dart index 6d904086..4d512f05 100644 --- a/packages/stream_chat_flutter/lib/src/v4/scroll_view/user_scroll_view/stream_user_grid_tile.dart +++ b/packages/stream_chat_flutter/lib/src/v4/scroll_view/user_scroll_view/stream_user_grid_tile.dart @@ -13,13 +13,13 @@ import 'package:stream_chat_flutter/stream_chat_flutter.dart'; class StreamUserGridTile extends StatelessWidget { /// Creates a new instance of [StreamUserGridTile] widget. const StreamUserGridTile({ - Key? key, + super.key, required this.user, this.child, this.footer, this.onTap, this.onLongPress, - }) : super(key: key); + }); /// The user to display. final User user; diff --git a/packages/stream_chat_flutter/lib/src/v4/scroll_view/user_scroll_view/stream_user_grid_view.dart b/packages/stream_chat_flutter/lib/src/v4/scroll_view/user_scroll_view/stream_user_grid_view.dart index 08cc4a50..13a12100 100644 --- a/packages/stream_chat_flutter/lib/src/v4/scroll_view/user_scroll_view/stream_user_grid_view.dart +++ b/packages/stream_chat_flutter/lib/src/v4/scroll_view/user_scroll_view/stream_user_grid_view.dart @@ -39,7 +39,7 @@ typedef StreamUserGridViewIndexedWidgetBuilder class StreamUserGridView extends StatelessWidget { /// Creates a new instance of [StreamUserGridView]. const StreamUserGridView({ - Key? key, + super.key, required this.controller, this.gridDelegate = defaultUserGridViewDelegate, this.itemBuilder, @@ -67,7 +67,7 @@ class StreamUserGridView extends StatelessWidget { this.keyboardDismissBehavior = ScrollViewKeyboardDismissBehavior.manual, this.restorationId, this.clipBehavior = Clip.hardEdge, - }) : super(key: key); + }); /// The [StreamUserListController] used to control the grid of users. final StreamUserListController controller; diff --git a/packages/stream_chat_flutter/lib/src/v4/scroll_view/user_scroll_view/stream_user_list_tile.dart b/packages/stream_chat_flutter/lib/src/v4/scroll_view/user_scroll_view/stream_user_list_tile.dart index c88862fa..00471855 100644 --- a/packages/stream_chat_flutter/lib/src/v4/scroll_view/user_scroll_view/stream_user_list_tile.dart +++ b/packages/stream_chat_flutter/lib/src/v4/scroll_view/user_scroll_view/stream_user_list_tile.dart @@ -19,7 +19,7 @@ import 'package:stream_chat_flutter_core/stream_chat_flutter_core.dart' class StreamUserListTile extends StatelessWidget { /// Creates a new instance of [StreamUserListTile]. const StreamUserListTile({ - Key? key, + super.key, required this.user, this.leading, this.title, @@ -31,7 +31,7 @@ class StreamUserListTile extends StatelessWidget { this.tileColor, this.visualDensity = VisualDensity.compact, this.contentPadding = const EdgeInsets.symmetric(horizontal: 8), - }) : super(key: key); + }); /// The user to display. final User user; @@ -171,9 +171,9 @@ class StreamUserListTile extends StatelessWidget { class UserLastActive extends StatelessWidget { /// Creates a new instance of the [UserLastActive] widget. const UserLastActive({ - Key? key, + super.key, required this.user, - }) : super(key: key); + }); /// The user whose last active time is displayed. final User user; diff --git a/packages/stream_chat_flutter/lib/src/v4/scroll_view/user_scroll_view/stream_user_list_view.dart b/packages/stream_chat_flutter/lib/src/v4/scroll_view/user_scroll_view/stream_user_list_view.dart index d87f8ab9..f54ce795 100644 --- a/packages/stream_chat_flutter/lib/src/v4/scroll_view/user_scroll_view/stream_user_list_view.dart +++ b/packages/stream_chat_flutter/lib/src/v4/scroll_view/user_scroll_view/stream_user_list_view.dart @@ -48,7 +48,7 @@ typedef StreamUserListViewIndexedWidgetBuilder class StreamUserListView extends StatelessWidget { /// Creates a new instance of [StreamUserListView]. const StreamUserListView({ - Key? key, + super.key, required this.controller, this.itemBuilder, this.separatorBuilder = defaultUserListViewSeparatorBuilder, @@ -73,7 +73,7 @@ class StreamUserListView extends StatelessWidget { this.keyboardDismissBehavior = ScrollViewKeyboardDismissBehavior.manual, this.restorationId, this.clipBehavior = Clip.hardEdge, - }) : super(key: key); + }); /// The [StreamUserListController] used to control the list of users. final StreamUserListController controller; @@ -368,7 +368,7 @@ class StreamUserListView extends StatelessWidget { /// [StreamUserListTile] items. class StreamUserListSeparator extends StatelessWidget { /// Creates a new instance of [StreamUserListSeparator]. - const StreamUserListSeparator({Key? key}) : super(key: key); + const StreamUserListSeparator({super.key}); @override Widget build(BuildContext context) { diff --git a/packages/stream_chat_flutter/lib/src/v4/stream_channel_avatar.dart b/packages/stream_chat_flutter/lib/src/v4/stream_channel_avatar.dart index 448e39d8..452e19a3 100644 --- a/packages/stream_chat_flutter/lib/src/v4/stream_channel_avatar.dart +++ b/packages/stream_chat_flutter/lib/src/v4/stream_channel_avatar.dart @@ -47,7 +47,7 @@ import 'package:stream_chat_flutter/stream_chat_flutter.dart'; class StreamChannelAvatar extends StatelessWidget { /// Instantiate a new ChannelImage StreamChannelAvatar({ - Key? key, + super.key, required this.channel, this.constraints, this.onTap, @@ -55,11 +55,10 @@ class StreamChannelAvatar extends StatelessWidget { this.selected = false, this.selectionColor, this.selectionThickness = 4, - }) : assert( + }) : assert( channel.state != null, 'Channel ${channel.id} is not initialized', - ), - super(key: key); + ); /// [BorderRadius] to display the widget final BorderRadius? borderRadius; diff --git a/packages/stream_chat_flutter/lib/src/v4/stream_channel_info_bottom_sheet.dart b/packages/stream_chat_flutter/lib/src/v4/stream_channel_info_bottom_sheet.dart index 19c2349b..6827c431 100644 --- a/packages/stream_chat_flutter/lib/src/v4/stream_channel_info_bottom_sheet.dart +++ b/packages/stream_chat_flutter/lib/src/v4/stream_channel_info_bottom_sheet.dart @@ -13,18 +13,17 @@ import 'package:stream_chat_flutter_core/stream_chat_flutter_core.dart'; class StreamChannelInfoBottomSheet extends StatelessWidget { /// Creates a new instance [StreamChannelInfoBottomSheet] widget. StreamChannelInfoBottomSheet({ - Key? key, + super.key, required this.channel, this.onMemberTap, this.onViewInfoTap, this.onLeaveChannelTap, this.onDeleteConversationTap, this.onCancelTap, - }) : assert( + }) : assert( channel.state != null, 'Channel ${channel.id} is not initialized', - ), - super(key: key); + ); /// The [Channel] to show information about. final Channel channel; diff --git a/packages/stream_chat_flutter/lib/src/v4/stream_channel_name.dart b/packages/stream_chat_flutter/lib/src/v4/stream_channel_name.dart index c6070e0f..b7536df3 100644 --- a/packages/stream_chat_flutter/lib/src/v4/stream_channel_name.dart +++ b/packages/stream_chat_flutter/lib/src/v4/stream_channel_name.dart @@ -10,15 +10,14 @@ import 'package:stream_chat_flutter_core/stream_chat_flutter_core.dart'; class StreamChannelName extends StatelessWidget { /// Instantiate a new ChannelName StreamChannelName({ - Key? key, + super.key, required this.channel, this.textStyle, this.textOverflow = TextOverflow.ellipsis, - }) : assert( + }) : assert( channel.state != null, 'Channel ${channel.id} is not initialized', - ), - super(key: key); + ); /// The [Channel] to show the name for. final Channel channel; diff --git a/packages/stream_chat_flutter/lib/src/v4/stream_message_preview_text.dart b/packages/stream_chat_flutter/lib/src/v4/stream_message_preview_text.dart index 53d260a2..4e036c5c 100644 --- a/packages/stream_chat_flutter/lib/src/v4/stream_message_preview_text.dart +++ b/packages/stream_chat_flutter/lib/src/v4/stream_message_preview_text.dart @@ -6,11 +6,11 @@ import 'package:stream_chat_flutter/stream_chat_flutter.dart'; class StreamMessagePreviewText extends StatelessWidget { /// Creates a new instance of [StreamMessagePreviewText]. const StreamMessagePreviewText({ - Key? key, + super.key, required this.message, this.language, this.textStyle, - }) : super(key: key); + }); /// The message to display. final Message message; diff --git a/packages/stream_chat_flutter/lib/src/video_thumbnail_image.dart b/packages/stream_chat_flutter/lib/src/video_thumbnail_image.dart index 4d253da0..9f778278 100644 --- a/packages/stream_chat_flutter/lib/src/video_thumbnail_image.dart +++ b/packages/stream_chat_flutter/lib/src/video_thumbnail_image.dart @@ -16,7 +16,7 @@ typedef VideoThumbnailImage = StreamVideoThumbnailImage; class StreamVideoThumbnailImage extends StatefulWidget { /// Constructor for creating [StreamVideoThumbnailImage] const StreamVideoThumbnailImage({ - Key? key, + super.key, required this.video, this.width, this.height, @@ -24,7 +24,7 @@ class StreamVideoThumbnailImage extends StatefulWidget { this.format = ImageFormat.PNG, this.errorBuilder, this.placeholderBuilder, - }) : super(key: key); + }); /// Video path final String video; diff --git a/packages/stream_chat_flutter/lib/src/visible_footnote.dart b/packages/stream_chat_flutter/lib/src/visible_footnote.dart index 1456de3a..80fac2e0 100644 --- a/packages/stream_chat_flutter/lib/src/visible_footnote.dart +++ b/packages/stream_chat_flutter/lib/src/visible_footnote.dart @@ -11,7 +11,7 @@ typedef VisibleFootnote = StreamVisibleFootnote; /// {@endtemplate} class StreamVisibleFootnote extends StatelessWidget { /// Constructor for creating a [StreamVisibleFootnote] - const StreamVisibleFootnote({Key? key}) : super(key: key); + const StreamVisibleFootnote({super.key}); @override Widget build(BuildContext context) { diff --git a/packages/stream_chat_flutter/pubspec.yaml b/packages/stream_chat_flutter/pubspec.yaml index 7df5cc83..573d08df 100644 --- a/packages/stream_chat_flutter/pubspec.yaml +++ b/packages/stream_chat_flutter/pubspec.yaml @@ -1,12 +1,12 @@ 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: 4.1.0 +version: 4.2.0 repository: https://github.com/GetStream/stream-chat-flutter issue_tracker: https://github.com/GetStream/stream-chat-flutter/issues environment: - sdk: '>=2.14.0 <3.0.0' + sdk: '>=2.17.0 <3.0.0' flutter: ">=1.17.0" dependencies: @@ -36,7 +36,7 @@ dependencies: rxdart: ^0.27.0 share_plus: ^4.0.1 shimmer: ^2.0.0 - stream_chat_flutter_core: ^4.1.0 + stream_chat_flutter_core: ^4.2.0 substring_highlight: ^1.0.26 url_launcher: ^6.1.0 video_player: ^2.1.0 diff --git a/packages/stream_chat_flutter/test/flutter_test_config.dart b/packages/stream_chat_flutter/test/flutter_test_config.dart index bfda23d0..07b2da98 100644 --- a/packages/stream_chat_flutter/test/flutter_test_config.dart +++ b/packages/stream_chat_flutter/test/flutter_test_config.dart @@ -13,7 +13,7 @@ Future testExecutable(FutureOr Function() testMain) async { } class CustomGoldenFileComparator extends LocalFileComparator { - CustomGoldenFileComparator(Uri testFile) : super(testFile); + CustomGoldenFileComparator(super.testFile); @override Future compare(Uint8List imageBytes, Uri golden) async { @@ -28,8 +28,4 @@ class CustomGoldenFileComparator extends LocalFileComparator { } return true; } - - @override - Future update(Uri golden, Uint8List imageBytes) => - super.update(golden, imageBytes); } diff --git a/packages/stream_chat_flutter/test/scrollable_positioned_list/scrollable_positioned_list_test.dart b/packages/stream_chat_flutter/test/scrollable_positioned_list/scrollable_positioned_list_test.dart index 79845215..ef715743 100644 --- a/packages/stream_chat_flutter/test/scrollable_positioned_list/scrollable_positioned_list_test.dart +++ b/packages/stream_chat_flutter/test/scrollable_positioned_list/scrollable_positioned_list_test.dart @@ -933,6 +933,11 @@ void main() { await tester.pumpAndSettle(); }); + final fadeTransitionFinder = find.descendant( + of: find.byType(ScrollablePositionedList), + matching: find.byType(FadeTransition), + ); + testWidgets('Scroll to 0 stop before half way', (WidgetTester tester) async { final itemScrollController = ItemScrollController(); await setUpWidgetTest(tester, itemScrollController: itemScrollController); @@ -951,7 +956,7 @@ void main() { await tester.pump(); expect(tester.getTopLeft(find.text('Item 91')).dy, 0); - expect(find.byType(FadeTransition), findsNWidgets(2)); + expect(fadeTransitionFinder, findsNWidgets(1)); await tester.pumpAndSettle(); }); @@ -976,7 +981,7 @@ void main() { expect(tester.getBottomLeft(find.text('Item 100')).dy, closeTo(screenHeight, tolerance)); expect(find.text('Item 9', skipOffstage: false), findsNothing); - expect(find.byType(FadeTransition), findsNWidgets(2)); + expect(fadeTransitionFinder, findsNWidgets(1)); await tester.pumpAndSettle(); }); @@ -999,11 +1004,7 @@ void main() { await tester.pump(); expect(tester.getTopLeft(find.text('Item 9')).dy, closeTo(0, tolerance)); - final fadeTransition = tester.widget(find - .descendant( - of: find.byType(ScrollablePositionedList), - matching: find.byType(FadeTransition)) - .last); + final fadeTransition = tester.widget(fadeTransitionFinder); expect(fadeTransition.opacity.value, 1.0); await tester.pumpAndSettle(); @@ -1021,13 +1022,14 @@ void main() { itemScrollController.scrollTo(index: 0, duration: scrollDuration)); await tester.pump(); await tester.pump(); - await tester.pump(scrollDuration ~/ 2); + await tester.pump(scrollDuration ~/ 2 + scrollDuration ~/ 20); await tester.tap(find.byType(ScrollablePositionedList)); await tester.pump(); - expect(tester.getTopLeft(find.text('Item 90')).dy, 0); - expect(find.byType(FadeTransition), findsNWidgets(2)); + expect(tester.getTopLeft(find.text('Item 9')).dy, closeTo(0, tolerance)); + final fadeTransition = tester.widget(fadeTransitionFinder); + expect(fadeTransition.opacity.value, 1.0); await tester.pumpAndSettle(); }); @@ -1317,7 +1319,7 @@ void main() { await setUpWidgetTest(tester, itemPositionsListener: itemPositionsListener); final root = WidgetsBinding - .instance!.pipelineOwner.semanticsOwner!.rootSemanticsNode!; + .instance.pipelineOwner.semanticsOwner!.rootSemanticsNode!; final semanticNodes = [root]; diff --git a/packages/stream_chat_flutter/test/src/attachment_actions_modal_test.dart b/packages/stream_chat_flutter/test/src/attachment_actions_modal_test.dart index d59b8002..244eace5 100644 --- a/packages/stream_chat_flutter/test/src/attachment_actions_modal_test.dart +++ b/packages/stream_chat_flutter/test/src/attachment_actions_modal_test.dart @@ -75,7 +75,7 @@ void main() { ); testWidgets( - 'it should hide delete if it\'s not my message', + "it should hide delete if it's not my message", (WidgetTester tester) async { final client = MockClient(); final clientState = MockClientState(); @@ -364,7 +364,7 @@ void main() { testWidgets( // ignore: lines_longer_than_80_chars - 'tapping on delete in chat should remove the message if that\'s the only attachment and there is no text', + "tapping on delete in chat should remove the message if that's the only attachment and there is no text", (WidgetTester tester) async { final client = MockClient(); final clientState = MockClientState(); diff --git a/packages/stream_chat_flutter/test/src/gradient_avatar_test.dart b/packages/stream_chat_flutter/test/src/gradient_avatar_test.dart index 073adc55..a4388a2e 100644 --- a/packages/stream_chat_flutter/test/src/gradient_avatar_test.dart +++ b/packages/stream_chat_flutter/test/src/gradient_avatar_test.dart @@ -92,7 +92,7 @@ void main() { width: 100, height: 100, child: StreamGradientAvatar( - name: 'd123@/d de:\$as', + name: r'd123@/d de:$as', userId: 'demo123', ), ), @@ -116,7 +116,7 @@ void main() { width: 100, height: 100, child: StreamGradientAvatar( - name: '123@/d \$as', userId: 'demo123'), + name: r'123@/d $as', userId: 'demo123'), ), ), ), diff --git a/packages/stream_chat_flutter/test/src/message_list_view_test.dart b/packages/stream_chat_flutter/test/src/message_list_view_test.dart index 08e23820..240dda84 100644 --- a/packages/stream_chat_flutter/test/src/message_list_view_test.dart +++ b/packages/stream_chat_flutter/test/src/message_list_view_test.dart @@ -114,9 +114,9 @@ void main() { }); bool findBackground(Widget widget) => - widget is Container && + widget is DecoratedBox && widget.decoration is BoxDecoration && - (widget.decoration! as BoxDecoration).image != null; + (widget.decoration as BoxDecoration).image != null; expect(find.byType(StreamMessageListView), findsOneWidget); expect(find.byKey(nonEmptyWidgetKey), findsOneWidget); diff --git a/packages/stream_chat_flutter/test/src/reaction_bubble_test.dart b/packages/stream_chat_flutter/test/src/reaction_bubble_test.dart index 50719b17..e5234a6d 100644 --- a/packages/stream_chat_flutter/test/src/reaction_bubble_test.dart +++ b/packages/stream_chat_flutter/test/src/reaction_bubble_test.dart @@ -60,7 +60,7 @@ void main() { client: client, streamChatThemeData: StreamChatThemeData.fromTheme(themeData), connectivityStream: Stream.value(ConnectivityResult.mobile), - child: Container( + child: ColoredBox( color: Colors.black, child: StreamReactionBubble( reactions: [ @@ -97,7 +97,7 @@ void main() { client: client, streamChatThemeData: StreamChatThemeData.fromTheme(themeData), connectivityStream: Stream.value(ConnectivityResult.mobile), - child: Container( + child: ColoredBox( color: Colors.black, child: StreamReactionBubble( reactions: [ @@ -142,7 +142,7 @@ void main() { client: client, streamChatThemeData: StreamChatThemeData.fromTheme(themeData), connectivityStream: Stream.value(ConnectivityResult.mobile), - child: Container( + child: ColoredBox( color: Colors.black, child: StreamReactionBubble( reactions: [ diff --git a/packages/stream_chat_flutter/test/src/simple_frame.dart b/packages/stream_chat_flutter/test/src/simple_frame.dart index 0633a3b8..aad15b63 100644 --- a/packages/stream_chat_flutter/test/src/simple_frame.dart +++ b/packages/stream_chat_flutter/test/src/simple_frame.dart @@ -1,7 +1,7 @@ import 'package:flutter/material.dart'; class SimpleFrame extends StatelessWidget { - const SimpleFrame({Key? key, required this.child}) : super(key: key); + const SimpleFrame({super.key, required this.child}); final Widget child; diff --git a/packages/stream_chat_flutter/test/utils/golden.dart b/packages/stream_chat_flutter/test/utils/golden.dart index 574306ef..436f10f2 100644 --- a/packages/stream_chat_flutter/test/utils/golden.dart +++ b/packages/stream_chat_flutter/test/utils/golden.dart @@ -38,7 +38,7 @@ This method level parameter will be removed in an upcoming release. This can be } class CustomGoldenFileComparator extends LocalFileComparator { - CustomGoldenFileComparator(Uri testFile) : super(testFile); + CustomGoldenFileComparator(super.testFile); @override Future compare(Uint8List imageBytes, Uri golden) async { diff --git a/packages/stream_chat_flutter_core/CHANGELOG.md b/packages/stream_chat_flutter_core/CHANGELOG.md index 7eb8845a..34a92400 100644 --- a/packages/stream_chat_flutter_core/CHANGELOG.md +++ b/packages/stream_chat_flutter_core/CHANGELOG.md @@ -1,3 +1,12 @@ +## 4.2.0 + +- Updated `stream_chat` dependency to [`4.2.0`](https://pub.dev/packages/stream_chat/changelog). + +🔄 Changed + +- Deprecated `before` and `after` parameters in `StreamChannel.queryAroundMessage`. Use `limit` instead. +- Deprecated `before` and `after` parameters in `StreamChannel.loadChannelAtMessage`. Use `limit` instead. + ## 4.1.0 - Updated `stream_chat` dependency to [`4.1.0`](https://pub.dev/packages/stream_chat/changelog). diff --git a/packages/stream_chat_flutter_core/example/pubspec.yaml b/packages/stream_chat_flutter_core/example/pubspec.yaml index 4b0e27fb..562d0761 100644 --- a/packages/stream_chat_flutter_core/example/pubspec.yaml +++ b/packages/stream_chat_flutter_core/example/pubspec.yaml @@ -18,7 +18,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev version: 1.0.0+1 environment: - sdk: '>=2.12.0 <3.0.0' + sdk: '>=2.17.0 <3.0.0' dependencies: # The following adds the Cupertino Icons font to your application. diff --git a/packages/stream_chat_flutter_core/lib/src/better_stream_builder.dart b/packages/stream_chat_flutter_core/lib/src/better_stream_builder.dart index 2a2a5ab7..6305224b 100644 --- a/packages/stream_chat_flutter_core/lib/src/better_stream_builder.dart +++ b/packages/stream_chat_flutter_core/lib/src/better_stream_builder.dart @@ -15,8 +15,8 @@ class BetterStreamBuilder extends StatefulWidget { this.noDataBuilder, this.errorBuilder, this.comparator, - Key? key, - }) : super(key: key); + super.key, + }); /// The stream to listen to final Stream? stream; 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 51be28e7..556b44cc 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 @@ -64,7 +64,7 @@ More details here https://getstream.io/chat/docs/sdk/flutter/stream_chat_flutter class ChannelListCore extends StatefulWidget { /// Instantiate a new ChannelListView const ChannelListCore({ - Key? key, + super.key, required this.errorBuilder, required this.emptyBuilder, required this.loadingBuilder, @@ -78,7 +78,7 @@ class ChannelListCore extends StatefulWidget { this.sort, this.channelListController, this.limit = 25, - }) : super(key: key); + }); /// A [ChannelListController] allows reloading and pagination. /// Use [ChannelListController.loadData] and 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 2f8838b5..df791d52 100644 --- a/packages/stream_chat_flutter_core/lib/src/channels_bloc.dart +++ b/packages/stream_chat_flutter_core/lib/src/channels_bloc.dart @@ -23,12 +23,12 @@ class ChannelsBloc extends StatefulWidget { /// Creates a new [ChannelsBloc]. The parameter [child] must be supplied and /// not null. const ChannelsBloc({ - Key? key, + super.key, required this.child, this.lockChannelsOrder = false, this.channelsComparator, this.shouldAddChannel, - }) : super(key: key); + }); /// The widget child final Widget child; diff --git a/packages/stream_chat_flutter_core/lib/src/lazy_load_scroll_view.dart b/packages/stream_chat_flutter_core/lib/src/lazy_load_scroll_view.dart index fb503bcd..e086ab55 100644 --- a/packages/stream_chat_flutter_core/lib/src/lazy_load_scroll_view.dart +++ b/packages/stream_chat_flutter_core/lib/src/lazy_load_scroll_view.dart @@ -9,7 +9,7 @@ class LazyLoadScrollView extends StatefulWidget { /// Creates a new instance of [LazyLoadScrollView]. The parameter [child] /// must be supplied and not null. const LazyLoadScrollView({ - Key? key, + super.key, required this.child, this.onStartOfPage, this.onEndOfPage, @@ -17,7 +17,7 @@ class LazyLoadScrollView extends StatefulWidget { this.onPageScrollEnd, this.onInBetweenOfPage, this.scrollOffset = 100, - }) : super(key: key); + }); /// The [Widget] that this widget watches for changes on final Widget child; diff --git a/packages/stream_chat_flutter_core/lib/src/message_list_core.dart b/packages/stream_chat_flutter_core/lib/src/message_list_core.dart index a28d6d73..042c2eca 100644 --- a/packages/stream_chat_flutter_core/lib/src/message_list_core.dart +++ b/packages/stream_chat_flutter_core/lib/src/message_list_core.dart @@ -70,7 +70,7 @@ bool Function(Message) defaultMessageFilter(String currentUserId) => class MessageListCore extends StatefulWidget { /// Instantiate a new [MessageListView]. const MessageListCore({ - Key? key, + super.key, required this.loadingBuilder, required this.emptyBuilder, required this.messageListBuilder, @@ -79,7 +79,7 @@ class MessageListCore extends StatefulWidget { this.messageListController, this.messageFilter, this.paginationLimit = 20, - }) : super(key: key); + }); /// A [MessageListController] allows pagination. /// Use [ChannelListController.paginateData] pagination. 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 0c302c72..0ba47fd2 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 @@ -17,9 +17,9 @@ import 'package:stream_chat_flutter_core/src/stream_controller_extension.dart'; class MessageSearchBloc extends StatefulWidget { /// Instantiate a new MessageSearchBloc const MessageSearchBloc({ - Key? key, + super.key, required this.child, - }) : super(key: key); + }); /// The widget child final Widget child; diff --git a/packages/stream_chat_flutter_core/lib/src/message_search_list_core.dart b/packages/stream_chat_flutter_core/lib/src/message_search_list_core.dart index e86d020b..f528a4da 100644 --- a/packages/stream_chat_flutter_core/lib/src/message_search_list_core.dart +++ b/packages/stream_chat_flutter_core/lib/src/message_search_list_core.dart @@ -46,7 +46,7 @@ class MessageSearchListCore extends StatefulWidget { /// * [loadingBuilder] /// * [childBuilder] MessageSearchListCore({ - Key? key, + super.key, required this.emptyBuilder, required this.errorBuilder, required this.loadingBuilder, @@ -76,8 +76,7 @@ class MessageSearchListCore extends StatefulWidget { sortOptions == null, 'Cannot specify `offset` with `sortOptions` parameter', ), - limit = limit ?? paginationParams?.limit ?? 30, - super(key: key); + limit = limit ?? paginationParams?.limit ?? 30; /// A [MessageSearchListController] allows reloading and pagination. /// Use [MessageSearchListController.loadData] and diff --git a/packages/stream_chat_flutter_core/lib/src/message_text_field_controller.dart b/packages/stream_chat_flutter_core/lib/src/message_text_field_controller.dart index 0f9f75c6..ff5c03a4 100644 --- a/packages/stream_chat_flutter_core/lib/src/message_text_field_controller.dart +++ b/packages/stream_chat_flutter_core/lib/src/message_text_field_controller.dart @@ -10,15 +10,15 @@ typedef TextStyleBuilder = TextStyle? Function( class MessageTextFieldController extends TextEditingController { /// Returns a new MessageTextFieldController MessageTextFieldController({ - String? text, + super.text, this.textPatternStyle, - }) : super(text: text); + }); /// Returns a new MessageTextFieldController with the given text [value]. MessageTextFieldController.fromValue( - TextEditingValue? value, { + super.value, { this.textPatternStyle, - }) : super.fromValue(value); + }) : super.fromValue(); /// A map of style to apply to the text matching the RegExp patterns. final Map? textPatternStyle; diff --git a/packages/stream_chat_flutter_core/lib/src/paged_value_scroll_view.dart b/packages/stream_chat_flutter_core/lib/src/paged_value_scroll_view.dart index 00d96f56..a078f471 100644 --- a/packages/stream_chat_flutter_core/lib/src/paged_value_scroll_view.dart +++ b/packages/stream_chat_flutter_core/lib/src/paged_value_scroll_view.dart @@ -26,7 +26,7 @@ typedef PagedValueScrollViewLoadMoreErrorBuilder = Widget Function( class PagedValueListView extends StatefulWidget { /// Creates a new instance of [PagedValueListView] widget. const PagedValueListView({ - Key? key, + super.key, required this.controller, required this.itemBuilder, required this.separatorBuilder, @@ -51,7 +51,7 @@ class PagedValueListView extends StatefulWidget { this.keyboardDismissBehavior = ScrollViewKeyboardDismissBehavior.manual, this.restorationId, this.clipBehavior = Clip.hardEdge, - }) : super(key: key); + }); /// The [PagedValueNotifier] used to control the list of items. final PagedValueNotifier controller; @@ -322,7 +322,7 @@ class _PagedValueListViewState extends State> { index == newPageRequestTriggerIndex; if (nextPageKey != null && isBuildingTriggerIndexItem) { // Schedules the request for the end of this frame. - WidgetsBinding.instance?.addPostFrameCallback((_) async { + WidgetsBinding.instance.addPostFrameCallback((_) async { if (error == null) { await _controller.loadMore(nextPageKey); } @@ -357,7 +357,7 @@ class _PagedValueListViewState extends State> { class PagedValueGridView extends StatefulWidget { /// Creates a new instance of [PagedValueGridView] widget. const PagedValueGridView({ - Key? key, + super.key, required this.controller, required this.gridDelegate, required this.itemBuilder, @@ -383,7 +383,7 @@ class PagedValueGridView extends StatefulWidget { this.keyboardDismissBehavior = ScrollViewKeyboardDismissBehavior.manual, this.restorationId, this.clipBehavior = Clip.hardEdge, - }) : super(key: key); + }); /// The [PagedValueNotifier] used to control the list of items. final PagedValueNotifier controller; @@ -678,7 +678,7 @@ class _PagedValueGridViewState extends State> { index == newPageRequestTriggerIndex; if (nextPageKey != null && isBuildingTriggerIndexItem) { // Schedules the request for the end of this frame. - WidgetsBinding.instance?.addPostFrameCallback((_) async { + WidgetsBinding.instance.addPostFrameCallback((_) async { if (error == null) { await _controller.loadMore(nextPageKey); } diff --git a/packages/stream_chat_flutter_core/lib/src/stream_channel.dart b/packages/stream_chat_flutter_core/lib/src/stream_channel.dart index 47822791..18e494e2 100644 --- a/packages/stream_chat_flutter_core/lib/src/stream_channel.dart +++ b/packages/stream_chat_flutter_core/lib/src/stream_channel.dart @@ -22,12 +22,12 @@ class StreamChannel extends StatefulWidget { /// Creates a new instance of [StreamChannel]. Both [child] and [client] must /// be supplied and not null. const StreamChannel({ - Key? key, + super.key, required this.child, required this.channel, this.showLoading = true, this.initialMessageId, - }) : super(key: key); + }); /// The child of the widget final Widget child; @@ -220,21 +220,20 @@ class StreamChannelState extends State { /// Loads channel at specific message Future loadChannelAtMessage( String? messageId, { - int before = 20, - int after = 20, + @Deprecated('before is deprecated, use limit instead') int before = 20, + @Deprecated('after is deprecated, use limit instead') int after = 20, + int limit = 20, bool preferOffline = false, }) => _queryAtMessage( messageId: messageId, - before: before, - after: after, + limit: limit, preferOffline: preferOffline, ); Future _queryAtMessage({ String? messageId, - int before = 20, - int after = 20, + int limit = 20, bool preferOffline = false, }) async { if (channel.state == null) return null; @@ -244,7 +243,7 @@ class StreamChannelState extends State { if (messageId == null) { await channel.query( messagesPagination: PaginationParams( - limit: before, + limit: limit, ), preferOffline: preferOffline, ); @@ -254,8 +253,7 @@ class StreamChannelState extends State { return queryAroundMessage( messageId, - before: before, - after: after, + limit: limit, preferOffline: preferOffline, ); } @@ -263,15 +261,15 @@ class StreamChannelState extends State { /// Future queryAroundMessage( String messageId, { - int before = 20, - int after = 20, + @Deprecated('before is deprecated, use limit instead') int before = 20, + @Deprecated('after is deprecated, use limit instead') int after = 20, + int limit = 20, bool preferOffline = false, }) => channel.query( messagesPagination: PaginationParams( idAround: messageId, - before: before, - after: after, + limit: limit, ), preferOffline: preferOffline, ); @@ -338,7 +336,7 @@ class StreamChannelState extends State { } /// Reloads the channel with latest message - Future reloadChannel() => _queryAtMessage(before: 30); + Future reloadChannel() => _queryAtMessage(limit: 30); late List> _futures; diff --git a/packages/stream_chat_flutter_core/lib/src/stream_channel_list_controller.dart b/packages/stream_chat_flutter_core/lib/src/stream_channel_list_controller.dart index 9fe5594c..61193ac2 100644 --- a/packages/stream_chat_flutter_core/lib/src/stream_channel_list_controller.dart +++ b/packages/stream_chat_flutter_core/lib/src/stream_channel_list_controller.dart @@ -55,7 +55,7 @@ class StreamChannelListController extends PagedValueNotifier { /// Creates a [StreamChannelListController] from the passed [value]. StreamChannelListController.fromValue( - PagedValue value, { + super.value, { required this.client, StreamChannelListEventHandler? eventHandler, this.filter, @@ -64,8 +64,7 @@ class StreamChannelListController extends PagedValueNotifier { this.limit = defaultChannelPagedLimit, this.messageLimit, this.memberLimit, - }) : _eventHandler = eventHandler ?? StreamChannelListEventHandler(), - super(value); + }) : _eventHandler = eventHandler ?? StreamChannelListEventHandler(); /// The client to use for the channels list. final StreamChatClient client; diff --git a/packages/stream_chat_flutter_core/lib/src/stream_chat_core.dart b/packages/stream_chat_flutter_core/lib/src/stream_chat_core.dart index 82f0a5d6..9b5f5dce 100644 --- a/packages/stream_chat_flutter_core/lib/src/stream_chat_core.dart +++ b/packages/stream_chat_flutter_core/lib/src/stream_chat_core.dart @@ -38,13 +38,13 @@ class StreamChatCore extends StatefulWidget { /// [StreamChatCore] is a stateful widget which reacts to system events and /// updates Stream's connection status accordingly. const StreamChatCore({ - Key? key, + super.key, required this.client, required this.child, this.onBackgroundEventReceived, this.backgroundKeepAlive = const Duration(minutes: 1), this.connectivityStream, - }) : super(key: key); + }); /// Instance of Stream Chat Client containing information about the current /// application. @@ -115,7 +115,7 @@ class StreamChatCoreState extends State @override void initState() { super.initState(); - WidgetsBinding.instance?.addObserver(this); + WidgetsBinding.instance.addObserver(this); _subscribeToConnectivityChange(widget.connectivityStream); } @@ -207,7 +207,7 @@ class StreamChatCoreState extends State @override void dispose() { - WidgetsBinding.instance?.removeObserver(this); + WidgetsBinding.instance.removeObserver(this); _unsubscribeFromConnectivityChange(); _eventSubscription?.cancel(); _disconnectTimer?.cancel(); diff --git a/packages/stream_chat_flutter_core/lib/src/stream_message_input_controller.dart b/packages/stream_chat_flutter_core/lib/src/stream_message_input_controller.dart index b8f9107d..9e1586de 100644 --- a/packages/stream_chat_flutter_core/lib/src/stream_message_input_controller.dart +++ b/packages/stream_chat_flutter_core/lib/src/stream_message_input_controller.dart @@ -52,7 +52,7 @@ class StreamMessageInputController extends ValueNotifier { Map? textPatternStyle, }) : _textEditingController = MessageTextFieldController.fromValue( initialMessage.text == null - ? const TextEditingValue() + ? TextEditingValue.empty : TextEditingValue( text: initialMessage.text!, composing: TextRange.collapsed(initialMessage.text!.length), diff --git a/packages/stream_chat_flutter_core/lib/src/stream_message_search_list_controller.dart b/packages/stream_chat_flutter_core/lib/src/stream_message_search_list_controller.dart index d5b8a2f3..b41a99f0 100644 --- a/packages/stream_chat_flutter_core/lib/src/stream_message_search_list_controller.dart +++ b/packages/stream_chat_flutter_core/lib/src/stream_message_search_list_controller.dart @@ -52,7 +52,7 @@ class StreamMessageSearchListController /// Creates a [StreamUserListController] from the passed [value]. StreamMessageSearchListController.fromValue( - PagedValue value, { + super.value, { required this.client, required this.filter, this.messageFilter, @@ -70,8 +70,7 @@ class StreamMessageSearchListController _activeFilter = filter, _activeMessageFilter = messageFilter, _activeSearchQuery = searchQuery, - _activeSort = sort, - super(value); + _activeSort = sort; /// The client to use for the channels list. final StreamChatClient client; diff --git a/packages/stream_chat_flutter_core/lib/src/stream_user_list_controller.dart b/packages/stream_chat_flutter_core/lib/src/stream_user_list_controller.dart index 1881e868..3e1b2892 100644 --- a/packages/stream_chat_flutter_core/lib/src/stream_user_list_controller.dart +++ b/packages/stream_chat_flutter_core/lib/src/stream_user_list_controller.dart @@ -40,15 +40,14 @@ class StreamUserListController extends PagedValueNotifier { /// Creates a [StreamUserListController] from the passed [value]. StreamUserListController.fromValue( - PagedValue value, { + super.value, { required this.client, this.filter, this.sort, this.presence = true, this.limit = defaultUserPagedLimit, }) : _activeFilter = filter, - _activeSort = sort, - super(value); + _activeSort = sort; /// The client to use for the channels list. final StreamChatClient client; diff --git a/packages/stream_chat_flutter_core/lib/src/user_list_core.dart b/packages/stream_chat_flutter_core/lib/src/user_list_core.dart index 03159afb..67841569 100644 --- a/packages/stream_chat_flutter_core/lib/src/user_list_core.dart +++ b/packages/stream_chat_flutter_core/lib/src/user_list_core.dart @@ -67,14 +67,14 @@ class UserListCore extends StatefulWidget { required this.emptyBuilder, required this.loadingBuilder, required this.listBuilder, - Key? key, + super.key, this.filter = const Filter.empty(), this.sort, this.presence, this.groupAlphabetically = false, this.userListController, this.limit = 30, - }) : super(key: key); + }); /// A [UserListController] allows reloading and pagination. /// Use [UserListController.loadData] and [UserListController.paginateData] @@ -170,11 +170,11 @@ class UserListCoreState extends State for (final key in groupedUsers.keys) { items ..add(ListHeaderItem(key)) - ..addAll(groupedUsers[key]!.map((e) => ListUserItem(e))); + ..addAll(groupedUsers[key]!.map(ListUserItem.new)); } return items; } - return users.map((e) => ListUserItem(e)).toList(); + return users.map(ListUserItem.new).toList(); }, ); 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 c01242ec..5db4f5f5 100644 --- a/packages/stream_chat_flutter_core/lib/src/users_bloc.dart +++ b/packages/stream_chat_flutter_core/lib/src/users_bloc.dart @@ -17,8 +17,8 @@ class UsersBloc extends StatefulWidget { /// not null. const UsersBloc({ required this.child, - Key? key, - }) : super(key: key); + super.key, + }); /// The widget child final Widget child; diff --git a/packages/stream_chat_flutter_core/pubspec.yaml b/packages/stream_chat_flutter_core/pubspec.yaml index 07d5f842..f0318fdd 100644 --- a/packages/stream_chat_flutter_core/pubspec.yaml +++ b/packages/stream_chat_flutter_core/pubspec.yaml @@ -1,12 +1,12 @@ 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: 4.1.0 +version: 4.2.0 repository: https://github.com/GetStream/stream-chat-flutter issue_tracker: https://github.com/GetStream/stream-chat-flutter/issues environment: - sdk: '>=2.14.0 <3.0.0' + sdk: '>=2.17.0 <3.0.0' flutter: ">=1.17.0" dependencies: @@ -14,10 +14,10 @@ dependencies: connectivity_plus: ^2.1.0 flutter: sdk: flutter - freezed_annotation: ^1.0.0 + freezed_annotation: ^2.0.3 meta: ^1.3.0 rxdart: ^0.27.0 - stream_chat: ^4.1.0 + stream_chat: ^4.2.0 dev_dependencies: build_runner: ^2.0.1 @@ -25,6 +25,6 @@ dev_dependencies: fake_async: ^1.2.0 flutter_test: sdk: flutter - freezed: ^1.0.0 + freezed: ^2.0.3 mocktail: ^0.3.0 diff --git a/packages/stream_chat_flutter_core/test/stream_channel_test.dart b/packages/stream_chat_flutter_core/test/stream_channel_test.dart index cccea24d..673bd4da 100644 --- a/packages/stream_chat_flutter_core/test/stream_channel_test.dart +++ b/packages/stream_chat_flutter_core/test/stream_channel_test.dart @@ -211,8 +211,7 @@ void main() { final paginationParams = PaginationParams( idAround: initialMessageId, - after: 20, - before: 20, + limit: 20, ); when(() => mockChannel.initialized).thenAnswer((_) async => true); diff --git a/packages/stream_chat_flutter_core/test/user_list_core_test.dart b/packages/stream_chat_flutter_core/test/user_list_core_test.dart index 86ae601d..89d0cdbd 100644 --- a/packages/stream_chat_flutter_core/test/user_list_core_test.dart +++ b/packages/stream_chat_flutter_core/test/user_list_core_test.dart @@ -265,7 +265,7 @@ void main() { .map((e) => Container( key: Key(e.key ?? ''), child: e.when( - headerItem: (heading) => Text(heading), + headerItem: Text.new, userItem: (user) => Text(user.id), ), )) @@ -333,7 +333,7 @@ void main() { .map((e) => Container( key: Key(e.key ?? ''), child: e.when( - headerItem: (heading) => Text(heading), + headerItem: Text.new, userItem: (user) => Text(user.id), ), )) @@ -438,7 +438,7 @@ void main() { .map((e) => Container( key: Key(e.key ?? ''), child: e.when( - headerItem: (heading) => Text(heading), + headerItem: Text.new, userItem: (user) => Text(user.id), ), )) diff --git a/packages/stream_chat_localizations/example/lib/add_new_lang.dart b/packages/stream_chat_localizations/example/lib/add_new_lang.dart index d0eca8e8..9becad2d 100644 --- a/packages/stream_chat_localizations/example/lib/add_new_lang.dart +++ b/packages/stream_chat_localizations/example/lib/add_new_lang.dart @@ -24,8 +24,7 @@ class _NnStreamChatLocalizationsDelegate /// and formatting. class NnStreamChatLocalizations extends GlobalStreamChatLocalizations { /// Create an instance of the translation bundle for English. - const NnStreamChatLocalizations({String localeName = 'nn'}) - : super(localeName: localeName); + const NnStreamChatLocalizations({super.localeName = 'nn'}); /// A [LocalizationsDelegate] for [NnStreamChatLocalizations]. static const delegate = _NnStreamChatLocalizationsDelegate(); @@ -86,7 +85,7 @@ class NnStreamChatLocalizations extends GlobalStreamChatLocalizations { @override String get sendMessagePermissionError => - 'You don\'t have permission to send messages'; + "You don't have permission to send messages"; @override String get emptyMessagesText => 'There are no messages currently'; @@ -223,7 +222,7 @@ class NnStreamChatLocalizations extends GlobalStreamChatLocalizations { @override String get operationCouldNotBeCompletedText => - 'The operation couldn\'t be completed.'; + "The operation couldn't be completed."; @override String get replyLabel => 'Reply'; @@ -453,10 +452,10 @@ class MyApp extends StatelessWidget { /// If you'd prefer using minimal wrapper widgets for your app, please see /// our other package, `stream_chat_flutter_core`. const MyApp({ - Key? key, + super.key, required this.client, required this.channel, - }) : super(key: key); + }); /// Instance of Stream Client. /// @@ -510,8 +509,8 @@ class MyApp extends StatelessWidget { class ChannelPage extends StatelessWidget { /// Creates the page that shows the list of messages const ChannelPage({ - Key? key, - }) : super(key: key); + super.key, + }); @override Widget build(BuildContext context) => Scaffold( diff --git a/packages/stream_chat_localizations/example/lib/main.dart b/packages/stream_chat_localizations/example/lib/main.dart index 55354e50..a212c82c 100644 --- a/packages/stream_chat_localizations/example/lib/main.dart +++ b/packages/stream_chat_localizations/example/lib/main.dart @@ -47,10 +47,10 @@ class MyApp extends StatelessWidget { /// If you'd prefer using minimal wrapper widgets for your app, please see /// our other package, `stream_chat_flutter_core`. const MyApp({ - Key? key, + super.key, required this.client, required this.channel, - }) : super(key: key); + }); /// Instance of Stream Client. /// @@ -101,8 +101,8 @@ class MyApp extends StatelessWidget { class ChannelPage extends StatelessWidget { /// Creates the page that shows the list of messages const ChannelPage({ - Key? key, - }) : super(key: key); + super.key, + }); @override Widget build(BuildContext context) => Scaffold( diff --git a/packages/stream_chat_localizations/example/lib/override_lang.dart b/packages/stream_chat_localizations/example/lib/override_lang.dart index 33ebaa99..f3621915 100644 --- a/packages/stream_chat_localizations/example/lib/override_lang.dart +++ b/packages/stream_chat_localizations/example/lib/override_lang.dart @@ -72,10 +72,10 @@ class MyApp extends StatelessWidget { /// If you'd prefer using minimal wrapper widgets for your app, please see /// our other package, `stream_chat_flutter_core`. const MyApp({ - Key? key, + super.key, required this.client, required this.channel, - }) : super(key: key); + }); /// Instance of Stream Client. /// @@ -128,8 +128,8 @@ class MyApp extends StatelessWidget { class ChannelPage extends StatelessWidget { /// Creates the page that shows the list of messages const ChannelPage({ - Key? key, - }) : super(key: key); + super.key, + }); @override Widget build(BuildContext context) => Scaffold( diff --git a/packages/stream_chat_localizations/example/pubspec.yaml b/packages/stream_chat_localizations/example/pubspec.yaml index db447618..5fcac8de 100644 --- a/packages/stream_chat_localizations/example/pubspec.yaml +++ b/packages/stream_chat_localizations/example/pubspec.yaml @@ -5,7 +5,7 @@ publish_to: 'none' version: 1.0.0+1 environment: - sdk: ">=2.12.0 <3.0.0" + sdk: '>=2.17.0 <3.0.0' dependencies: cupertino_icons: ^1.0.3 diff --git a/packages/stream_chat_localizations/lib/src/stream_chat_localizations_de.dart b/packages/stream_chat_localizations/lib/src/stream_chat_localizations_de.dart index 35b283ec..aa65e81d 100644 --- a/packages/stream_chat_localizations/lib/src/stream_chat_localizations_de.dart +++ b/packages/stream_chat_localizations/lib/src/stream_chat_localizations_de.dart @@ -3,8 +3,7 @@ part of 'stream_chat_localizations.dart'; /// The translations for German (`de`). class StreamChatLocalizationsDe extends GlobalStreamChatLocalizations { /// Create an instance of the translation bundle for German. - const StreamChatLocalizationsDe({String localeName = 'de'}) - : super(localeName: localeName); + const StreamChatLocalizationsDe({super.localeName = 'de'}); @override String get launchUrlError => 'Die Url kann nicht geöffnet werden'; diff --git a/packages/stream_chat_localizations/lib/src/stream_chat_localizations_en.dart b/packages/stream_chat_localizations/lib/src/stream_chat_localizations_en.dart index 1d1d82b3..ead459fa 100644 --- a/packages/stream_chat_localizations/lib/src/stream_chat_localizations_en.dart +++ b/packages/stream_chat_localizations/lib/src/stream_chat_localizations_en.dart @@ -3,8 +3,7 @@ part of 'stream_chat_localizations.dart'; /// The translations for English (`en`). class StreamChatLocalizationsEn extends GlobalStreamChatLocalizations { /// Create an instance of the translation bundle for English. - const StreamChatLocalizationsEn({String localeName = 'en'}) - : super(localeName: localeName); + const StreamChatLocalizationsEn({super.localeName = 'en'}); @override String get launchUrlError => 'Cannot launch the url'; @@ -62,7 +61,7 @@ class StreamChatLocalizationsEn extends GlobalStreamChatLocalizations { @override String get sendMessagePermissionError => - 'You don\'t have permission to send messages'; + "You don't have permission to send messages"; @override String get emptyMessagesText => 'There are no messages currently'; @@ -199,7 +198,7 @@ class StreamChatLocalizationsEn extends GlobalStreamChatLocalizations { @override String get operationCouldNotBeCompletedText => - 'The operation couldn\'t be completed.'; + "The operation couldn't be completed."; @override String get replyLabel => 'Reply'; diff --git a/packages/stream_chat_localizations/lib/src/stream_chat_localizations_es.dart b/packages/stream_chat_localizations/lib/src/stream_chat_localizations_es.dart index b906843f..d26e033a 100644 --- a/packages/stream_chat_localizations/lib/src/stream_chat_localizations_es.dart +++ b/packages/stream_chat_localizations/lib/src/stream_chat_localizations_es.dart @@ -3,8 +3,7 @@ part of 'stream_chat_localizations.dart'; /// The translations for Spanish (`es`). class StreamChatLocalizationsEs extends GlobalStreamChatLocalizations { /// Create an instance of the translation bundle for Spanish. - const StreamChatLocalizationsEs({String localeName = 'es'}) - : super(localeName: localeName); + const StreamChatLocalizationsEs({super.localeName = 'es'}); @override String get launchUrlError => 'No se pudo abrir la url'; diff --git a/packages/stream_chat_localizations/lib/src/stream_chat_localizations_fr.dart b/packages/stream_chat_localizations/lib/src/stream_chat_localizations_fr.dart index b5a44a51..5521ef57 100644 --- a/packages/stream_chat_localizations/lib/src/stream_chat_localizations_fr.dart +++ b/packages/stream_chat_localizations/lib/src/stream_chat_localizations_fr.dart @@ -3,8 +3,7 @@ part of 'stream_chat_localizations.dart'; /// The translations for French (`fr`). class StreamChatLocalizationsFr extends GlobalStreamChatLocalizations { /// Create an instance of the translation bundle for French. - const StreamChatLocalizationsFr({String localeName = 'fr'}) - : super(localeName: localeName); + const StreamChatLocalizationsFr({super.localeName = 'fr'}); @override String get launchUrlError => "Impossible de lancer l'url"; @@ -63,7 +62,7 @@ class StreamChatLocalizationsFr extends GlobalStreamChatLocalizations { @override String get sendMessagePermissionError => - 'Vous n\'êtes pas autorisé à envoyer des messages'; + "Vous n'êtes pas autorisé à envoyer des messages"; @override String get emptyMessagesText => "Il n'y a pas de messages actuellement"; @@ -383,7 +382,7 @@ Limite de pièces jointes dépassée : il n'est pas possible d'ajouter plus de $ @override String get linkDisabledDetails => - 'L\'envoi de liens n\'est pas autorisé dans cette conversation.'; + "L'envoi de liens n'est pas autorisé dans cette conversation."; @override String get linkDisabledError => 'Les liens sont désactivés'; diff --git a/packages/stream_chat_localizations/lib/src/stream_chat_localizations_hi.dart b/packages/stream_chat_localizations/lib/src/stream_chat_localizations_hi.dart index e07566bd..20ae9db2 100644 --- a/packages/stream_chat_localizations/lib/src/stream_chat_localizations_hi.dart +++ b/packages/stream_chat_localizations/lib/src/stream_chat_localizations_hi.dart @@ -3,8 +3,7 @@ part of 'stream_chat_localizations.dart'; /// The translations for Hindi (`hi`). class StreamChatLocalizationsHi extends GlobalStreamChatLocalizations { /// Create an instance of the translation bundle for Hindi. - const StreamChatLocalizationsHi({String localeName = 'hi'}) - : super(localeName: localeName); + const StreamChatLocalizationsHi({super.localeName = 'hi'}); @override String get launchUrlError => 'यूआरएल लॉन्च नहीं कर सकते'; diff --git a/packages/stream_chat_localizations/lib/src/stream_chat_localizations_it.dart b/packages/stream_chat_localizations/lib/src/stream_chat_localizations_it.dart index ffbdde94..f8b21ed4 100644 --- a/packages/stream_chat_localizations/lib/src/stream_chat_localizations_it.dart +++ b/packages/stream_chat_localizations/lib/src/stream_chat_localizations_it.dart @@ -3,17 +3,16 @@ part of 'stream_chat_localizations.dart'; /// The translations for Italian (`it`). class StreamChatLocalizationsIt extends GlobalStreamChatLocalizations { /// Create an instance of the translation bundle for Italian. - const StreamChatLocalizationsIt({String localeName = 'it'}) - : super(localeName: localeName); + const StreamChatLocalizationsIt({super.localeName = 'it'}); @override - String get launchUrlError => 'Impossibile aprire l\'url'; + String get launchUrlError => "Impossibile aprire l'url"; @override String get loadingUsersError => 'Errore durante il carimento degli utenti'; @override - String get noUsersLabel => 'Non c\'é nessun utente al momento'; + String get noUsersLabel => "Non c'é nessun utente al momento"; @override String get retryLabel => 'Riprova'; @@ -62,10 +61,10 @@ class StreamChatLocalizationsIt extends GlobalStreamChatLocalizations { @override String get sendMessagePermissionError => - 'Non hai l\'autorizzazione per inviare messaggi'; + "Non hai l'autorizzazione per inviare messaggi"; @override - String get emptyMessagesText => 'Non c\'é nessun messaggio al momento'; + String get emptyMessagesText => "Non c'é nessun messaggio al momento"; @override String get genericErrorText => 'Qualcosa è andato storto'; @@ -162,11 +161,11 @@ Il file è troppo grande per essere caricato. Il limite è di $limitInMB MB.'''; @override String get enablePhotoAndVideoAccessMessage => - 'Per favore attiva l\'accesso alle foto' + "Per favore attiva l'accesso alle foto" '\ne ai video cosí potrai condividerli con i tuoi amici.'; @override - String get allowGalleryAccessMessage => 'Permetti l\'accesso alla galleria'; + String get allowGalleryAccessMessage => "Permetti l'accesso alla galleria"; @override String get flagMessageLabel => 'Segnala messaggio'; diff --git a/packages/stream_chat_localizations/lib/src/stream_chat_localizations_ja.dart b/packages/stream_chat_localizations/lib/src/stream_chat_localizations_ja.dart index 7729a6ca..2faae6c4 100644 --- a/packages/stream_chat_localizations/lib/src/stream_chat_localizations_ja.dart +++ b/packages/stream_chat_localizations/lib/src/stream_chat_localizations_ja.dart @@ -3,8 +3,7 @@ part of 'stream_chat_localizations.dart'; /// The translations for Japanese (`ja`). class StreamChatLocalizationsJa extends GlobalStreamChatLocalizations { /// Create an instance of the translation bundle for Japanese. - const StreamChatLocalizationsJa({String localeName = 'ja'}) - : super(localeName: localeName); + const StreamChatLocalizationsJa({super.localeName = 'ja'}); @override String get launchUrlError => 'URLの起動ができません'; diff --git a/packages/stream_chat_localizations/lib/src/stream_chat_localizations_ko.dart b/packages/stream_chat_localizations/lib/src/stream_chat_localizations_ko.dart index c7c858f1..e541e529 100644 --- a/packages/stream_chat_localizations/lib/src/stream_chat_localizations_ko.dart +++ b/packages/stream_chat_localizations/lib/src/stream_chat_localizations_ko.dart @@ -3,8 +3,7 @@ part of 'stream_chat_localizations.dart'; /// The translations for Korean (`ko`). class StreamChatLocalizationsKo extends GlobalStreamChatLocalizations { /// Create an instance of the translation bundle for Korean. - const StreamChatLocalizationsKo({String localeName = 'ko'}) - : super(localeName: localeName); + const StreamChatLocalizationsKo({super.localeName = 'ko'}); @override String get launchUrlError => 'URL을 시작할 수 없습니다'; diff --git a/packages/stream_chat_localizations/lib/src/stream_chat_localizations_pt.dart b/packages/stream_chat_localizations/lib/src/stream_chat_localizations_pt.dart index 3a1a7696..74e9a1f4 100644 --- a/packages/stream_chat_localizations/lib/src/stream_chat_localizations_pt.dart +++ b/packages/stream_chat_localizations/lib/src/stream_chat_localizations_pt.dart @@ -3,8 +3,7 @@ part of 'stream_chat_localizations.dart'; /// The translations for Portuguese (`pt`). class StreamChatLocalizationsPt extends GlobalStreamChatLocalizations { /// Create an instance of the translation bundle for Portuguese. - const StreamChatLocalizationsPt({String localeName = 'pt'}) - : super(localeName: localeName); + const StreamChatLocalizationsPt({super.localeName = 'pt'}); @override String get launchUrlError => 'O URL não pôde ser aberto'; diff --git a/packages/stream_chat_localizations/pubspec.yaml b/packages/stream_chat_localizations/pubspec.yaml index e9ffb1c8..b0c4a96e 100644 --- a/packages/stream_chat_localizations/pubspec.yaml +++ b/packages/stream_chat_localizations/pubspec.yaml @@ -6,7 +6,7 @@ repository: https://github.com/GetStream/stream-chat-flutter issue_tracker: https://github.com/GetStream/stream-chat-flutter/issues environment: - sdk: ">=2.12.0 <3.0.0" + sdk: '>=2.17.0 <3.0.0' flutter: ">=1.17.0" dependencies: diff --git a/packages/stream_chat_localizations/test/basics_test.dart b/packages/stream_chat_localizations/test/basics_test.dart index 8491a332..ae52a1af 100644 --- a/packages/stream_chat_localizations/test/basics_test.dart +++ b/packages/stream_chat_localizations/test/basics_test.dart @@ -92,7 +92,7 @@ class DummyLocalizations { } class LocalizationTracker extends StatefulWidget { - const LocalizationTracker({Key? key}) : super(key: key); + const LocalizationTracker({super.key}); @override State createState() => LocalizationTrackerState(); diff --git a/packages/stream_chat_persistence/example/lib/main.dart b/packages/stream_chat_persistence/example/lib/main.dart index 049868fa..5771d716 100644 --- a/packages/stream_chat_persistence/example/lib/main.dart +++ b/packages/stream_chat_persistence/example/lib/main.dart @@ -52,10 +52,10 @@ class StreamExample extends StatelessWidget { /// To initialize this example, an instance of /// [client] and [channel] is required. const StreamExample({ - Key? key, + super.key, required this.client, required this.channel, - }) : super(key: key); + }); /// Instance of [StreamChatClient] we created earlier. /// This contains information about our application and connection state. @@ -76,9 +76,9 @@ class StreamExample extends StatelessWidget { class HomeScreen extends StatelessWidget { /// [HomeScreen] is constructed using the [Channel] we defined earlier. const HomeScreen({ - Key? key, + super.key, required this.channel, - }) : super(key: key); + }); /// Channel object containing the [Channel.id] we'd like to observe. final Channel channel; @@ -129,10 +129,10 @@ class HomeScreen extends StatelessWidget { class MessageView extends StatefulWidget { /// Message takes the latest list of messages and the current channel. const MessageView({ - Key? key, + super.key, required this.messages, required this.channel, - }) : super(key: key); + }); /// List of messages sent in the given channel. final List messages; diff --git a/packages/stream_chat_persistence/example/pubspec.yaml b/packages/stream_chat_persistence/example/pubspec.yaml index 6c6e8c6d..34f56989 100644 --- a/packages/stream_chat_persistence/example/pubspec.yaml +++ b/packages/stream_chat_persistence/example/pubspec.yaml @@ -5,7 +5,7 @@ publish_to: 'none' version: 1.0.0+1 environment: - sdk: ">=2.12.0 <3.0.0" + sdk: '>=2.17.0 <3.0.0' dependencies: cupertino_icons: ^1.0.3 diff --git a/packages/stream_chat_persistence/lib/src/dao/channel_dao.dart b/packages/stream_chat_persistence/lib/src/dao/channel_dao.dart index 50f3b2a6..f3a3de41 100644 --- a/packages/stream_chat_persistence/lib/src/dao/channel_dao.dart +++ b/packages/stream_chat_persistence/lib/src/dao/channel_dao.dart @@ -12,7 +12,7 @@ part 'channel_dao.g.dart'; class ChannelDao extends DatabaseAccessor with _$ChannelDaoMixin { /// Creates a new channel dao instance - ChannelDao(DriftChatDatabase db) : super(db); + ChannelDao(super.db); /// Get channel by cid Future getChannelByCid(String cid) async => diff --git a/packages/stream_chat_persistence/lib/src/dao/channel_query_dao.dart b/packages/stream_chat_persistence/lib/src/dao/channel_query_dao.dart index 75a5db13..acac4993 100644 --- a/packages/stream_chat_persistence/lib/src/dao/channel_query_dao.dart +++ b/packages/stream_chat_persistence/lib/src/dao/channel_query_dao.dart @@ -15,7 +15,7 @@ part 'channel_query_dao.g.dart'; class ChannelQueryDao extends DatabaseAccessor with _$ChannelQueryDaoMixin { /// Creates a new channel query dao instance - ChannelQueryDao(DriftChatDatabase db) : super(db); + ChannelQueryDao(super.db); String _computeHash(Filter? filter) { if (filter == null) { diff --git a/packages/stream_chat_persistence/lib/src/dao/connection_event_dao.dart b/packages/stream_chat_persistence/lib/src/dao/connection_event_dao.dart index b9b4a52d..fa7ff982 100644 --- a/packages/stream_chat_persistence/lib/src/dao/connection_event_dao.dart +++ b/packages/stream_chat_persistence/lib/src/dao/connection_event_dao.dart @@ -12,7 +12,7 @@ part 'connection_event_dao.g.dart'; class ConnectionEventDao extends DatabaseAccessor with _$ConnectionEventDaoMixin { /// Creates a new connection event dao instance - ConnectionEventDao(DriftChatDatabase db) : super(db); + ConnectionEventDao(super.db); /// Get the latest stored connection event Future get connectionEvent => select(connectionEvents) diff --git a/packages/stream_chat_persistence/lib/src/dao/member_dao.dart b/packages/stream_chat_persistence/lib/src/dao/member_dao.dart index 9f81879c..ccf843fb 100644 --- a/packages/stream_chat_persistence/lib/src/dao/member_dao.dart +++ b/packages/stream_chat_persistence/lib/src/dao/member_dao.dart @@ -14,7 +14,7 @@ part 'member_dao.g.dart'; class MemberDao extends DatabaseAccessor with _$MemberDaoMixin { /// Creates a new member dao instance - MemberDao(DriftChatDatabase db) : super(db); + MemberDao(super.db); /// Get all members where [Members.channelCid] matches [cid] Future> getMembersByCid(String cid) async => diff --git a/packages/stream_chat_persistence/lib/src/dao/pinned_message_reaction_dao.dart b/packages/stream_chat_persistence/lib/src/dao/pinned_message_reaction_dao.dart index 4a37984a..c5c5a6d4 100644 --- a/packages/stream_chat_persistence/lib/src/dao/pinned_message_reaction_dao.dart +++ b/packages/stream_chat_persistence/lib/src/dao/pinned_message_reaction_dao.dart @@ -12,7 +12,7 @@ part 'pinned_message_reaction_dao.g.dart'; class PinnedMessageReactionDao extends DatabaseAccessor with _$PinnedMessageReactionDaoMixin { /// Creates a new reaction dao instance - PinnedMessageReactionDao(DriftChatDatabase db) : super(db); + PinnedMessageReactionDao(super.db); /// Returns all the reactions of a particular message by matching /// [Reactions.messageId] with [messageId] diff --git a/packages/stream_chat_persistence/lib/src/dao/reaction_dao.dart b/packages/stream_chat_persistence/lib/src/dao/reaction_dao.dart index 7b0b5b8c..d6dae9bd 100644 --- a/packages/stream_chat_persistence/lib/src/dao/reaction_dao.dart +++ b/packages/stream_chat_persistence/lib/src/dao/reaction_dao.dart @@ -12,7 +12,7 @@ part 'reaction_dao.g.dart'; class ReactionDao extends DatabaseAccessor with _$ReactionDaoMixin { /// Creates a new reaction dao instance - ReactionDao(DriftChatDatabase db) : super(db); + ReactionDao(super.db); /// Returns all the reactions of a particular message by matching /// [Reactions.messageId] with [messageId] diff --git a/packages/stream_chat_persistence/lib/src/dao/read_dao.dart b/packages/stream_chat_persistence/lib/src/dao/read_dao.dart index 9e46f818..4e2024f1 100644 --- a/packages/stream_chat_persistence/lib/src/dao/read_dao.dart +++ b/packages/stream_chat_persistence/lib/src/dao/read_dao.dart @@ -11,7 +11,7 @@ part 'read_dao.g.dart'; @DriftAccessor(tables: [Reads, Users]) class ReadDao extends DatabaseAccessor with _$ReadDaoMixin { /// Creates a new read dao instance - ReadDao(DriftChatDatabase db) : super(db); + ReadDao(super.db); /// Get all reads where [Reads.channelCid] matches [cid] Future> getReadsByCid(String cid) async => (select(reads).join([ diff --git a/packages/stream_chat_persistence/lib/src/dao/user_dao.dart b/packages/stream_chat_persistence/lib/src/dao/user_dao.dart index a53a4131..1366dd25 100644 --- a/packages/stream_chat_persistence/lib/src/dao/user_dao.dart +++ b/packages/stream_chat_persistence/lib/src/dao/user_dao.dart @@ -10,7 +10,7 @@ part 'user_dao.g.dart'; @DriftAccessor(tables: [Users]) class UserDao extends DatabaseAccessor with _$UserDaoMixin { /// Creates a new user dao instance - UserDao(DriftChatDatabase db) : super(db); + UserDao(super.db); /// Updates the users data with the new [userList] data Future updateUsers(List userList) => batch( diff --git a/packages/stream_chat_persistence/pubspec.yaml b/packages/stream_chat_persistence/pubspec.yaml index 4d3ed908..6c517f3f 100644 --- a/packages/stream_chat_persistence/pubspec.yaml +++ b/packages/stream_chat_persistence/pubspec.yaml @@ -6,7 +6,7 @@ repository: https://github.com/GetStream/stream-chat-flutter issue_tracker: https://github.com/GetStream/stream-chat-flutter/issues environment: - sdk: ">=2.12.0 <3.0.0" + sdk: '>=2.17.0 <3.0.0' flutter: ">=1.17.0" dependencies: