Skip to main content

Create Poll Screen

Introduction

The Create Poll Screen (LMFeedCreatePollScreen) serves as the interface for creating polls. It provides customization options through builders, settings, and styles to meet specific design and functional requirements.


1. LMFeedCreatePollScreen Widget

File Location:
create_poll_screen.dart

Class Declaration

class LMFeedCreatePollScreen extends StatefulWidget {
/// A screen widget that facilitates the creation of a new poll.
const LMFeedCreatePollScreen({
super.key,
this.attachmentMeta,
this.appBarBuilder,
this.pollQuestionStyle,
this.optionStyle,
this.advancedButtonBuilder,
this.postButtonBuilder,
this.addOptionButtonBuilder,
});


State<LMFeedCreatePollScreen> createState() => _LMFeedCreatePollScreenState();
}

Key Parameters

  1. key (Key?, optional): A key to uniquely identify the widget.
  2. attachmentMeta (LMAttachmentMetaViewData?, optional): Metadata to prefill the poll data.
  3. appBarBuilder (LMFeedAppBarBuilder?, optional): Custom builder for the app bar.
  4. pollQuestionStyle (LMFeedTextFieldStyle?, optional): Style for the poll question.
  5. optionStyle (LMFeedTextFieldStyle?, optional): Style for the poll options.

For the complete source code, refer to the GitHub link.


2. LMFeedPollBuilderDelegate

File Location:
builder.dart

Class Declaration

class LMFeedPollBuilderDelegate extends LMFeedWidgetBuilderDelegate {
const LMFeedPollBuilderDelegate();
}

The LMFeedPollBuilderDelegate allows developers to customize various aspects of the poll screen, such as dialogs, input fields, and poll options.

Methods in LMFeedPollBuilderDelegate

  1. pollWidgetBuilder
    Definition: Builds the widget for poll UI.
    Purpose: Customizes the appearance and behavior of poll UI.

    Usage Example:


    Widget pollWidgetBuilder(BuildContext context, LMFeedPoll pollWidget) {
    return pollWidget.copyWith();
    }

Remaining Methods

Explore the complete list of methods here.


3. LMFeedPollSetting

File Location:
settings.dart

class LMFeedPollSetting {
const LMFeedPollSetting();
}
  • Purpose: Provides configuration settings for the Create Poll Screen. No additional fields or methods are currently defined.

4. LMFeedPollStyle

File Location:
style.dart

class LMFeedPollStyle {
const LMFeedPollStyle();
}
  • Purpose: Defines styling options for the Create Poll Screen. No fields or methods are currently defined.

5. LMFeedPollConfig

File Location:
config.dart

Class Declaration

class LMFeedPollConfig {
final LMFeedPollBuilderDelegate builder;
final LMFeedPollSetting setting;
final LMFeedPollStyle style;

const LMFeedPollConfig({
this.builder = const LMFeedPollBuilderDelegate(),
this.setting = const LMFeedPollSetting(),
this.style = const LMFeedPollStyle(),
});
}

Usage Example: Injecting Custom Configuration

  1. Create a Custom Builder:

    class CustomPollBuilder extends LMFeedPollBuilderDelegate {

    Widget pollWidgetBuilder(BuildContext context, LMFeedPoll pollWidget) {
    return pollWidget.copyWith();
    }
    }
  2. Pass Custom Style or Setting along with Builder:

    final customStyle = LMFeedPollStyle();
    final customSetting = LMFeedPollSetting();
  3. Inject the Custom Builder, Style, or Setting into the Config:

    final pollConfig = LMFeedPollConfig(
    builder: CustomPollBuilder(),
    setting: customSetting,
    style: customStyle,
    );
  4. Initialize with Custom Config:

    LMFeedCore.instance.initialize(
    config: LMFeedConfig(
    pollConfig: pollConfig,
    ),
    );

6. Summary

The Create Poll Screen provides a user interface for creating polls. Developers can customize components like poll options, dialogs, and submit buttons using the LMFeedPollBuilderDelegate. Configuration options are encapsulated in LMFeedPollConfig, allowing seamless integration of customizations tailored to specific design and functional requirements.