void onSelectAllChange(bool? value) { setState(() { selectAllCheckboxValue = value; //…
- User
void onSelectAllChange(bool? value) { setState(() { selectAllCheckboxValue = value; // Set the checkbox value for each quotation in the list for (var quotation in branchmanagerQuotationsList) { quotation.isChecked = value!; int? quotationId = quotation.id; if (quotationId != null) { if (value!) { if (!quotationsChecked.contains(quotationId)) { quotationsChecked.add(quotationId); } } else { quotationsChecked.remove(quotationId); } } debugPrint('quotationsChecked inside onSelectALl: quotationsChecked'); } debugPrint('quotationsChecked inside onSelectALl: quotationsChecked'); }); } this is my function htat handle select ll fucntinoality and here is my child widget with the get checkbox import 'package:custom_pop_up_menu/custom_pop_up_menu.dart'; import 'package:emis_mobile/constants/enums.dart'; import 'package:flutter/material.dart'; import 'package:flutter_svg/svg.dart'; import 'package:responsive_sizer/responsive_sizer.dart';
class BranchmanagerQuotationWidget extends StatelessWidget { BranchmanagerQuotationWidget({ super.key, required this.itemName, required this.scrollController, required this.child, required this.itemInfoPopupChild, required this.quoteStatus, this.quoteSyncStatus, this.isFirstIndex = false, required this.checkboxValue, this.selectAllCheckboxValue, this.unFoundQuote, required this.onCheckboxChange, required this.selectAll, this.onSelectAllChange, this.onAcceptPressed, this.onRejectPressed, this.isChecked = false, this.quotationSubclassIndex, this.subclassCode, });
final String itemName; final ScrollController scrollController; final Widget child; final Widget itemInfoPopupChild; final CustomPopupMenuController _controller = CustomPopupMenuController(); final QuotationStatus? quoteStatus; final String? quoteSyncStatus; bool isChecked; // Add isChecked property final bool isFirstIndex; final bool? checkboxValue; final bool? selectAllCheckboxValue; final bool selectAll; final Function(bool?)? onSelectAllChange; final Function(bool?)? onCheckboxChange; final String? unFoundQuote;
final Function()? onRejectPressed; final Function()? onAcceptPressed;
final int? quotationSubclassIndex; // Define quotationSubclassIndex variable final String? subclassCode; // Define subclassCode variable
BoxShadow getBoxShadow() { switch (quoteStatus) { // case QuotationStatus.SUPERVISOR_APPROVED: // return const BoxShadow( // color: Colors.green, blurRadius: 3, offset: Offset(1, -4)); // case QuotationStatus.STATISTICIAN_APPROVED: // return const BoxShadow( // color: Colors.green, blurRadius: 3, offset: Offset(1, -4)); // case QuotationStatus.REJECTED: // return const BoxShadow( // color: Colors.red, blurRadius: 3, offset: Offset(1, -4)); // case QuotationStatus.PENDING: // return BoxShadow( // color: Colors.grey.shade300.withOpacity(0.4), // blurRadius: 10, // offset: const Offset(2, 5)); // default: // return BoxShadow( // color: Colors.grey.shade300.withOpacity(0.4), // blurRadius: 10, // offset: const Offset(2, 5)); case QuotationStatus.BRANCH_APPROVED: return const BoxShadow( color: Colors.green, blurRadius: 3, offset: Offset(1, -4)); case QuotationStatus.REJECTED: return const BoxShadow( color: Colors.red, blurRadius: 3, offset: Offset(1, -4)); case QuotationStatus.STATISTICIAN_APPROVED: return BoxShadow( color: Colors.grey.shade300.withOpacity(0.4), blurRadius: 10, offset: const Offset(2, 5)); default: return BoxShadow( color: Colors.grey.shade300.withOpacity(0.4), blurRadius: 10, offset: const Offset(2, 5)); } }
- Assistant
To fix the issue of displaying other subclasses as selected when selecting the top-level checkbox, you need to update the
onCheckboxChangefunction in yourBranchmanagerQuotationWidgetas follows: