Accordion constructor Null safety

Accordion(
  1. {int? maxOpenSections,
  2. List<AccordionSection>? children,
  3. int? initialOpeningSequenceDelay,
  4. Color? headerBackgroundColor,
  5. double? headerBorderRadius,
  6. TextAlign? headerTextAlign,
  7. TextStyle? headerTextStyle,
  8. Widget? leftIcon,
  9. Widget? rightIcon,
  10. bool? flipRightIconIfOpen,
  11. Color? contentBackgroundColor,
  12. Color? contentBorderColor,
  13. double? contentBorderWidth,
  14. double? contentBorderRadius,
  15. double? contentHorizontalPadding,
  16. double? contentVerticalPadding,
  17. double paddingListTop = 20.0,
  18. double paddingListBottom = 40.0,
  19. double paddingListHorizontal = 10.0,
  20. EdgeInsets? headerPadding,
  21. double? paddingBetweenOpenSections,
  22. double? paddingBetweenClosedSections,
  23. ScrollIntoViewOfItems? scrollIntoViewOfItems}
)

Implementation

Accordion({
  int? maxOpenSections,
  this.children,
  int? initialOpeningSequenceDelay,
  Color? headerBackgroundColor,
  double? headerBorderRadius,
  TextAlign? headerTextAlign,
  TextStyle? headerTextStyle,
  Widget? leftIcon,
  Widget? rightIcon,
  bool? flipRightIconIfOpen,
  Color? contentBackgroundColor,
  Color? contentBorderColor,
  double? contentBorderWidth,
  double? contentBorderRadius,
  double? contentHorizontalPadding,
  double? contentVerticalPadding,
  this.paddingListTop = 20.0,
  this.paddingListBottom = 40.0,
  this.paddingListHorizontal = 10.0,
  EdgeInsets? headerPadding,
  double? paddingBetweenOpenSections,
  double? paddingBetweenClosedSections,
  ScrollIntoViewOfItems? scrollIntoViewOfItems,
}) {
  listCtrl.initialOpeningSequenceDelay = initialOpeningSequenceDelay ?? 0;
  this._headerBackgroundColor = headerBackgroundColor;
  this._headerBorderRadius = headerBorderRadius ?? 30;
  this._headerTextAlign = headerTextAlign ?? TextAlign.left;
  this._headerTextStyle = headerTextStyle;
  this._leftIcon = leftIcon;
  this._rightIcon = rightIcon;
  this._flipRightIconIfOpen = flipRightIconIfOpen;
  this._contentBackgroundColor = contentBackgroundColor;
  this._contentBorderColor = contentBorderColor;
  this._contentBorderWidth = contentBorderWidth;
  this._contentBorderRadius = contentBorderRadius ?? 20;
  this._contentHorizontalPadding = contentHorizontalPadding;
  this._contentVerticalPadding = contentVerticalPadding;
  this._headerPadding = headerPadding ?? EdgeInsets.symmetric(horizontal: 20, vertical: 10);
  this._paddingBetweenOpenSections = paddingBetweenOpenSections ?? 10;
  this._paddingBetweenClosedSections = paddingBetweenClosedSections ?? 3;
  this._scrollIntoViewOfItems = scrollIntoViewOfItems;

  int count = 0;
  listCtrl.maxOpenSections = maxOpenSections ?? 1;
  children!.forEach((child) {
    if (child._sectionCtrl.isSectionOpen.value == true) {
      count++;

      if (count > listCtrl.maxOpenSections) child._sectionCtrl.isSectionOpen.value = false;
    }
  });
}