Files
syncrow-web/lib/pages/spaces_management/widgets/community_tile.dart
2024-10-08 20:37:04 +04:00

46 lines
1.1 KiB
Dart

import 'package:flutter/material.dart';
import 'package:syncrow_web/common/custom_expansion_tile.dart';
class CommunityTile extends StatefulWidget {
final String title;
final List<Widget>? children;
final bool initiallyExpanded;
final Function(String, bool) onExpansionChanged;
const CommunityTile({
Key? key,
required this.title,
required this.initiallyExpanded,
required this.onExpansionChanged,
this.children,
}) : super(key: key);
@override
_CommunityTileState createState() => _CommunityTileState();
}
class _CommunityTileState extends State<CommunityTile> {
late bool _isExpanded;
@override
void initState() {
super.initState();
_isExpanded = widget.initiallyExpanded;
}
@override
Widget build(BuildContext context) {
return CustomExpansionTile(
title: widget.title,
initiallyExpanded: _isExpanded,
onExpansionChanged: (bool expanded) {
setState(() {
_isExpanded = expanded;
});
widget.onExpansionChanged(widget.title, expanded);
},
children: widget.children ?? [],
);
}
}