Skip to main content

mebabl_social 1.1.0 copy "mebabl_social: ^1.1.0" to clipboard
mebabl_social: ^1.1.0 copied to clipboard

Typed Flutter SDK for Mebabl Platform social interactions.

mebabl_social #

Typed Flutter SDK for the Mebabl Platform Social API. The package reuses an initialized MebablCore instance for the configured API base URL, application authentication, token handling, and HTTP transport.

Requirements #

  • Dart SDK >=3.8.0 <4.0.0
  • Flutter
  • mebabl_core: ^1.0.9
  • An authenticated application-user session. Social routes are protected by the ApplicationUser authorization policy.

Installation #

Add the package to your app:

dependencies:
  mebabl_core: ^1.2.0
  mebabl_social: ^1.1.0

Run:

flutter pub get

Initialization #

Initialize MebablCore using the configuration and initialization flow already used by your application. Then pass that initialized instance to the Social service:

// `core` is the initialized MebablCore instance used by your app.
final social = MebablSocialService(core: core);

Features currently exposed by the backend #

Feature SDK method API route
Add or change reaction react POST /api/sdk/social/posts/{postId}/reactions
Remove own reaction removeReaction DELETE /api/sdk/social/posts/{postId}/reactions
List reactions getReactions GET /api/sdk/social/posts/{postId}/reactions
Create comment createComment POST /api/sdk/social/posts/{postId}/comments
List comments getComments GET /api/sdk/social/posts/{postId}/comments
Update comment updateComment PUT /api/sdk/social/comments/{commentId}*
Delete comment deleteComment DELETE /api/sdk/social/comments/{commentId}
Record share event share POST /api/sdk/social/posts/{postId}/shares
Repost repost POST /api/sdk/social/posts/{postId}/reposts
Read aggregated post stats getPostStats GET /api/sdk/social/posts/stats?postIds={id1},{id2}

* The current API controller exposes the update-comment action as PATCH. The MebablCore HTTP client used by this SDK provides PUT, so apply the small backward-compatible server change in backend-compat/README.md to accept PUT as well as PATCH.

Usage #

Likes and reactions #

final reaction = await social.react(
  postId,
  type: SocialReactionType.like,
);

await social.removeReaction(postId);

final reactions = await social.getReactions(postId);

SocialReactionType.like sends the exact value Like, which is the value currently counted by the backend's likes aggregate. Other reaction values are supported by the API, but are not included in that likes counter unless the backend's aggregation logic is changed.

Comments #

final comment = await social.createComment(
  postId,
  text: 'Great post!',
);

final comments = await social.getComments(
  postId,
  page: 1,
  pageSize: 20,
);

final updated = await social.updateComment(
  comment.id,
  text: 'Updated comment',
);

await social.deleteComment(comment.id);

Page must be positive and page size must be between 1 and 100. Comment text must contain between 1 and 5,000 characters after trimming.

The response model includes parentCommentId, but the current create-comment request and command accept only postId and text. Creating nested replies is therefore not available through this backend contract yet.

Shares and reposts #

final shareEvent = await social.share(postId);
final repost = await social.repost(postId);

share records a share event for analytics. It does not deliver the post to a chat conversation and does not invoke Android/iOS share UI. Sending a post through Babilo Chat requires a separate chat-message endpoint that accepts a post reference. The current controller does not expose that operation.

The current backend also does not expose a remove-repost endpoint, so this SDK intentionally does not provide removeRepost.

Aggregated post statistics #

final stats = await social.getPostStats([
  firstPostId,
  secondPostId,
]);

for (final item in stats) {
  print(item.likes);
  print(item.comments);
  print(item.shares);
  print(item.reposts);
  print(item.liked); // State for the authenticated user.
  print(item.reposted); // State for the authenticated user.
}

The API accepts between 1 and 100 unique post IDs per request. The service removes duplicate IDs before sending the comma-separated postIds query parameter.

Error handling #

HTTP and authentication errors are propagated by MebablCore. SDK-side argument validation throws ArgumentError; malformed or unexpected response payloads throw FormatException.

Handle these errors in the app's repository or state-management layer. Do not treat a successful local tap as a successful server mutation until the returned Future completes.

Scope and responsibilities #

This package contains client models and calls for the Social API only. It does not create posts, upload media, send chat messages, deliver notifications, or implement a feed ranking algorithm. Those responsibilities belong to their respective Mebabl SDK modules and backend APIs.

0
likes
0
points
80
downloads

Publisher

unverified uploader

Weekly Downloads

Typed Flutter SDK for Mebabl Platform social interactions.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

mebabl_core

More

Packages that depend on mebabl_social