Skip to content

Commit a8fcb76

Browse files
chore: less null; bump emoji_picker
1 parent 1b00383 commit a8fcb76

File tree

4 files changed

+22
-27
lines changed

4 files changed

+22
-27
lines changed

lib/src/widgets/chat_bubble_widget.dart

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -118,28 +118,18 @@ class _ChatBubbleWidgetState extends State<ChatBubbleWidget> {
118118
bool get isLastMessage =>
119119
chatController?.initialMessageList.last.id == widget.message.id;
120120

121-
bool get swipeLeftShouldShowTime =>
122-
featureActiveConfig?.enableSwipeToSeeTime ?? true;
121+
bool get swipeLeftShouldShowTime => featureActiveConfig.enableSwipeToSeeTime;
123122

124-
bool get enableSwipeToReply =>
125-
featureActiveConfig?.enableSwipeToReply ?? true;
123+
bool get enableSwipeToReply => featureActiveConfig.enableSwipeToReply;
126124

127125
ProfileCircleConfiguration? get profileCircleConfig =>
128126
widget.profileCircleConfig;
129-
FeatureActiveConfig? featureActiveConfig;
130-
ChatController? chatController;
131-
ChatUser? currentUser;
132-
int? maxDuration;
133127

134-
@override
135-
void didChangeDependencies() {
136-
super.didChangeDependencies();
137-
if (provide != null) {
138-
featureActiveConfig = provide!.featureActiveConfig;
139-
chatController = provide!.chatController;
140-
currentUser = provide!.currentUser;
141-
}
142-
}
128+
FeatureActiveConfig get featureActiveConfig =>
129+
provide?.featureActiveConfig ?? const FeatureActiveConfig();
130+
ChatController? get chatController => provide?.chatController;
131+
ChatUser? get currentUser => provide?.currentUser;
132+
int? maxDuration;
143133

144134
@override
145135
Widget build(BuildContext context) {
@@ -193,7 +183,7 @@ class _ChatBubbleWidgetState extends State<ChatBubbleWidget> {
193183
crossAxisAlignment: CrossAxisAlignment.end,
194184
children: [
195185
if (!(isMessageBySender || isMessageLastFromSender) &&
196-
(featureActiveConfig?.enableOtherUserProfileAvatar ?? true))
186+
(featureActiveConfig.enableOtherUserProfileAvatar))
197187
ProfileCircle(
198188
bottomPadding: widget.message.reaction.reactions.isNotEmpty
199189
? profileCircleConfig?.bottomPadding ?? 15
@@ -234,7 +224,7 @@ class _ChatBubbleWidgetState extends State<ChatBubbleWidget> {
234224
),
235225
if (isMessageBySender) ...[getReciept()],
236226
if (isMessageBySender &&
237-
(featureActiveConfig?.enableCurrentUserProfileAvatar ?? true))
227+
(featureActiveConfig.enableCurrentUserProfileAvatar))
238228
ProfileCircle(
239229
bottomPadding: widget.message.reaction.reactions.isNotEmpty
240230
? profileCircleConfig?.bottomPadding ?? 15
@@ -328,7 +318,7 @@ class _ChatBubbleWidgetState extends State<ChatBubbleWidget> {
328318
if (!isMessageBySameSenderAsPrevious &&
329319
(chatController?.chatUsers.length ?? 0) > 1 &&
330320
!isMessageBySender &&
331-
(featureActiveConfig?.enableOtherUserName ?? true))
321+
(featureActiveConfig.enableOtherUserName))
332322
Padding(
333323
padding:
334324
widget.chatBubbleConfig?.inComingChatBubbleConfig?.padding ??
@@ -352,9 +342,8 @@ class _ChatBubbleWidgetState extends State<ChatBubbleWidget> {
352342
MessageView(
353343
outgoingChatBubbleConfig:
354344
widget.chatBubbleConfig?.outgoingChatBubbleConfig,
355-
isLongPressEnable:
356-
(featureActiveConfig?.enableReactionPopup ?? true) ||
357-
(featureActiveConfig?.enableReplySnackBar ?? true),
345+
isLongPressEnable: (featureActiveConfig.enableReactionPopup) ||
346+
(featureActiveConfig.enableReplySnackBar),
358347
inComingChatBubbleConfig:
359348
widget.chatBubbleConfig?.inComingChatBubbleConfig,
360349
message: widget.message,
@@ -364,7 +353,7 @@ class _ChatBubbleWidgetState extends State<ChatBubbleWidget> {
364353
chatBubbleMaxWidth: widget.chatBubbleConfig?.maxWidth,
365354
longPressAnimationDuration:
366355
widget.chatBubbleConfig?.longPressAnimationDuration,
367-
onDoubleTap: featureActiveConfig?.enableDoubleTapToLike ?? false
356+
onDoubleTap: featureActiveConfig.enableDoubleTapToLike
368357
? widget.chatBubbleConfig?.onDoubleTap ??
369358
(message) => currentUser != null
370359
? chatController?.setReaction(

lib/src/widgets/chat_groupedlist_widget.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,12 @@ class _ChatGroupedListWidgetState extends State<ChatGroupedListWidget>
296296
final message = messages[newIndex];
297297
return ChatBubbleWidget(
298298
key: message.key,
299+
previousMessage: (index > 0)
300+
? snapshot.data!.elementAtOrNull(index - 1)
301+
: null,
302+
nextMessage: (index < snapshot.data!.length - 1)
303+
? snapshot.data!.elementAtOrNull(index + 1)
304+
: null,
299305
messageTimeTextStyle:
300306
chatBackgroundConfig.messageTimeTextStyle,
301307
messageTimeIconColor:

lib/src/widgets/emoji_picker_widget.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ import '../values/typedefs.dart';
3030

3131
class EmojiPickerWidget extends StatelessWidget {
3232
const EmojiPickerWidget({
33-
Key? key,
33+
super.key,
3434
required this.onSelected,
3535
this.emojiPickerSheetConfig,
36-
}) : super(key: key);
36+
});
3737

3838
/// Provides callback when user selects emoji.
3939
final StringCallback onSelected;

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ dependencies:
1717
sdk: flutter
1818
intl: ^0.19.0
1919
url_launcher: ^6.1.14
20-
emoji_picker_flutter: ^2.1.1
20+
emoji_picker_flutter: ^2.2.0
2121
any_link_preview: ^3.0.1
2222
image_picker: '>=0.8.9 <2.0.0'
2323
audio_waveforms: ^1.0.5

0 commit comments

Comments
 (0)