Migration Guide: Feed Flutter SDK (v1.12.1 to v1.13.0)
This guide provides an overview of the key changes in v1.13.0 of the LikeMinds Feed Flutter SDK and instructions for updating your project from v1.12.1.
Key Updates in v1.13.0
LMFeedWidgetUtility
replaced byLMFeedWidgetBuilderDelegate
:- Common widget builders are now handled by
LMFeedWidgetBuilderDelegate
.
- Common widget builders are now handled by
Screen-Level Builder Delegates Introduced:
- Builders for screen-specific elements (e.g.,
floatingActionButtonBuilder
) are now moved to screen-level delegates such asLMFeedSocialScreenBuilderDelegate
.
- Builders for screen-specific elements (e.g.,
Screen-level Config Introduced:
- It consist the specific screen level builder delegate. e.g,
LMFeedSocialScreenConfig
forLMFeedSocialScreenBuilderDelegate
- It consist the specific screen level builder delegate. e.g,
Migration Steps
Step 1: Upgrade the LikeMinds Feed Flutter SDK to v1.13.0 in pubspec.yaml
likeminds_feed_flutter_core: ^1.13.0
Step 2: Update Common Widget Builders
Replace LMFeedWidgetUtility
with LMFeedWidgetBuilderDelegate
for common widget customization.
Before v1.13.0:
class ExampleWidgetUtility extends LMFeedWidgetUtility {
Widget postWidgetBuilder(
BuildContext context, LMFeedPostWidget post, LMPostViewData postViewData,
{LMFeedWidgetSource source = LMFeedWidgetSource.universalFeed}) {
return post.copyWith(
style: post.style?.copyWith(backgroundColor: Colors.red),
);
}
}
After v1.13.0:
class ExampleBuilderDelegate extends LMFeedWidgetBuilderDelegate {
Widget postWidgetBuilder(
BuildContext context, LMFeedPostWidget post, LMPostViewData postViewData,
{LMFeedWidgetSource source = LMFeedWidgetSource.universalFeed}) {
return post.copyWith(
style: post.style?.copyWith(backgroundColor: Colors.red),
);
}
}
Step 3: Implement Screen-Level Builders
For screen-specific customizations, such as the floating action button, extend the relevant screen-level delegate (e.g., LMFeedSocialScreenBuilderDelegate
).
Example:
class ExampleLMFeedScreenBuilderDelegate extends LMFeedSocialScreenBuilderDelegate {
Widget floatingActionButtonBuilder(
BuildContext context, LMFeedButton floatingActionButton) {
return floatingActionButton.copyWith();
}
}
Step 4: Update SDK Initialization
Pass the widget builder and screen-level builder in the LMFeedConfig
during SDK initialization.
Before v1.13.0:
LMFeedCore.instance.initialize(
widget: ExampleWidgetUtility(),
);
After v1.13.0:
LMFeedCore.instance.initialize(
config: LMFeedConfig(
widgetBuilderDelegate: ExampleBuilderDelegate(),
socialFeedScreenConfig: LMFeedSocialScreenConfig(
builder: ExampleLMFeedScreenBuilderDelegate(),
),
),
);
Summary of Changes
v1.12.1 | v1.13.0 |
---|---|
LMFeedWidgetUtility for all customizations. | LMFeedWidgetBuilderDelegate for common widgets. |
floatingActionButtonBuilder in WidgetUtility . | Moved to LMFeedSocialScreenBuilderDelegate . |
Single initialization using widget . | Modular initialization with LMFeedWidgetBuilderDelegate and LMFeedConfig . |
Key Methods Comparison
LMFeedWidgetUtility (v1.12.1) | LMFeedWidgetBuilderDelegate (v1.13.0) | Notes |
---|---|---|
scaffold | scaffold | No change. |
postWidgetBuilder | postWidgetBuilder | No change. |
commentBuilder | commentBuilder | No change. |
headerBuilder | postHeaderBuilder | Minor name change (headerBuilder → postHeaderBuilder ). |
menuBuilder | postMenuBuilder | Minor name change (menuBuilder → postMenuBuilder ). |
topicBuilder | topicBuilder | No change. |
postContentBuilder | postContentBuilder | No change. |
postMediaBuilder | postMediaBuilder | No change. |
postFooterBuilder | postFooterBuilder | No change. |
pollWidgetBuilder | pollWidgetBuilder | No change. |
noItemsFoundIndicatorBuilderFeed | noItemsFoundIndicatorBuilder | Name shortened; now allows passing Widget? child . |
noPostUnderTopicFeed | noPostUnderTopicFeed | No change. |
firstPageProgressIndicatorBuilderFeed | firstPageProgressIndicatorBuilder | Name shortened; now allows passing Widget? child . |
newPageProgressIndicatorBuilderFeed | newPageProgressIndicatorBuilder | Name shortened; now allows passing Widget? child . |
firstPageErrorIndicatorBuilderFeed | firstPageErrorIndicatorBuilder | Name shortened; now allows passing Widget? child . |
newPageErrorIndicatorBuilderFeed | newPageErrorIndicatorBuilder | Name shortened; now allows passing Widget? child . |
noMoreItemsIndicatorBuilderFeed | noMoreItemsIndicatorBuilder | Name shortened; now allows passing Widget? child . |
snackBarBuilder | snackBarBuilder | No change. |
imageBuilder | imageBuilder | No change. |
videoBuilder | videoBuilder | No change. |
topicBarBuilder | topicBarBuilder | No change. |
topResponseBuilder | topResponseBuilder | No change. |
addACommentBuilder | addACommentBuilder | No change. |
Benefits of v1.13.0
- Modularity: Screen-specific builders make customization more organized and targeted.
- Flexibility: Pass separate builders for widgets and screens, allowing granular control over UI components.
By following these steps, you can migrate seamlessly to v1.13.0 and take advantage of the new modular and flexible customization options.