Edit Post Screen
Introduction
The Edit Post Screen (LMFeedEditPostScreen
) provides an interface for editing existing posts. It reuses the configurations from the Compose Screen, allowing developers to customize fields, styles, and behaviors using LMFeedComposeScreenConfig
.
1. LMFeedEditPostScreen Widget
File Location:
edit_post_screen.dart
Class Declaration
class LMFeedEditPostScreen extends StatefulWidget {
/// A screen widget that facilitates editing an existing post.
const LMFeedEditPostScreen({
super.key,
// Widget builder functions for customizations
this.composeDiscardDialogBuilder,
this.composeAppBarBuilder,
this.composeContentBuilder,
this.composeTopicSelectorBuilder,
this.composeMediaPreviewBuilder,
this.composeUserHeaderBuilder,
// Config for the screen
this.config,
// Style for the screen
this.style,
// Post data to be edited
this.postId,
this.pendingPostId,
this.displayName,
this.displayUrl,
}) : assert(pendingPostId != null || postId != null);
State<LMFeedEditPostScreen> createState() => _LMFeedEditPostScreenState();
}
Key Parameters
key
(Key?
, optional): A key to uniquely identify the widget.composeDiscardDialogBuilder
(Function(BuildContext context)?
, optional): Custom builder for the discard dialog.composeAppBarBuilder
(PreferredSizeWidget Function(LMFeedAppBar oldAppBar)?
, optional): Custom builder for the app bar.composeContentBuilder
(Widget Function()?
, optional): Custom builder for the content.composeTopicSelectorBuilder
(Widget Function(BuildContext context, Widget topicSelector, List<LMTopicViewData>)?
, optional): Custom builder for the topic selector.
For the complete source code, refer to the GitHub link.
2. Reusing LMFeedComposeScreenConfig
LMFeedEditPostScreen
reuses LMFeedComposeScreenConfig
for all the customization
The Edit Post Screen relies on the following components from LMFeedComposeScreenConfig
:
LMFeedComposeBuilderDelegate
Allows developers to customize input fields, submit buttons, and discard dialogs.Example:
class CustomComposeBuilder extends LMFeedComposeBuilderDelegate {
Widget submitButtonBuilder(BuildContext context) {
return ElevatedButton(
onPressed: () => saveEditedPost(),
child: Text('Save Changes'),
);
}
}LMFeedComposeSetting
Provides configuration settings for input validation and other behaviors.LMFeedComposeStyle
Defines styling options, such as input field colors and button appearances.LMFeedComposeConfig
Aggregates the builder, setting, and style components into a single configuration object.
3. Summary
The Edit Post Screen provides a user interface for modifying existing posts. It reuses the configurations from LMFeedComposeScreenConfig
, allowing developers to leverage existing customization options for input fields, dialogs, buttons, and styles.