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) {
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
YourStreamStateManager
in the example above) to track the state (Loading
,Streaming
,Completed
,Error
) for each stream ID.- Passing the correct
StreamState
to theFlyerChatTextStreamMessage
widget.- Updating your
ChatController
to replace theTextStreamMessage
with a finalTextMessage
once the stream completes or errors.For a complete example of how to manage stream state and integrate this widget, see the
gemini.dart
andgemini_stream_manager.dart
files 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.