import 'package:flutter/material.dart'; class ExpandableSection extends StatefulWidget { const ExpandableSection( {super.key, required this.title, required this.child}); final String title; final Widget child; @override State createState() => _ExpandableSectionState(); } class _ExpandableSectionState extends State { bool _open = false; @override Widget build(BuildContext context) { return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ InkWell( enableFeedback: false, borderRadius: BorderRadius.circular(3), onTap: () => setState(() => _open = !_open), child: Padding( padding: const EdgeInsets.symmetric(horizontal: 4), child: Row( children: [ Expanded( child: Text( widget.title, style: Theme.of(context).textTheme.titleSmall, ), ), Icon( _open ? Icons.keyboard_arrow_up : Icons.keyboard_arrow_down, ), ], ), ), ), if (_open) Padding( padding: const EdgeInsets.fromLTRB(12, 0, 12, 12), child: widget.child, ), ], ); } }