Accordion constructor
Accordion({
- Key? key,
- int? maxOpenSections,
- required List<
AccordionSection> children, - int? initialOpeningSequenceDelay,
- Color? headerBackgroundColor,
- Color? headerBackgroundColorOpened,
- Color? headerBorderColor,
- Color? headerBorderColorOpened,
- double? headerBorderWidth,
- double? headerBorderRadius,
- Widget? leftIcon,
- Widget? rightIcon,
- Widget? header,
- bool? flipLeftIconIfOpen = false,
- bool? flipRightIconIfOpen = true,
- Color? contentBackgroundColor,
- Color? contentBorderColor,
- double? contentBorderWidth,
- double? contentBorderRadius,
- double? contentHorizontalPadding,
- double? contentVerticalPadding,
- double paddingListTop = 20.0,
- double paddingListBottom = 20.0,
- double paddingListHorizontal = 10.0,
- EdgeInsets? headerPadding,
- double? paddingBetweenOpenSections,
- double? paddingBetweenClosedSections,
- ScrollIntoViewOfItems? scrollIntoViewOfItems,
- bool disableScrolling = false,
- SectionHapticFeedback? sectionOpeningHapticFeedback,
- SectionHapticFeedback? sectionClosingHapticFeedback,
- bool? openAndCloseAnimation,
- bool? scaleWhenAnimating,
- 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();
}