Skip to content

Commit

Permalink
Add message width ratio (#548)
Browse files Browse the repository at this point in the history
* Add paramter  of message width ratio

* Update chat.dart

* Update chat.dart
  • Loading branch information
elihaialgoaitech authored Feb 4, 2024
1 parent a63d386 commit 78d18c3
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/src/widgets/chat.dart
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ class Chat extends StatefulWidget {
this.videoMessageBuilder,
this.slidableMessageBuilder,
this.isLeftStatus = false,
this.messageWidthRatio = 0.72,
});

/// See [Message.audioMessageBuilder].
Expand Down Expand Up @@ -333,6 +334,9 @@ class Chat extends StatefulWidget {
/// If false, status will be shown on the right side of the message.
/// Default value is false.
final bool isLeftStatus;

/// Width ratio for message bubble.
final double messageWidthRatio;

@override
State<Chat> createState() => ChatState();
Expand Down Expand Up @@ -469,8 +473,8 @@ class ChatState extends State<Chat> {
final maxWidth = widget.theme.messageMaxWidth;
final messageWidth =
widget.showUserAvatars && message.author.id != widget.user.id
? min(constraints.maxWidth * 0.72, maxWidth).floor()
: min(constraints.maxWidth * 0.78, maxWidth).floor();
? min(constraints.maxWidth * widget.messageWidthRatio, maxWidth).floor()
: min(constraints.maxWidth * (widget.messageWidthRatio + 0.06), maxWidth).floor();
final Widget msgWidget = Message(
audioMessageBuilder: widget.audioMessageBuilder,
avatarBuilder: widget.avatarBuilder,
Expand Down

0 comments on commit 78d18c3

Please sign in to comment.