Accordion constructor

Accordion({
  1. Key? key,
  2. int? maxOpenSections,
  3. required List<AccordionSection> children,
  4. int? initialOpeningSequenceDelay,
  5. Color? headerBackgroundColor,
  6. Color? headerBackgroundColorOpened,
  7. Color? headerBorderColor,
  8. Color? headerBorderColorOpened,
  9. double? headerBorderWidth,
  10. double? headerBorderRadius,
  11. Widget? leftIcon,
  12. Widget? rightIcon,
  13. Widget? header,
  14. bool? flipLeftIconIfOpen = false,
  15. bool? flipRightIconIfOpen = true,
  16. Color? contentBackgroundColor,
  17. Color? contentBorderColor,
  18. double? contentBorderWidth,
  19. double? contentBorderRadius,
  20. double? contentHorizontalPadding,
  21. double? contentVerticalPadding,
  22. double paddingListTop = 20.0,
  23. double paddingListBottom = 20.0,
  24. double paddingListHorizontal = 10.0,
  25. EdgeInsets? headerPadding,
  26. double? paddingBetweenOpenSections,
  27. double? paddingBetweenClosedSections,
  28. ScrollIntoViewOfItems? scrollIntoViewOfItems,
  29. bool disableScrolling = false,
  30. SectionHapticFeedback? sectionOpeningHapticFeedback,
  31. SectionHapticFeedback? sectionClosingHapticFeedback,
  32. bool? openAndCloseAnimation,
  33. bool? scaleWhenAnimating,
  34. String? accordionId,
})

Implementation

Accordion({
  Key? key,
  int? maxOpenSections,
  required this.children,
  int? initialOpeningSequenceDelay,
  Color? headerBackgroundColor,
  Color? headerBackgroundColorOpened,
  Color? headerBorderColor,
  Color? headerBorderColorOpened,
  double? headerBorderWidth,
  double? headerBorderRadius,
  Widget? leftIcon,
  Widget? rightIcon,
  Widget? header,
  this.flipLeftIconIfOpen = false,
  this.flipRightIconIfOpen = true,
  Color? contentBackgroundColor,
  Color? contentBorderColor,
  double? contentBorderWidth,
  double? contentBorderRadius,
  double? contentHorizontalPadding,
  double? contentVerticalPadding,
  this.paddingListTop = 20.0,
  this.paddingListBottom = 20.0,
  this.paddingListHorizontal = 10.0,
  EdgeInsets? headerPadding,
  double? paddingBetweenOpenSections,
  double? paddingBetweenClosedSections,
  ScrollIntoViewOfItems? scrollIntoViewOfItems,
  this.disableScrolling = false,
  SectionHapticFeedback? sectionOpeningHapticFeedback,
  SectionHapticFeedback? sectionClosingHapticFeedback,

  /// if to use any animation when opening and closing sections
  bool? openAndCloseAnimation,

  /// if to use horizontal scaling of a section when opening or closing
  bool? scaleWhenAnimating,
  String? accordionId,
}) : super(key: key) {
  final listCtrl = Get.put(ListController(), tag: hashCode.toString());
  listCtrl.initialOpeningSequenceDelay = initialOpeningSequenceDelay ?? 0;
  listCtrl.maxOpenSections = maxOpenSections ?? 1;

  int index = 0;
  for (var child in children) {
    if (child.isOpen &&
        listCtrl.openSections.length < listCtrl.maxOpenSections) {
      listCtrl.openSections.add(listCtrl.keys.elementAt(index));
    }
    index++;
  }

  this.headerBackgroundColor = headerBackgroundColor;
  this.headerBackgroundColorOpened =
      headerBackgroundColorOpened ?? headerBackgroundColor;
  this.headerBorderColor = headerBorderColor;
  this.headerBorderColorOpened = headerBorderColorOpened ?? headerBorderColor;
  this.headerBorderWidth = headerBorderWidth;
  this.headerBorderRadius = headerBorderRadius;
  this.leftIcon = leftIcon;
  this.rightIcon = rightIcon;
  SectionController.flipLeftIconIfOpen = flipLeftIconIfOpen!;
  SectionController.flipRightIconIfOpen = flipRightIconIfOpen!;
  this.contentBackgroundColor = contentBackgroundColor;
  this.contentBorderColor = contentBorderColor;
  this.contentBorderWidth = contentBorderWidth;
  this.contentBorderRadius = contentBorderRadius;
  this.contentHorizontalPadding = contentHorizontalPadding;
  this.contentVerticalPadding = contentVerticalPadding;
  this.headerPadding = headerPadding;
  this.paddingBetweenOpenSections = paddingBetweenOpenSections;
  this.paddingBetweenClosedSections = paddingBetweenClosedSections;
  this.scrollIntoViewOfItems = scrollIntoViewOfItems;
  this.sectionOpeningHapticFeedback =
      sectionOpeningHapticFeedback ?? SectionHapticFeedback.none;
  this.sectionClosingHapticFeedback =
      sectionClosingHapticFeedback ?? SectionHapticFeedback.none;
  sectionAnimation = openAndCloseAnimation ?? true;
  sectionScaleAnimation = scaleWhenAnimating ?? true;
  this.accordionId = hashCode.toString();
}