mirror of
https://github.com/foss42/apidash.git
synced 2025-12-02 02:39:19 +08:00
52 lines
1.3 KiB
Dart
52 lines
1.3 KiB
Dart
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<ExpandableSection> createState() => _ExpandableSectionState();
|
|
}
|
|
|
|
class _ExpandableSectionState extends State<ExpandableSection> {
|
|
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,
|
|
),
|
|
],
|
|
);
|
|
}
|
|
}
|