GotJimmy / accordion

Other
47 stars 44 forks source link

New function - Is it possible to show an AccordionSection condicionally? #61

Closed cesarkmelo closed 10 months ago

cesarkmelo commented 10 months ago

Hi, Is it possible to show an AccordionSection condicionally?

Something like this

(element.field != null)
                    ? AccordionSection(
                        isOpen: false,
                        contentVerticalPadding: 20,
                        leftIcon: const Icon(Icons.text_fields_rounded,
                            color: Colors.white),
                        header: const Text('Element field Name'),
                        content: const Text('Element field content'),
                      )
                    : null,

This will be very nice to have.

GotJimmy commented 10 months ago

Sure:

Accordion(
   children: [
      AccordionSection(.......),
      if (YOUR_CONDITION) AccordionSection(.......),
      AccordionSection(.......),
]
)
cesarkmelo commented 10 months ago

Great, LOL, I was blinded by the ternary operator. Thanks.