Flyer Chat 💬 Text Stream Message Widget
This package provides an opinionated text stream message widget for use with the flutter_chat_ui package. It's designed to display text content that arrives in chunks over time, often seen in interactions with AI assistants or other streaming data sources.
Purpose
This widget is designed specifically to render text stream messages within a flutter_chat_ui implementation. It relies on models and themes provided by flutter_chat_core and is not intended for standalone use outside the Flyer Chat ecosystem.
Installation
Add this package to your pubspec.yaml alongside flutter_chat_ui:
dependencies:
flutter_chat_ui: ^2.0.0
flyer_chat_text_stream_message: ^2.0.0
Then run flutter pub get.
Usage
import 'package:flutter_chat_ui/flutter_chat_ui.dart';
import 'package:flyer_chat_text_stream_message/flyer_chat_text_stream_message.dart';
import 'your_stream_state_manager.dart'; // Example import
Chat(
builders: Builders(
textStreamMessageBuilder: (context, message, index, {
required bool isSentByMe,
MessageGroupStatus? groupStatus,
}) {
final streamState = YourStreamStateManager.getState(message.streamId);
return FlyerChatTextStreamMessage(
message: message,
index: index,
streamState: streamState,
);
}
),
);
Note: This widget only handles the UI display. You are responsible for:
- Creating and managing the actual text stream (fetching data, handling chunks).
- Implementing a state management solution (like
YourStreamStateManagerin the example above) to track the state (Loading,Streaming,Completed,Error) for each stream ID.- Passing the correct
StreamStateto theFlyerChatTextStreamMessagewidget.- Updating your
ChatControllerto replace theTextStreamMessagewith a finalTextMessageonce the stream completes or errors.For a complete example of how to manage stream state and integrate this widget, see the
gemini.dartandgemini_stream_manager.dartfiles within the example application.
License
Licensed under the MIT License. See the LICENSE file for details.
Libraries
- flyer_chat_text_stream_message
- Flyer Chat Text Stream Message package. Provides a widget for streamed text messages.