to property

  1. @JsonKey(includeIfNull: false, fromJson: FeedId.fromIds, toJson: FeedId.toIds)
List<FeedId>? to
final

The recipients of the action.

The TO field allows you to specify a list of feeds to which the activity should be copied.

One way to think about it is as the CC functionality of email.

Use Cases

  • Mentions

    Targeting is useful when you want to support @mentions and notify users. An example is shown below:
 // Add the activity to Eric's feed and to Jessica's notification feed
final activity = Activity(
	actor: 'user:Eric',
	message: "@Jessica check out getstream.io it's awesome!",
	verb: 'tweet',
	object: 'tweet:id',
	to: [FeedId.id('notification:Jessica')],
);
final response = await user_feed_1.addActivity(activity)
  • Organizations & Topics

    Another everyday use case is for teams, organizations or topics.

For example, one of our customers runs a football community.

Updates about a player should also be added to their team's feed.

Stream supports this by adding the activity to the player's feed, and specifying the target feeds in the TO field:

// The TO field ensures the activity is sent to the player, match and team feed
final activity = Activity(
	actor: 'Player:Suarez',
	verb: 'foul',
	object: 'Player:Ramos',
	extraData: {"match": { "name": 'El Clasico', "id": 10 },}
	to: ['team:barcelona', 'match:1'],
);
const response = await playerFeed1.addActivity(activity);

Implementation

@JsonKey(
  includeIfNull: false,
  fromJson: FeedId.fromIds,
  toJson: FeedId.toIds,
)
final List<FeedId>? to;