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