display<T> static method

Future display<T>(
  1. dynamic context, {
  2. required List<T> listData,
  3. List<T>? selectedListData,
  4. required LabelDelegate<T> choiceChipLabel,
  5. required ValidateSelectedItem<T> validateSelectedItem,
  6. required ItemSearchDelegate<T> onItemSearch,
  7. required OnApplyButtonClick<T> onApplyButtonClick,
  8. double? height,
  9. double? width,
  10. double borderRadius = 20,
  11. String headlineText = "Select",
  12. String searchFieldHintText = "Search here",
  13. bool hideSelectedTextCount = false,
  14. bool hideSearchField = false,
  15. bool hideCloseIcon = false,
  16. bool hideheader = false,
  17. bool hideHeaderText = false,
  18. Color closeIconColor = Colors.black,
  19. bool barrierDismissible = true,
  20. bool useSafeArea = true,
  21. bool useRootNavigator = true,
  22. RouteSettings? routeSettings,
  23. bool enableOnlySingleSelection = false,
  24. Color backgroundColor = Colors.white,
  25. Color searchFieldBackgroundColor = const Color(0xfff5f5f5),
  26. Color applyButonTextBackgroundColor = Colors.blue,
  27. TextStyle? selectedChipTextStyle,
  28. TextStyle? unselectedChipTextStyle,
  29. TextStyle? controlButtonTextStyle,
  30. TextStyle? applyButtonTextStyle,
  31. TextStyle? headerTextStyle,
  32. TextStyle? searchFieldTextStyle,
  33. ChoiceChipBuilder? choiceChipBuilder,
})

Implementation

static Future display<T>(context,
    {

    /// Pass list containing all data which neeeds to filter.
    required List<T> listData,

    /// pass selected list of object
    /// every object on selecteListData should be present in list data.
    List<T>? selectedListData,

    /// Display text on choice chip.
    required LabelDelegate<T> choiceChipLabel,

    /// identifies weather a item is selecte or not.
    required ValidateSelectedItem<T> validateSelectedItem,

    /// filter list on the basis of search field text.
    /// When text change in search text field then return list containing that text value.
    ///
    ///Check if list has value which matches to text.
    required ItemSearchDelegate<T> onItemSearch,

    /// Return list of all selected items
    required OnApplyButtonClick<T> onApplyButtonClick,

    /// Height of the dialog
    double? height,

    /// Width of the dialog
    double? width,

    /// Border radius of dialog.
    double borderRadius = 20,

    /// Headline text to be display as header of dialog.
    String headlineText = "Select",

    /// Hint text for search field.
    String searchFieldHintText = "Search here",

    /// Used to hide selected text count.
    bool hideSelectedTextCount = false,

    /// Used to hide search field.
    bool hideSearchField = false,

    /// Used to hide close icon.
    bool hideCloseIcon = false,

    /// Used to hide header.
    bool hideheader = false,

    /// Used to hide header text.
    bool hideHeaderText = false,

    ///Color of close icon
    Color closeIconColor = Colors.black,

    /// The `barrierDismissible` argument is used to indicate whether tapping on the barrier will dismiss the dialog.
    ///
    ///  It is true by default and can not be null.
    bool barrierDismissible = true,
    bool useSafeArea = true,
    bool useRootNavigator = true,
    RouteSettings? routeSettings,

    /// if `enableOnlySingleSelection` is true then it disabled the multiple selection.
    /// and enabled the single selection model.
    ///
    /// Defautl value is [false]
    bool enableOnlySingleSelection = false,

    /// Background color of dialog box.
    Color backgroundColor = Colors.white,

    /// Background color for search field.
    Color searchFieldBackgroundColor = const Color(0xfff5f5f5),

    /// Background color for Apply button.
    Color applyButonTextBackgroundColor = Colors.blue,

    /// TextStyle for chip when selected.
    TextStyle? selectedChipTextStyle,

    /// TextStyle for chip when not selected.
    TextStyle? unselectedChipTextStyle,

    /// TextStyle for [All] and [Reset] button text.
    TextStyle? controlButtonTextStyle,

    /// TextStyle for [Apply] button.
    TextStyle? applyButtonTextStyle,

    /// TextStyle for header text.
    TextStyle? headerTextStyle,

    /// TextStyle for search field text.
    TextStyle? searchFieldTextStyle,

    /// The `choiceChipBuilder` is a builder to design custom choice chip.
    ChoiceChipBuilder? choiceChipBuilder}) async {
  if (height == null) {
    height = MediaQuery.of(context).size.height * .8;
  }
  if (width == null) {
    width = MediaQuery.of(context).size.width;
  }
  await showDialog(
    context: context,
    barrierDismissible: barrierDismissible,
    routeSettings: routeSettings,
    useRootNavigator: useRootNavigator,
    useSafeArea: useSafeArea,
    builder: (BuildContext context) {
      return Dialog(
        elevation: 0,
        backgroundColor: Colors.transparent,
        child: Container(
          height: height,
          width: width,
          color: Colors.transparent,
          child: FilterListWidget(
            listData: listData,
            choiceChipLabel: choiceChipLabel,
            width: width,
            height: height,
            hideHeader: hideheader,
            borderRadius: borderRadius,
            headlineText: headlineText,
            onItemSearch: onItemSearch,
            closeIconColor: closeIconColor,
            headerTextStyle: headerTextStyle,
            backgroundColor: backgroundColor,
            selectedListData: selectedListData,
            onApplyButtonClick: onApplyButtonClick,
            validateSelectedItem: validateSelectedItem,
            hideSelectedTextCount: hideSelectedTextCount,
            hideCloseIcon: hideCloseIcon,
            hideHeaderText: hideHeaderText,
            hideSearchField: hideSearchField,
            choiceChipBuilder: choiceChipBuilder,
            searchFieldHintText: searchFieldHintText,
            applyButtonTextStyle: applyButtonTextStyle,
            searchFieldTextStyle: searchFieldTextStyle,
            selectedChipTextStyle: selectedChipTextStyle,
            controlButtonTextStyle: controlButtonTextStyle,
            unselectedChipTextStyle: unselectedChipTextStyle,
            enableOnlySingleSelection: enableOnlySingleSelection,
            searchFieldBackgroundColor: searchFieldBackgroundColor,
            applyButonTextBackgroundColor: applyButonTextBackgroundColor,
          ),
        ),
      );
    },
  );
}