Skip to content

Commit c92d7e2

Browse files
authored
fix: add onLinkTap for StreamMessages (#831)
1 parent a404412 commit c92d7e2

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

packages/flyer_chat_text_message/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ dependencies:
1313
flutter:
1414
sdk: flutter
1515
flutter_chat_core: ^2.6.2
16-
gpt_markdown: ^1.1.0
16+
gpt_markdown: ^1.1.1
1717
provider: ^6.1.5
1818

1919
dev_dependencies:

packages/flyer_chat_text_stream_message/lib/src/flyer_chat_text_stream_message.dart

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ class FlyerChatTextStreamMessage extends StatefulWidget {
8888
/// The rendering mode for the text content.
8989
final TextStreamMessageMode mode;
9090

91+
/// The callback function to handle link clicks.
92+
final void Function(String url, String title)? onLinkTap;
93+
9194
/// Creates a widget to display a streaming text message.
9295
const FlyerChatTextStreamMessage({
9396
super.key,
@@ -106,6 +109,7 @@ class FlyerChatTextStreamMessage extends StatefulWidget {
106109
this.timeAndStatusPosition = TimeAndStatusPosition.end,
107110
this.chunkAnimationDuration = const Duration(milliseconds: 350),
108111
this.mode = TextStreamMessageMode.animatedOpacity,
112+
this.onLinkTap,
109113
});
110114

111115
@override
@@ -339,7 +343,11 @@ class _FlyerChatTextStreamMessageState extends State<FlyerChatTextStreamMessage>
339343

340344
if (widget.streamState is StreamStateCompleted) {
341345
final state = widget.streamState as StreamStateCompleted;
342-
return GptMarkdown(state.finalText, style: paragraphStyle);
346+
return GptMarkdown(
347+
state.finalText,
348+
style: paragraphStyle,
349+
onLinkTap: widget.onLinkTap,
350+
);
343351
}
344352

345353
// Build RichText from segments for Streaming state

packages/flyer_chat_text_stream_message/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ dependencies:
1313
flutter:
1414
sdk: flutter
1515
flutter_chat_core: ^2.6.2
16-
gpt_markdown: ^1.1.0
16+
gpt_markdown: ^1.1.1
1717
provider: ^6.1.5
1818

1919
dev_dependencies:

0 commit comments

Comments
 (0)