AccordionSection constructor

AccordionSection({
  1. Key? key,
  2. int index = 0,
  3. bool isOpen = false,
  4. required Widget header,
  5. required Widget content,
  6. Color? headerBackgroundColor,
  7. Color? headerBackgroundColorOpened,
  8. Color? headerBorderColor,
  9. Color? headerBorderColorOpened,
  10. double? headerBorderWidth,
  11. double? headerBorderRadius,
  12. EdgeInsets? headerPadding,
  13. Widget? leftIcon,
  14. Widget? rightIcon,
  15. Color? contentBackgroundColor,
  16. Color? contentBorderColor,
  17. double? contentBorderWidth,
  18. double? contentBorderRadius,
  19. double? contentHorizontalPadding,
  20. double? contentVerticalPadding,
  21. double? paddingBetweenOpenSections,
  22. double? paddingBetweenClosedSections,
  23. ScrollIntoViewOfItems? scrollIntoViewOfItems,
  24. SectionHapticFeedback? sectionOpeningHapticFeedback,
  25. SectionHapticFeedback? sectionClosingHapticFeedback,
  26. String? accordionId,
  27. Function? onOpenSection,
  28. Function? onCloseSection,
})

Implementation

AccordionSection({
  Key? key,
  this.index = 0,
  this.isOpen = false,
  required this.header,
  required this.content,
  Color? headerBackgroundColor,
  Color? headerBackgroundColorOpened,
  Color? headerBorderColor,
  Color? headerBorderColorOpened,
  double? headerBorderWidth,
  double? headerBorderRadius,
  EdgeInsets? headerPadding,
  Widget? leftIcon,
  Widget? rightIcon,
  Color? contentBackgroundColor,
  Color? contentBorderColor,
  double? contentBorderWidth,
  double? contentBorderRadius,
  double? contentHorizontalPadding,
  double? contentVerticalPadding,
  double? paddingBetweenOpenSections,
  double? paddingBetweenClosedSections,
  ScrollIntoViewOfItems? scrollIntoViewOfItems,
  SectionHapticFeedback? sectionOpeningHapticFeedback,
  SectionHapticFeedback? sectionClosingHapticFeedback,
  String? accordionId,
  this.onOpenSection,
  this.onCloseSection,
}) : super(key: key) {
  final listCtrl = Get.put(ListController(), tag: accordionId);
  uniqueKey = listCtrl.keys.elementAt(index);
  sectionCtrl.isSectionOpen.value = listCtrl.openSections.contains(uniqueKey);

  this.headerBackgroundColor = headerBackgroundColor;
  this.headerBackgroundColorOpened =
      headerBackgroundColorOpened ?? headerBackgroundColor;
  this.headerBorderColor = headerBorderColor ?? headerBackgroundColor;
  this.headerBorderColorOpened =
      headerBorderColorOpened ?? headerBackgroundColorOpened;
  this.headerBorderWidth = headerBorderWidth;
  this.headerBorderRadius = headerBorderRadius;
  this.headerPadding = headerPadding;
  this.leftIcon = leftIcon;
  this.rightIcon = rightIcon;
  this.contentBackgroundColor = contentBackgroundColor;
  this.contentBorderColor = contentBorderColor;
  this.contentBorderWidth = contentBorderWidth;
  this.contentBorderRadius = contentBorderRadius;
  this.contentHorizontalPadding = contentHorizontalPadding;
  this.contentVerticalPadding = contentVerticalPadding;
  this.paddingBetweenOpenSections = paddingBetweenOpenSections;
  this.paddingBetweenClosedSections = paddingBetweenClosedSections;
  this.scrollIntoViewOfItems =
      scrollIntoViewOfItems ?? ScrollIntoViewOfItems.fast;
  this.sectionOpeningHapticFeedback = sectionOpeningHapticFeedback;
  this.sectionClosingHapticFeedback = sectionClosingHapticFeedback;
  this.accordionId = accordionId;

  listCtrl.controllerIsOpen.stream.asBroadcastStream().listen((data) {
    sectionCtrl.isSectionOpen.value = listCtrl.openSections.contains(key);
  });
}