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. double? headerBorderRadius,
  9. EdgeInsets? headerPadding,
  10. Widget? leftIcon,
  11. Widget? rightIcon,
  12. bool? flipRightIconIfOpen = true,
  13. Color? contentBackgroundColor,
  14. Color? contentBorderColor,
  15. double? contentBorderWidth,
  16. double? contentBorderRadius,
  17. double? contentHorizontalPadding,
  18. double? contentVerticalPadding,
  19. double? paddingBetweenOpenSections,
  20. double? paddingBetweenClosedSections,
  21. ScrollIntoViewOfItems? scrollIntoViewOfItems,
  22. SectionHapticFeedback? sectionOpeningHapticFeedback,
  23. SectionHapticFeedback? sectionClosingHapticFeedback,
  24. String? accordionId,
  25. Function? onOpenSection,
  26. Function? onCloseSection,
})

Implementation

AccordionSection({
  Key? key,
  this.index = 0,
  this.isOpen = false,
  required this.header,
  required this.content,
  Color? headerBackgroundColor,
  Color? headerBackgroundColorOpened,
  double? headerBorderRadius,
  EdgeInsets? headerPadding,
  Widget? leftIcon,
  Widget? rightIcon,
  bool? flipRightIconIfOpen = true,
  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.headerBorderRadius = headerBorderRadius;
  this.headerPadding = headerPadding;
  this.leftIcon = leftIcon;
  this.rightIcon = rightIcon;
  this.flipRightIconIfOpen?.value = flipRightIconIfOpen ?? true;
  this.contentBackgroundColor = contentBackgroundColor;
  this.contentBorderColor = contentBorderColor;
  this.contentBorderWidth = contentBorderWidth ?? 1;
  this.contentBorderRadius = contentBorderRadius ?? 10;
  this.contentHorizontalPadding = contentHorizontalPadding ?? 10;
  this.contentVerticalPadding = contentVerticalPadding ?? 10;
  this.paddingBetweenOpenSections = paddingBetweenOpenSections ?? 10;
  this.paddingBetweenClosedSections = paddingBetweenClosedSections ?? 10;
  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);
  });
}