AccordionSection constructor
AccordionSection({
- Key? key,
- int index = 0,
- bool isOpen = false,
- required Widget header,
- required Widget 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,
- Function? onOpenSection,
- 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);
});
}