multiSelect static method

dynamic multiSelect({
  1. required BuildContext context,
  2. required ValueChanged<bool> onSelectAll,
  3. required List<Widget> children,
  4. bool? show,
  5. VoidCallback? onClose,
  6. bool? allSelected,
  7. bool showAllSelect = true,
  8. int? totalCount,
  9. int? selectedCount,
})

多选

Implementation

static multiSelect({
  required BuildContext context,
  required ValueChanged<bool> onSelectAll,
  required List<Widget> children,
  bool? show,
  VoidCallback? onClose,
  bool? allSelected,
  bool showAllSelect = true,
  int? totalCount,
  int? selectedCount,
}) {
  bool isAllSelected = allSelected ?? (totalCount != null && selectedCount != null && selectedCount == totalCount);
  bool isShow = show ?? (totalCount != null && selectedCount != null && selectedCount > 0);
  return CustomBottomFloatBar(
    show: isShow,
    child: Wrap(
      children: [
        CustomTextButton(
          onPressed: onClose ?? () => onSelectAll(false),
          color: Theme.of(context).colorScheme.outline,
          child: Text('cancel'.tr()),
        ),
        if (showAllSelect)
          CustomTextButton(
            onPressed: () => onSelectAll(!isAllSelected),
            child: AnimatedSize(
              duration: const Duration(milliseconds: 200),
              child: Text(isAllSelected ? 'deselectAll'.tr() : 'selectAll'.tr()),
            ),
          ),
        ...children,
      ],
    ),
  );
}