Refactor expansion icon handling in CustomExpansionTileSpaceTree for improved readability and maintainability.

This commit is contained in:
Faris Armoush
2025-04-16 14:46:37 +03:00
parent f709b92e12
commit 3de7606a00

View File

@ -49,21 +49,7 @@ class CustomExpansionTileSpaceTree extends StatelessWidget {
}), }),
checkColor: ColorsManager.whiteColors, checkColor: ColorsManager.whiteColors,
), ),
if (children != null && children!.isNotEmpty) _buildExpansionIcon(),
InkWell(
onTap: () {
if (onExpansionChanged != null) {
onExpansionChanged!();
}
},
child: Icon(
isExpanded
? Icons.keyboard_arrow_down
: Icons.keyboard_arrow_right,
color: ColorsManager.lightGrayColor,
size: 16.0,
),
),
Expanded( Expanded(
child: GestureDetector( child: GestureDetector(
onTap: () { onTap: () {
@ -96,6 +82,20 @@ class CustomExpansionTileSpaceTree extends StatelessWidget {
); );
} }
Widget _buildExpansionIcon() {
return Visibility(
visible: children != null && children!.isNotEmpty,
child: InkWell(
onTap: onExpansionChanged,
child: Icon(
isExpanded ? Icons.keyboard_arrow_down : Icons.keyboard_arrow_right,
color: ColorsManager.lightGrayColor,
size: 16.0,
),
),
);
}
String _capitalizeFirstLetter(String text) { String _capitalizeFirstLetter(String text) {
if (text.isEmpty) return text; if (text.isEmpty) return text;
return text[0].toUpperCase() + text.substring(1); return text[0].toUpperCase() + text.substring(1);