diff --git a/packages/stream_chat/lib/src/api/channel.dart b/packages/stream_chat/lib/src/api/channel.dart index 35989a72..17755b6d 100644 --- a/packages/stream_chat/lib/src/api/channel.dart +++ b/packages/stream_chat/lib/src/api/channel.dart @@ -204,7 +204,8 @@ class Channel { /// Channel extra data as a stream Stream> get extraDataStream { _checkInitialized(); - return state!.channelStateStream.map( + return state!.channelStateStream + .map( (cs) => cs.channel?.extraData ?? _extraData, ); } 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 0ad06cc0..e2686638 100644 --- a/packages/stream_chat_flutter/lib/src/attachment/attachment_title.dart +++ b/packages/stream_chat_flutter/lib/src/attachment/attachment_title.dart @@ -11,7 +11,7 @@ class AttachmentTitle extends StatelessWidget { required this.messageTheme, }) : super(key: key); - final MessageTheme? messageTheme; + final MessageTheme messageTheme; final Attachment attachment; @override @@ -32,7 +32,7 @@ class AttachmentTitle extends StatelessWidget { Text( attachment.title!, overflow: TextOverflow.ellipsis, - style: messageTheme?.messageText?.copyWith( + style: messageTheme.messageText?.copyWith( color: StreamChatTheme.of(context).colorTheme.accentBlue, fontWeight: FontWeight.bold, ), @@ -47,7 +47,7 @@ class AttachmentTitle extends StatelessWidget { .toList() .reversed .join('.'), - style: messageTheme?.messageText, + style: messageTheme.messageText, ), ], ), 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 929cddc2..90ef92b1 100644 --- a/packages/stream_chat_flutter/lib/src/attachment/file_attachment.dart +++ b/packages/stream_chat_flutter/lib/src/attachment/file_attachment.dart @@ -155,7 +155,7 @@ class FileAttachment extends AttachmentWidget { shape: _getDefaultShape(context), child: source.when( local: () => VideoThumbnailImage( - video: attachment.file?.path, + video: attachment.file!.path!, placeholderBuilder: (_) { return Center( child: Container( @@ -167,7 +167,7 @@ class FileAttachment extends AttachmentWidget { }, ), network: () => VideoThumbnailImage( - video: attachment.assetUrl, + video: attachment.assetUrl!, placeholderBuilder: (_) { return Center( child: Container( 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 6ac48f59..1ff9b8a9 100644 --- a/packages/stream_chat_flutter/lib/src/attachment/image_attachment.dart +++ b/packages/stream_chat_flutter/lib/src/attachment/image_attachment.dart @@ -10,7 +10,7 @@ import 'attachment_title.dart'; import 'attachment_widget.dart'; class ImageAttachment extends AttachmentWidget { - final MessageTheme? messageTheme; + final MessageTheme messageTheme; final bool showTitle; final ShowMessageCallback? onShowMessage; final ValueChanged? onReturnAction; @@ -20,8 +20,8 @@ class ImageAttachment extends AttachmentWidget { Key? key, required Message message, required Attachment attachment, + required this.messageTheme, Size? size, - this.messageTheme, this.showTitle = false, this.onShowMessage, this.onReturnAction, @@ -157,7 +157,7 @@ class ImageAttachment extends AttachmentWidget { ), if (showTitle && attachment.title != null) Material( - color: messageTheme?.messageBackgroundColor, + color: messageTheme.messageBackgroundColor, child: AttachmentTitle( messageTheme: messageTheme, attachment: attachment, 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 05c511b5..4ffbee1b 100644 --- a/packages/stream_chat_flutter/lib/src/attachment/video_attachment.dart +++ b/packages/stream_chat_flutter/lib/src/attachment/video_attachment.dart @@ -8,7 +8,7 @@ import 'attachment_upload_state_builder.dart'; import 'attachment_widget.dart'; class VideoAttachment extends AttachmentWidget { - final MessageTheme? messageTheme; + final MessageTheme messageTheme; final ShowMessageCallback? onShowMessage; final ValueChanged? onReturnAction; final VoidCallback? onAttachmentTap; @@ -17,8 +17,8 @@ class VideoAttachment extends AttachmentWidget { Key? key, required Message message, required Attachment attachment, + required this.messageTheme, Size? size, - this.messageTheme, this.onShowMessage, this.onReturnAction, this.onAttachmentTap, @@ -39,7 +39,7 @@ class VideoAttachment extends AttachmentWidget { return _buildVideoAttachment( context, VideoThumbnailImage( - video: attachment.file?.path, + video: attachment.file!.path!, height: size?.height, width: size?.width, fit: BoxFit.cover, @@ -54,7 +54,7 @@ class VideoAttachment extends AttachmentWidget { return _buildVideoAttachment( context, VideoThumbnailImage( - video: attachment.assetUrl, + video: attachment.assetUrl!, height: size?.height, width: size?.width, fit: BoxFit.cover, @@ -116,7 +116,7 @@ class VideoAttachment extends AttachmentWidget { ), if (attachment.title != null) Material( - color: messageTheme?.messageBackgroundColor, + color: messageTheme.messageBackgroundColor, child: AttachmentTitle( messageTheme: messageTheme, attachment: attachment, diff --git a/packages/stream_chat_flutter/lib/src/deleted_message.dart b/packages/stream_chat_flutter/lib/src/deleted_message.dart index c0387982..b3071904 100644 --- a/packages/stream_chat_flutter/lib/src/deleted_message.dart +++ b/packages/stream_chat_flutter/lib/src/deleted_message.dart @@ -14,7 +14,7 @@ class DeletedMessage extends StatelessWidget { }) : super(key: key); /// The theme of the message - final MessageTheme? messageTheme; + final MessageTheme messageTheme; /// The border radius of the message text final BorderRadiusGeometry? borderRadiusGeometry; @@ -34,7 +34,7 @@ class DeletedMessage extends StatelessWidget { transform: Matrix4.rotationY(reverse ? pi : 0), alignment: Alignment.center, child: Material( - color: messageTheme?.messageBackgroundColor, + color: messageTheme.messageBackgroundColor, shape: shape ?? RoundedRectangleBorder( borderRadius: borderRadiusGeometry ?? BorderRadius.zero, @@ -61,9 +61,9 @@ class DeletedMessage extends StatelessWidget { alignment: Alignment.center, child: Text( 'Message deleted', - style: messageTheme?.messageText?.copyWith( + style: messageTheme.messageText?.copyWith( fontStyle: FontStyle.italic, - color: messageTheme?.createdAt?.color, + color: messageTheme.createdAt?.color, ), ), ), 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 4956fb28..f960b5ee 100644 --- a/packages/stream_chat_flutter/lib/src/full_screen_media.dart +++ b/packages/stream_chat_flutter/lib/src/full_screen_media.dart @@ -177,7 +177,6 @@ class _FullScreenMediaState extends State Navigator.of(context).pop(); }, message: widget.message, - urls: widget.mediaAttachments, currentIndex: _currentPage, onShowMessage: () { widget.onShowMessage?.call( diff --git a/packages/stream_chat_flutter/lib/src/image_footer.dart b/packages/stream_chat_flutter/lib/src/image_footer.dart index a25d1be3..27c92674 100644 --- a/packages/stream_chat_flutter/lib/src/image_footer.dart +++ b/packages/stream_chat_flutter/lib/src/image_footer.dart @@ -221,8 +221,8 @@ class _ImageFooterState extends State { child: FittedBox( fit: BoxFit.cover, child: VideoThumbnailImage( - video: attachment.file?.path ?? - attachment.assetUrl, + video: (attachment.file?.path ?? + attachment.assetUrl)!, ), ), ); diff --git a/packages/stream_chat_flutter/lib/src/image_group.dart b/packages/stream_chat_flutter/lib/src/image_group.dart index 85e28497..a08d13de 100644 --- a/packages/stream_chat_flutter/lib/src/image_group.dart +++ b/packages/stream_chat_flutter/lib/src/image_group.dart @@ -15,7 +15,7 @@ class ImageGroup extends StatelessWidget { final List images; final Message message; - final MessageTheme? messageTheme; + final MessageTheme messageTheme; final Size size; final ShowMessageCallback? onShowMessage; diff --git a/packages/stream_chat_flutter/lib/src/image_header.dart b/packages/stream_chat_flutter/lib/src/image_header.dart index 1cec9c36..6837722c 100644 --- a/packages/stream_chat_flutter/lib/src/image_header.dart +++ b/packages/stream_chat_flutter/lib/src/image_header.dart @@ -27,15 +27,13 @@ class ImageHeader extends StatelessWidget implements PreferredSizeWidget { final String userName; final String sentAt; - final List urls; - final currentIndex; + final int currentIndex; /// Creates a channel header ImageHeader({ Key? key, required this.message, - this.urls = const [], - this.currentIndex, + this.currentIndex = 0, this.showBackButton = true, this.onBackPressed, this.onShowMessage, 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 5d97bdf6..b737bd09 100644 --- a/packages/stream_chat_flutter/lib/src/message_actions_modal.dart +++ b/packages/stream_chat_flutter/lib/src/message_actions_modal.dart @@ -20,7 +20,7 @@ class MessageActionsModal extends StatefulWidget { final OnMessageTap? onThreadReplyTap; final OnMessageTap? onReplyTap; final Message message; - final MessageTheme? messageTheme; + final MessageTheme messageTheme; final bool showReactions; final OnMessageTap? onCopyTap; final bool showDeleteMessage; @@ -92,7 +92,7 @@ class _MessageActionsModalState extends State { } } final roughSentenceSize = messageTextLength * - (widget.messageTheme?.messageText?.fontSize ?? 1) * + (widget.messageTheme.messageText?.fontSize ?? 1) * 1.2; final divFactor = widget.message.attachments.isNotEmpty == true ? 1 @@ -149,7 +149,6 @@ class _MessageActionsModalState extends State { 0.0), child: ReactionPicker( message: widget.message, - messageTheme: widget.messageTheme, ), ), SizedBox(height: 8), diff --git a/packages/stream_chat_flutter/lib/src/message_input.dart b/packages/stream_chat_flutter/lib/src/message_input.dart index c7ddb5f1..33917de0 100644 --- a/packages/stream_chat_flutter/lib/src/message_input.dart +++ b/packages/stream_chat_flutter/lib/src/message_input.dart @@ -1661,7 +1661,7 @@ class MessageInputState extends State { VideoThumbnailImage( height: 104, width: 104, - video: attachment.file?.path ?? attachment.assetUrl, + video: (attachment.file?.path ?? attachment.assetUrl)!, fit: BoxFit.cover, ), Positioned( 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 f444224d..8f36baeb 100644 --- a/packages/stream_chat_flutter/lib/src/message_list_view.dart +++ b/packages/stream_chat_flutter/lib/src/message_list_view.dart @@ -832,7 +832,7 @@ class _MessageListViewState extends State { break; case ReturnActionType.reply: FocusScope.of(context).unfocus(); - widget.onMessageSwiped!(message); + widget.onMessageSwiped?.call(message); break; } }, @@ -1008,7 +1008,7 @@ class _MessageListViewState extends State { break; case ReturnActionType.reply: FocusScope.of(context).unfocus(); - widget.onMessageSwiped!(message); + widget.onMessageSwiped?.call(message); break; } }, @@ -1034,7 +1034,7 @@ class _MessageListViewState extends State { child: Swipeable( onSwipeEnd: () { FocusScope.of(context).unfocus(); - widget.onMessageSwiped!(message); + widget.onMessageSwiped?.call(message); }, backgroundIcon: StreamSvgIcon.reply( color: StreamChatTheme.of(context).colorTheme.accentBlue, 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 ed9534ac..9fa35cb6 100644 --- a/packages/stream_chat_flutter/lib/src/message_reactions_modal.dart +++ b/packages/stream_chat_flutter/lib/src/message_reactions_modal.dart @@ -14,7 +14,7 @@ import 'stream_chat_theme.dart'; class MessageReactionsModal extends StatelessWidget { final Message message; - final MessageTheme? messageTheme; + final MessageTheme messageTheme; final bool reverse; final bool showReactions; final DisplayWidget showUserAvatar; @@ -53,7 +53,7 @@ class MessageReactionsModal extends StatelessWidget { } } final roughSentenceSize = - messageTextLength * (messageTheme?.messageText?.fontSize ?? 1) * 1.2; + messageTextLength * (messageTheme.messageText?.fontSize ?? 1) * 1.2; final divFactor = message.attachments.isNotEmpty == true ? 1 : (roughSentenceSize == 0 ? 1 : (roughSentenceSize / roughMaxSize)); @@ -105,7 +105,6 @@ class MessageReactionsModal extends StatelessWidget { 0.0), child: ReactionPicker( message: message, - messageTheme: messageTheme, ), ), const SizedBox(height: 8), @@ -244,9 +243,9 @@ class MessageReactionsModal extends StatelessWidget { child: ReactionBubble( reactions: [reaction], flipTail: !reverse, - borderColor: messageTheme?.reactionsBorderColor ?? - Colors.transparent, - backgroundColor: messageTheme?.reactionsBackgroundColor ?? + borderColor: + messageTheme.reactionsBorderColor ?? Colors.transparent, + backgroundColor: messageTheme.reactionsBackgroundColor ?? Colors.transparent, maskColor: StreamChatTheme.of(context).colorTheme.white, tailCirclesSpacing: 1, diff --git a/packages/stream_chat_flutter/lib/src/message_text.dart b/packages/stream_chat_flutter/lib/src/message_text.dart index eb80b89b..b0099eff 100644 --- a/packages/stream_chat_flutter/lib/src/message_text.dart +++ b/packages/stream_chat_flutter/lib/src/message_text.dart @@ -18,11 +18,11 @@ class MessageText extends StatelessWidget { final Message message; final void Function(User)? onMentionTap; final void Function(String)? onLinkTap; - final MessageTheme? messageTheme; + final MessageTheme messageTheme; @override Widget build(BuildContext context) { - final text = _replaceMentions(message.text)!.replaceAll('\n', '\\\n'); + final text = _replaceMentions(message.text ?? '').replaceAll('\n', '\\\n'); return MarkdownBody( data: text, @@ -55,23 +55,23 @@ class MessageText extends StatelessWidget { styleSheet: MarkdownStyleSheet.fromTheme( Theme.of(context).copyWith( textTheme: Theme.of(context).textTheme.apply( - bodyColor: messageTheme!.messageText!.color, - decoration: messageTheme!.messageText!.decoration, - decorationColor: messageTheme!.messageText!.decorationColor, - decorationStyle: messageTheme!.messageText!.decorationStyle, - fontFamily: messageTheme!.messageText!.fontFamily, + bodyColor: messageTheme.messageText?.color, + decoration: messageTheme.messageText?.decoration, + decorationColor: messageTheme.messageText?.decorationColor, + decorationStyle: messageTheme.messageText?.decorationStyle, + fontFamily: messageTheme.messageText?.fontFamily, ), ), ).copyWith( - a: messageTheme!.messageLinks, - p: messageTheme!.messageText, + a: messageTheme.messageLinks, + p: messageTheme.messageText, ), ); } - String? _replaceMentions(String? text) { + String _replaceMentions(String text) { message.mentionedUsers.map((u) => u.name).toSet().forEach((userName) { - text = text!.replaceAll( + text = text.replaceAll( '@$userName', '[@$userName](@${userName.replaceAll(' ', '')})'); }); return text; diff --git a/packages/stream_chat_flutter/lib/src/message_widget.dart b/packages/stream_chat_flutter/lib/src/message_widget.dart index 1e8049f8..b05762ba 100644 --- a/packages/stream_chat_flutter/lib/src/message_widget.dart +++ b/packages/stream_chat_flutter/lib/src/message_widget.dart @@ -66,7 +66,7 @@ class MessageWidget extends StatefulWidget { final Message message; /// The message theme - final MessageTheme? messageTheme; + final MessageTheme messageTheme; /// If true the widget will be mirrored final bool reverse; @@ -93,7 +93,7 @@ class MessageWidget extends StatefulWidget { final EdgeInsetsGeometry? padding; /// The internal padding of the message text - final EdgeInsetsGeometry textPadding; + final EdgeInsets textPadding; /// The internal padding of an attachment final EdgeInsetsGeometry attachmentPadding; @@ -222,7 +222,7 @@ class MessageWidget extends StatefulWidget { child: wrapAttachmentWidget( context, Material( - color: messageTheme?.messageBackgroundColor, + color: messageTheme.messageBackgroundColor, child: ImageGroup( size: Size( MediaQuery.of(context).size.width * 0.8, @@ -425,7 +425,7 @@ class _MessageWidgetState extends State Widget build(BuildContext context) { super.build(context); final avatarWidth = - widget.messageTheme?.avatarTheme?.constraints.maxWidth ?? 40; + widget.messageTheme.avatarTheme?.constraints.maxWidth ?? 40; var leftPadding = widget.showUserAvatar != DisplayWidget.gone ? avatarWidth + 8.5 : 0.5; @@ -544,7 +544,7 @@ class _MessageWidgetState extends State BorderSide( color: widget .messageTheme - ?.messageBorderColor ?? + .messageBorderColor ?? Colors.grey, ), borderRadius: widget @@ -702,7 +702,7 @@ class _MessageWidgetState extends State ), InkWell( onTap: widget.onThreadTap != null ? onThreadTap : null, - child: Text(msg, style: widget.messageTheme?.replies), + child: Text(msg, style: widget.messageTheme.replies), ), ], if (showUsername) @@ -710,13 +710,13 @@ class _MessageWidgetState extends State widget.message.user!.name, maxLines: 1, key: usernameKey, - style: widget.messageTheme?.messageAuthor, + style: widget.messageTheme.messageAuthor, overflow: TextOverflow.ellipsis, ), if (showTimeStamp) Text( Jiffy(widget.message.createdAt.toLocal()).jm, - style: widget.messageTheme?.createdAt, + style: widget.messageTheme.createdAt, ), if (showSendingIndicator) _buildSendingIndicator(), ]); @@ -731,13 +731,13 @@ class _MessageWidgetState extends State Container( margin: EdgeInsets.only( bottom: context.textScaleFactor * - ((widget.messageTheme?.replies?.fontSize ?? 1) / 2), + ((widget.messageTheme.replies?.fontSize ?? 1) / 2), ), child: CustomPaint( size: Size(16, 32) * context.textScaleFactor, painter: _ThreadReplyPainter( context: context, - color: widget.messageTheme?.messageBorderColor, + color: widget.messageTheme.messageBorderColor, ), ), ), @@ -775,7 +775,7 @@ class _MessageWidgetState extends State return UrlAttachment( urlAttachment: urlAttachment, hostDisplayName: hostDisplayName, - textPadding: widget.textPadding as EdgeInsets, + textPadding: widget.textPadding, ); } @@ -830,12 +830,11 @@ class _MessageWidgetState extends State key: ValueKey('${widget.message.id}.reactions'), reverse: widget.reverse, flipTail: widget.reverse, - backgroundColor: - widget.messageTheme?.reactionsBackgroundColor ?? - Colors.transparent, - borderColor: widget.messageTheme?.reactionsBorderColor ?? + backgroundColor: widget.messageTheme.reactionsBackgroundColor ?? Colors.transparent, - maskColor: widget.messageTheme?.reactionsMaskColor ?? + borderColor: widget.messageTheme.reactionsBorderColor ?? + Colors.transparent, + maskColor: widget.messageTheme.reactionsMaskColor ?? Colors.transparent, reactions: reactionsList, ), @@ -1001,7 +1000,7 @@ class _MessageWidgetState extends State } Widget _buildSendingIndicator() { - final style = widget.messageTheme?.createdAt; + final style = widget.messageTheme.createdAt; final message = widget.message; if (hasNonUrlAttachments && @@ -1053,7 +1052,7 @@ class _MessageWidgetState extends State offset: Offset( 0, widget.translateUserAvatar - ? (widget.messageTheme?.avatarTheme?.constraints.maxHeight ?? + ? (widget.messageTheme.avatarTheme?.constraints.maxHeight ?? 40) / 2 : 0, @@ -1061,8 +1060,8 @@ class _MessageWidgetState extends State child: UserAvatar( user: widget.message.user!, onTap: widget.onUserAvatarTap, - constraints: widget.messageTheme?.avatarTheme!.constraints, - borderRadius: widget.messageTheme?.avatarTheme!.borderRadius, + constraints: widget.messageTheme.avatarTheme!.constraints, + borderRadius: widget.messageTheme.avatarTheme!.borderRadius, showOnlineStatus: false, ), ), @@ -1085,9 +1084,9 @@ class _MessageWidgetState extends State message: widget.message, onMentionTap: widget.onMentionTap, messageTheme: isOnlyEmoji - ? widget.messageTheme?.copyWith( + ? widget.messageTheme.copyWith( messageText: - widget.messageTheme?.messageText!.copyWith( + widget.messageTheme.messageText!.copyWith( fontSize: 42, )) : widget.messageTheme, @@ -1103,7 +1102,7 @@ class _MessageWidgetState extends State Color? _getBackgroundColor() { if (hasQuotedMessage) { - return widget.messageTheme?.messageBackgroundColor; + return widget.messageTheme.messageBackgroundColor; } if (hasUrlAttachments) { @@ -1118,7 +1117,7 @@ class _MessageWidgetState extends State return Colors.transparent; } - return widget.messageTheme?.messageBackgroundColor; + return widget.messageTheme.messageBackgroundColor; } void retryMessage(BuildContext context) { 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 bc77e97a..369fb4db 100644 --- a/packages/stream_chat_flutter/lib/src/quoted_message_widget.dart +++ b/packages/stream_chat_flutter/lib/src/quoted_message_widget.dart @@ -67,7 +67,7 @@ class QuotedMessageWidget extends StatelessWidget { final Message message; /// The message theme - final MessageTheme? messageTheme; + final MessageTheme messageTheme; /// If true the widget will be mirrored final bool reverse; @@ -144,12 +144,12 @@ class QuotedMessageWidget extends StatelessWidget { child: MessageText( message: msg, messageTheme: isOnlyEmoji && _containsText - ? messageTheme?.copyWith( - messageText: messageTheme?.messageText?.copyWith( + ? messageTheme.copyWith( + messageText: messageTheme.messageText?.copyWith( fontSize: 32, )) - : messageTheme?.copyWith( - messageText: messageTheme?.messageText?.copyWith( + : messageTheme.copyWith( + messageText: messageTheme.messageText?.copyWith( fontSize: 12, )), ), @@ -310,6 +310,6 @@ class QuotedMessageWidget extends StatelessWidget { if (_containsScrapeUrl) { return StreamChatTheme.of(context).colorTheme.blueAlice; } - return messageTheme?.messageBackgroundColor; + return messageTheme.messageBackgroundColor; } } diff --git a/packages/stream_chat_flutter/lib/src/reaction_picker.dart b/packages/stream_chat_flutter/lib/src/reaction_picker.dart index 7cd01eb7..cd358b2a 100644 --- a/packages/stream_chat_flutter/lib/src/reaction_picker.dart +++ b/packages/stream_chat_flutter/lib/src/reaction_picker.dart @@ -18,11 +18,9 @@ class ReactionPicker extends StatefulWidget { const ReactionPicker({ Key? key, required this.message, - required this.messageTheme, }) : super(key: key); final Message message; - final MessageTheme? messageTheme; @override _ReactionPickerState createState() => _ReactionPickerState(); diff --git a/packages/stream_chat_flutter/lib/src/stream_chat.dart b/packages/stream_chat_flutter/lib/src/stream_chat.dart index d3a196a1..d7e3ecea 100644 --- a/packages/stream_chat_flutter/lib/src/stream_chat.dart +++ b/packages/stream_chat_flutter/lib/src/stream_chat.dart @@ -32,7 +32,7 @@ import 'package:stream_chat_flutter_core/stream_chat_flutter_core.dart'; /// Use [StreamChat.of] to get the current [StreamChatState] instance. class StreamChat extends StatefulWidget { final StreamChatClient client; - final Widget? child; + final Widget child; final StreamChatThemeData? streamChatThemeData; /// The amount of time that will pass before disconnecting the client in the background @@ -96,7 +96,7 @@ class StreamChatState extends State { client: client, onBackgroundEventReceived: widget.onBackgroundEventReceived, backgroundKeepAlive: widget.backgroundKeepAlive, - child: widget.child!, + child: widget.child, ), ); }, 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 ec06de8a..e0e7e306 100644 --- a/packages/stream_chat_flutter/lib/src/upload_progress_indicator.dart +++ b/packages/stream_chat_flutter/lib/src/upload_progress_indicator.dart @@ -5,7 +5,7 @@ import 'stream_chat_theme.dart'; class UploadProgressIndicator extends StatelessWidget { final int uploaded; final int total; - late final Color progressIndicatorColor; + final Color progressIndicatorColor; final EdgeInsetsGeometry padding; final bool showBackground; final TextStyle? textStyle; @@ -14,7 +14,7 @@ class UploadProgressIndicator extends StatelessWidget { Key? key, required this.uploaded, required this.total, - Color? progressIndicatorColor, + this.progressIndicatorColor = const Color(0xffb2b2b2), this.padding = const EdgeInsets.only( top: 5, bottom: 5, @@ -23,9 +23,7 @@ class UploadProgressIndicator extends StatelessWidget { ), this.showBackground = true, this.textStyle, - }) : progressIndicatorColor = - progressIndicatorColor ?? const Color(0xffb2b2b2), - super(key: key); + }) : super(key: key); @override Widget build(BuildContext context) { diff --git a/packages/stream_chat_flutter/lib/src/url_attachment.dart b/packages/stream_chat_flutter/lib/src/url_attachment.dart index d9beab20..e8e7b8a8 100644 --- a/packages/stream_chat_flutter/lib/src/url_attachment.dart +++ b/packages/stream_chat_flutter/lib/src/url_attachment.dart @@ -11,16 +11,21 @@ class UrlAttachment extends StatelessWidget { UrlAttachment({ required this.urlAttachment, required this.hostDisplayName, - required this.textPadding, + this.textPadding = const EdgeInsets.symmetric( + horizontal: 16.0, + vertical: 8.0, + ), }); @override Widget build(BuildContext context) { return GestureDetector( - onTap: () => launchURL( - context, - urlAttachment.ogScrapeUrl!, - ), + onTap: () { + launchURL( + context, + urlAttachment.ogScrapeUrl, + ); + }, child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ diff --git a/packages/stream_chat_flutter/lib/src/utils.dart b/packages/stream_chat_flutter/lib/src/utils.dart index ebb2a22e..79bd210e 100644 --- a/packages/stream_chat_flutter/lib/src/utils.dart +++ b/packages/stream_chat_flutter/lib/src/utils.dart @@ -22,10 +22,10 @@ Future launchURL(BuildContext context, String? url) async { Future showConfirmationDialog( BuildContext context, { - String? title, + required String title, + required String okText, Widget? icon, String? question, - String? okText, String? cancelText, }) { return showModalBottomSheet( @@ -46,14 +46,15 @@ Future showConfirmationDialog( if (icon != null) icon, SizedBox(height: 26.0), Text( - title!, + title, style: StreamChatTheme.of(context).textTheme.headlineBold, ), SizedBox(height: 7.0), - Text( - question!, - textAlign: TextAlign.center, - ), + if (question != null) + Text( + question, + textAlign: TextAlign.center, + ), SizedBox(height: 36.0), Container( color: effect.color!.withOpacity(effect.alpha ?? 1), @@ -61,27 +62,28 @@ Future showConfirmationDialog( ), Row( children: [ - Flexible( - child: Container( - alignment: Alignment.center, - child: TextButton( - onPressed: () { - Navigator.of(context).pop(false); - }, - child: Text( - cancelText!, - style: StreamChatTheme.of(context) - .textTheme - .bodyBold - .copyWith( - color: StreamChatTheme.of(context) - .colorTheme - .black - .withOpacity(0.5)), + if (cancelText != null) + Flexible( + child: Container( + alignment: Alignment.center, + child: TextButton( + onPressed: () { + Navigator.of(context).pop(false); + }, + child: Text( + cancelText, + style: StreamChatTheme.of(context) + .textTheme + .bodyBold + .copyWith( + color: StreamChatTheme.of(context) + .colorTheme + .black + .withOpacity(0.5)), + ), ), ), ), - ), Flexible( child: Container( alignment: Alignment.center, @@ -90,7 +92,7 @@ Future showConfirmationDialog( Navigator.pop(context, true); }, child: Text( - okText!, + okText, style: StreamChatTheme.of(context) .textTheme .bodyBold @@ -112,10 +114,10 @@ Future showConfirmationDialog( Future showInfoDialog( BuildContext context, { - String? title, + required String title, + required String okText, Widget? icon, String? details, - String? okText, StreamChatThemeData? theme, }) { return showModalBottomSheet( @@ -140,14 +142,14 @@ Future showInfoDialog( height: 26.0, ), Text( - title!, + title, style: theme?.textTheme.headlineBold ?? StreamChatTheme.of(context).textTheme.headlineBold, ), SizedBox( height: 7.0, ), - Text(details!), + if (details != null) Text(details), SizedBox( height: 36.0, ), @@ -162,7 +164,7 @@ Future showInfoDialog( Navigator.of(context).pop(); }, child: Text( - okText!, + okText, style: TextStyle( color: theme?.colorTheme.black.withOpacity(0.5) ?? StreamChatTheme.of(context).colorTheme.accentBlue, 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 df8373eb..3d9d5429 100644 --- a/packages/stream_chat_flutter/lib/src/video_thumbnail_image.dart +++ b/packages/stream_chat_flutter/lib/src/video_thumbnail_image.dart @@ -9,7 +9,7 @@ import 'stream_svg_icon.dart'; import 'video_service.dart'; class VideoThumbnailImage extends StatefulWidget { - final String? video; + final String video; final double? width; final double? height; final BoxFit? fit; @@ -38,7 +38,7 @@ class _VideoThumbnailImageState extends State { @override void initState() { thumbnailFuture = VideoService.generateVideoThumbnail( - video: widget.video!, + video: widget.video, imageFormat: widget.format, ); super.initState(); @@ -48,7 +48,7 @@ class _VideoThumbnailImageState extends State { void didUpdateWidget(covariant VideoThumbnailImage oldWidget) { if (oldWidget.video != widget.video || oldWidget.format != widget.format) { thumbnailFuture = VideoService.generateVideoThumbnail( - video: widget.video!, + video: widget.video, imageFormat: widget.format, ); } 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 361d7cfc..762d4fe9 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 @@ -278,7 +278,7 @@ void main() { builder: (context, child) { return StreamChat( client: client, - child: child, + child: child!, ); }, home: StreamChannel( @@ -331,7 +331,7 @@ void main() { builder: (context, child) { return StreamChat( client: client, - child: child, + child: child!, ); }, home: StreamChannel( @@ -381,7 +381,7 @@ void main() { builder: (context, child) { return StreamChat( client: client, - child: child, + child: child!, ); }, home: StreamChannel( @@ -415,7 +415,7 @@ void main() { builder: (context, child) { return StreamChat( client: client, - child: child, + child: child!, ); }, home: Container( @@ -472,7 +472,7 @@ void main() { builder: (context, child) { return StreamChat( client: client, - child: child, + child: child!, ); }, home: Container( diff --git a/packages/stream_chat_flutter/test/src/message_action_modal_test.dart b/packages/stream_chat_flutter/test/src/message_action_modal_test.dart index 8a6e8c33..0be509ae 100644 --- a/packages/stream_chat_flutter/test/src/message_action_modal_test.dart +++ b/packages/stream_chat_flutter/test/src/message_action_modal_test.dart @@ -264,7 +264,7 @@ void main() { return StreamChat( client: client, streamChatThemeData: streamTheme, - child: child, + child: child!, ); }, theme: themeData, @@ -314,7 +314,7 @@ void main() { return StreamChat( client: client, streamChatThemeData: streamTheme, - child: child, + child: child!, ); }, theme: themeData, @@ -369,7 +369,7 @@ void main() { return StreamChat( client: client, streamChatThemeData: streamTheme, - child: child, + child: child!, ); }, theme: themeData, @@ -420,7 +420,7 @@ void main() { return StreamChat( client: client, streamChatThemeData: streamTheme, - child: child, + child: child!, ); }, theme: themeData, @@ -471,7 +471,7 @@ void main() { return StreamChat( client: client, streamChatThemeData: streamTheme, - child: child, + child: child!, ); }, theme: themeData, @@ -520,7 +520,7 @@ void main() { return StreamChat( client: client, streamChatThemeData: streamTheme, - child: child, + child: child!, ); }, theme: themeData, @@ -579,7 +579,7 @@ void main() { return StreamChat( client: client, streamChatThemeData: streamTheme, - child: child, + child: child!, ); }, theme: themeData, @@ -638,7 +638,7 @@ void main() { return StreamChat( client: client, streamChatThemeData: streamTheme, - child: child, + child: child!, ); }, theme: themeData, @@ -693,7 +693,7 @@ void main() { return StreamChat( client: client, streamChatThemeData: streamTheme, - child: child, + child: child!, ); }, theme: themeData, @@ -752,7 +752,7 @@ void main() { return StreamChat( client: client, streamChatThemeData: streamTheme, - child: child, + child: child!, ); }, theme: themeData,