Skip to main content

Saved Post List

LMFeedSavedPostListView

LMFeedSavedPostListView is a widget designed to display a list of saved posts. It seamlessly integrates with bloc architecture to manage state, handle pagination, and display loading or error states. The widget offers several builder functions to customize how posts, loaders, and errors are displayed, providing flexibility to developers.


LMFeedSavedPostListView

The widget utilizes a PagingController to fetch and display paginated data efficiently. Developers can configure the feed screen's behavior using LMFeedScreenConfig, which controls the appearance and functionality of the saved post list.


Properties

  • config (LMFeedScreenConfig?)
    An optional configuration object that defines the behavior, styling, and features of the feed screen.

  • postBuilder (LMFeedPostWidgetBuilder?)
    A builder function to customize how individual saved posts are displayed.

  • noItemsFoundIndicatorBuilder (LMFeedContextWidgetBuilder?)
    A builder function to render a widget when no saved posts are available.

  • firstPageProgressIndicatorBuilder (LMFeedContextWidgetBuilder?)
    A builder function to display a loader when the first page of saved posts is being fetched.

  • newPageProgressIndicatorBuilder (LMFeedContextWidgetBuilder?)
    A builder function to display a loader while additional posts are being fetched during pagination.

  • noMoreItemsIndicatorBuilder (LMFeedContextWidgetBuilder?)
    A builder function to render a widget when no more saved posts are available to load.

  • newPageErrorIndicatorBuilder (LMFeedContextWidgetBuilder?)
    A builder function to display an error message when loading additional pages fails.

  • firstPageErrorIndicatorBuilder (LMFeedContextWidgetBuilder?)
    A builder function to display an error message when loading the first page fails.


LMFeedScreenConfig

The LMFeedScreenConfig class allows developers to configure the behavior and appearance of the feed screen. It provides options to enable or disable topic filtering, control overlay styles, and show or hide specific UI elements like pending post headers or notification icons.

Properties

  • feedSystemOverlayStyle (SystemUiOverlayStyle)
    Configures the system’s overlay style to change between light and dark themes based on the screen background.
    Default: SystemUiOverlayStyle.light

  • enableTopicFiltering (bool)
    Enables or disables the topic filtering feature on the feed screen.
    Default: true

  • topicSelectionWidgetType (LMFeedTopicSelectionWidgetType)
    Controls the type of topic selection widget to be displayed:

    • showTopicSelectionBottomSheet: Displays a bottom sheet for topic selection.
    • showTopicSelectionScreen: Opens a separate screen for topic selection.
      Default: showTopicSelectionScreen
  • showCustomWidget (bool)
    Determines whether to display a custom widget on the feed screen.
    Default: false

  • showPendingPostHeader (bool)
    Enables or disables the pending post header on the feed screen.
    Default: true

  • showNotificationFeedIcon (bool)
    Enables or disables the notification feed icon on the feed screen.
    Default: true

Example Usage of LMFeedScreenConfig

final LMFeedScreenConfig config = LMFeedScreenConfig(
feedSystemOverlayStyle: SystemUiOverlayStyle.dark,
enableTopicFiltering: true,
topicSelectionWidgetType: LMFeedTopicSelectionWidgetType.showTopicSelectionBottomSheet,
showCustomWidget: true,
showPendingPostHeader: false,
showNotificationFeedIcon: true,
);

copyWith (LMFeedSavedPostListView)

The copyWith method allows creating a new instance of LMFeedSavedPostListView with selected properties overridden, while keeping the original values for the rest.

Usage

LMFeedSavedPostListView copyWith({
LMFeedScreenConfig? config,
LMFeedPostWidgetBuilder? postBuilder,
LMFeedContextWidgetBuilder? noItemsFoundIndicatorBuilder,
LMFeedContextWidgetBuilder? firstPageProgressIndicatorBuilder,
LMFeedContextWidgetBuilder? newPageProgressIndicatorBuilder,
LMFeedContextWidgetBuilder? noMoreItemsIndicatorBuilder,
LMFeedContextWidgetBuilder? newPageErrorIndicatorBuilder,
LMFeedContextWidgetBuilder? firstPageErrorIndicatorBuilder,
});

Example Usage

Below is an example demonstrating how to use LMFeedSavedPostListView with a custom configuration and post builder.

Code Example

LMFeedSavedPostListView(
config: LMFeedScreenConfig(
feedSystemOverlayStyle: SystemUiOverlayStyle.light,
enableTopicFiltering: true,
showPendingPostHeader: false,
),
postBuilder: (context, postWidget, post) {
return Padding(
padding: const EdgeInsets.all(8.0),
child: Card(
elevation: 4,
child: postWidget, // Custom styling inside a Card.
),
);
},
noItemsFoundIndicatorBuilder: (context) => Center(
child: Text("No saved posts available."),
),
firstPageProgressIndicatorBuilder: (context) => Center(
child: CircularProgressIndicator(),
),
newPageErrorIndicatorBuilder: (context) => Center(
child: Text("Failed to load more posts."),
),
);

In this example:

  • A custom post builder wraps each post inside a Card with padding.
  • The configuration disables the pending post header and uses a light system overlay style.
  • Error handling and progress indicators are implemented using builder functions.

This setup demonstrates how to efficiently use LMFeedSavedPostListView and its configuration to enhance the functionality and appearance of saved posts in your Flutter application.