Skip to main content

Poll Result Screen

Introduction​

The Poll Result Screen (LMFeedPollResultScreen) displays the results of a poll, including the options, votes, and analysis. It provides customization points for the appearance and behavior of result visualization.


1. LMFeedPollResultScreen Widget​

File Location:
poll_result_screen.dart

Class Declaration​

class LMFeedPollResultScreen extends StatefulWidget {
/// A screen widget that displays poll results.
const LMFeedPollResultScreen({
super.key,
required this.pollId,
required this.pollOptions,
this.pollTitle,
this.selectedOptionId,
this.noItemsFoundIndicatorBuilder,
this.firstPageProgressIndicatorBuilder,
this.newPageProgressIndicatorBuilder,
this.noMoreItemsIndicatorBuilder,
this.newPageErrorIndicatorBuilder,
this.firstPageErrorIndicatorBuilder,
this.tabWidth,
});


State<LMFeedPollResultScreen> createState() => _LMFeedPollResultScreenState();
}

Key Parameters​

  1. key (Key?, optional): A key to uniquely identify the widget.
  2. pollId (String, required): The ID of the poll to be displayed.
  3. pollTitle (String?, optional): The title of the poll.
  4. pollOptions (List<LMPollOptionViewData>, required): The options available in the poll.
  5. selectedOptionId (String?, optional): The ID of the selected option.

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


2. LMFeedPollResultBuilderDelegate​

File Location:
builder.dart

Class Declaration​

class LMFeedPollResultBuilderDelegate extends LMFeedWidgetBuilderDelegate {
const LMFeedPollResultBuilderDelegate();
}

The LMFeedPollResultBuilderDelegate allows developers to customize the appearance of poll results, including chart styles, vote counts, and other visual elements.

3. LMFeedPollResultSetting​

File Location:
settings.dart

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

4. LMFeedPollResultStyle​

File Location:
style.dart

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

5. LMFeedPollResultConfig​

File Location:
config.dart

Class Declaration​

class LMFeedPollResultConfig {
final LMFeedPollResultBuilderDelegate builder;
final LMFeedPollResultSetting setting;
final LMFeedPollResultStyle style;

const LMFeedPollResultConfig({
this.builder = const LMFeedPollResultBuilderDelegate(),
this.setting = const LMFeedPollResultSetting(),
this.style = const LMFeedPollResultStyle(),
});
}

Usage Example: Injecting Custom Configuration​

  1. Create a Custom Builder:

    class CustomPollResultBuilder extends LMFeedPollResultBuilderDelegate {

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

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

    final pollResultConfig = LMFeedPollResultConfig(
    builder: CustomPollResultBuilder(),
    setting: customSetting,
    style: customStyle,
    );
  4. Initialize with Custom Config:

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

6. Summary​

The Poll Result Screen provides a user interface for displaying poll results. Developers can customize components like charts, vote counts, and summaries using the LMFeedPollResultBuilderDelegate. Configuration options are encapsulated in LMFeedPollResultConfig, allowing seamless integration of customizations tailored to specific design and functional requirements.