Stream Feeds client for building scalable newsfeeds and activity streams.
The main entry point for integrating Stream's Feeds API into your Dart/Flutter application that provides comprehensive tools for building activity feeds, social interactions, real-time updates, rich queries, state management, moderation, and multi-platform support.
Getting Started
Initialize the client with your API key and user information:
final client = StreamFeedsClient(
apiKey: 'your-api-key',
user: User(
id: 'user-123',
name: 'John Doe',
image: 'https://example.com/avatar.jpg',
custom: {'email': 'john@example.com'},
),
tokenProvider: TokenProvider.static(UserToken('user-jwt-token-here')),
config: FeedsConfig(
// Optional configuration
),
);
// Connect to start receiving real-time updates
await client.connect();
Logging
Pass a StreamLogConfig to say how much the client reports and where those records go. Left out, the client writes nothing:
final client = StreamFeedsClient(
apiKey: 'your-api-key',
user: user,
config: const FeedsConfig(
logConfig: StreamLogConfig(priority: StreamLogPriority.debug),
),
);
The logger is shared with every other Stream SDK in the process, so passing one decides for
those too. Every record this client writes is tagged SF:, which is what tells them apart
from another SDK's in the same log.
Some of those records carry the Authorization header, so weigh what reads them.
Different User Types
The User class supports different authentication types:
// Regular user with full details
final regularUser = User(
id: 'user-123',
name: 'John Doe',
image: 'https://example.com/avatar.jpg',
custom: {'department': 'Engineering'},
);
// Guest user (temporary access)
final guestUser = User.guest('guest-456');
// Anonymous user (no authentication required)
final anonymousUser = User.anonymous();
Token Management
The client uses a TokenProvider for flexible token management:
// Static token (for development or long-lived tokens)
final staticProvider = TokenProvider.static(UserToken('your-jwt-token'));
// Dynamic token (for refreshable tokens or secure storage)
final dynamicProvider = TokenProvider.dynamic((userId) async {
// Fetch from secure storage, an endpoint of your own, etc.
final token = await secureStorage.read(key: 'token_for_\$userId');
if (token == null) {
throw Exception('No token available');
}
return UserToken(token);
});
Features
- Activity Feeds: Create and manage activity streams with real-time updates
- Social Interactions: Comments, reactions, follows, and bookmarks
- Type-safe Queries: Advanced filtering, sorting, and pagination
- Real-time Updates: WebSocket-based live feed synchronization
- Content Moderation: Built-in moderation tools and configurations
- Multi-platform: Pure Dart implementation for all platforms
For more detailed documentation and examples, visit: https://getstream.io/docs/feeds/
- Available extensions
Constructors
-
StreamFeedsClient({required String apiKey, required User user, FeedsConfig config, TokenProvider? tokenProvider, RetryStrategy? retryStrategy, NetworkStateProvider? networkStateProvider, LifecycleStateProvider? lifecycleStateProvider, List<
AutomaticReconnectionPolicy> ? reconnectionPolicies, @visibleForTesting WebSocketProvider? wsProvider, @visibleForTesting DefaultApi? feedsRestApi}) -
Creates a new Stream Feeds client instance.
factory
Properties
- attachmentUploader → StreamAttachmentUploader
-
The attachment uploader for managing file and image uploads.
no setter
- connectionState → ConnectionStateEmitter
-
The connection state emitter for monitoring WebSocket connection status.
no setter
-
events
→ EventEmitter<
StreamEvent> -
The event emitter for listening to client events.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- moderation → ModerationClient
-
The moderation client for managing moderation-related operations.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
stateUpdateEvents
→ SharedEmitter<
StateUpdateEvent> -
The state update events emitter for testing purposes only.
no setter
- user → User
-
The user this client is authenticated as.
no setter
Methods
-
activity(
{required String activityId, required FeedId fid, ActivityData? initialData}) → Activity -
Creates an activity instance for the specified
activityIdandfid. -
activityCommentList(
ActivityCommentsQuery query) → ActivityCommentList -
Creates an activity comment list instance based on the provided
query. -
activityList(
ActivitiesQuery query) → ActivityList -
Creates an activity list instance based on the provided
query. -
activityReactionList(
ActivityReactionsQuery query) → ActivityReactionList -
Creates an activity reaction list instance based on the provided
query. -
bookmarkFolderList(
BookmarkFoldersQuery query) → BookmarkFolderList -
Creates a bookmark folder list instance based on the provided
query. -
bookmarkList(
BookmarksQuery query) → BookmarkList -
Creates a bookmark list instance based on the provided
query. -
commentList(
CommentsQuery query) → CommentList -
Creates a comment list instance based on the provided
query. -
commentReactionList(
CommentReactionsQuery query) → CommentReactionList -
Creates a comment reaction list instance based on the provided
query. -
commentReplyList(
CommentRepliesQuery query) → CommentReplyList -
Creates a comment reply list instance based on the provided
query. -
connect(
{bool connectWebSocket = true}) → Future< void> - Establishes a connection to the Stream service.
-
createCollections(
{required CreateCollectionsRequest request}) → Future< Result< CreateCollectionsResponse> > - Creates new collections in a batch operation.
-
createDevice(
{required String id, required PushNotificationsProvider pushProvider, required String pushProviderName}) → Future< Result< void> > - Creates a new device for push notifications.
-
deleteActivities(
{required List< String> ids, bool? hardDelete}) → Future<Result< DeleteActivitiesResponse> > - Deletes multiple activities.
-
deleteCollections(
{required List< String> refs}) → Future<Result< DeleteCollectionsResponse> > - Deletes collections in a batch operation.
-
deleteDevice(
{required String id}) → Future< Result< void> > - Deletes a device by its unique identifier.
-
deleteFile(
{required String url}) → Future< Result< void> > - Deletes a previously uploaded file from the CDN.
-
deleteImage(
{required String url}) → Future< Result< void> > - Deletes a previously uploaded image from the CDN.
-
disconnect(
) → Future< void> - Disconnects the current client.
-
dispose(
) → Future< void> - Releases every resource held by the client.
-
feed(
{required String group, required String id, OnNewActivity onNewActivity = defaultOnNewActivity}) → Feed -
Available on StreamFeedsClient, provided by the StreamFeedsClientHelpers extension
Creates a feed instance for the specifiedgroupandid. -
feedFromId(
FeedId fid, {OnNewActivity onNewActivity = defaultOnNewActivity}) → Feed -
Available on StreamFeedsClient, provided by the StreamFeedsClientHelpers extension
Creates a feed instance for the specifiedfid. -
feedFromQuery(
FeedQuery query, {OnNewActivity onNewActivity}) → Feed -
Creates a feed instance from the provided
query. -
feedList(
FeedsQuery query) → FeedList -
Creates a feed list instance based on the provided
query. -
followList(
FollowsQuery query) → FollowList -
Creates a follow list instance based on the provided
query. -
getApp(
) → Future< Result< AppData> > - Retrieves the application configuration and settings.
-
getOrCreateFollows(
FollowBatchRequest request) → Future< Result< BatchFollowData> > - Creates or updates multiple follow relationships in a batch operation.
-
getOrCreateUnfollows(
UnfollowBatchRequest request) → Future< Result< List< >FollowData> > - Removes multiple follow relationships in a batch operation.
-
memberList(
MembersQuery query) → MemberList -
Creates a member list instance based on the provided
query. -
moderationConfigList(
ModerationConfigsQuery query) → ModerationConfigList -
Creates a moderation configuration list instance based on the provided
query. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
pollList(
PollsQuery query) → PollList -
Creates a poll list instance based on the provided
query. -
pollVoteList(
PollVotesQuery query) → PollVoteList -
Creates a poll vote list instance based on the provided
query. -
queryDevices(
) → Future< Result< ListDevicesResponse> > - Queries all devices associated with the current user.
-
readCollections(
{required List< String> refs}) → Future<Result< ReadCollectionsResponse> > - Reads collections by their references.
-
toString(
) → String -
A string representation of this object.
inherited
-
updateCollections(
{required UpdateCollectionsRequest request}) → Future< Result< UpdateCollectionsResponse> > - Updates existing collections in a batch operation.
-
updateSystemEnvironment(
SystemEnvironment environment) → void - Updates the system environment information used by the client.
-
upsertActivities(
{required List< ActivityRequest> activities}) → Future<Result< List< >ActivityData> > - Upserts (inserts or updates) multiple activities.
-
userList(
UsersQuery query) → UserList - Creates a UserList object that represents a collection of users matching the provided query.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited