buildListViewMultiSelectBuilder function

Widget buildListViewMultiSelectBuilder({
  1. Key? key,
  2. required BuildContext context,
  3. required List<CustomDropDownModel> listOfValues,
  4. required List<CustomDropDownModel> selectedValue,
  5. ScrollController? scrollController,
  6. bool isPaginationLoader = false,
  7. required dynamic callback(
    1. CustomDropDownModel
    ),
})

Common widget for list view builder Multi select

Implementation

Widget buildListViewMultiSelectBuilder(
    {Key? key,
    required BuildContext context,
    required List<CustomDropDownModel> listOfValues,
    required List<CustomDropDownModel> selectedValue,
    ScrollController? scrollController,
    bool isPaginationLoader = false,
    required Function(CustomDropDownModel) callback}) {
  return SizedBox(
    key: key,
    height: CommonConfigurationDropDown.of(context).dropdownHeight,
    child: ListView.builder(
      controller: scrollController,
      itemCount: listOfValues.length,
      shrinkWrap: true,
      itemBuilder: (context, index) {
        CustomDropDownModel model = listOfValues[index];
        final localContact = selectedValue.where((element) {
          return (element.id == model.id &&
              element.valueDisplay == model.valueDisplay);
        }).toList();
        return Column(
          mainAxisAlignment: MainAxisAlignment.start,
          crossAxisAlignment: CrossAxisAlignment.start,
          mainAxisSize: MainAxisSize.min,
          children: [
            buildRowItemForList(
                context: context,
                model: model,
                selectedModel:
                    localContact.isNotEmpty ? localContact.first : null,
                callback: (p0) {
                  callback(p0);
                }),
            if (isPaginationLoader && ((listOfValues.length - 1) == index))
              Material(
                  child: Center(
                      key: UniqueKey(),
                      child: const CircularProgressIndicator()))
          ],
        );
      },
    ),
  );
}