I've been wondering what's the best practice for conditional widget trees between using ternaries and if-else-blocks.
Following guides online, I feel people use mostly ternaries but I find them quite unreadable when they exceed a single line :
So I tend to create a fonction and make an if-else-block when my ternary are too long :
floatingActionButton: selectedLicences.isEmpty //
? Container()
: LicencesWidget(selectedLicences: selectedLicences)
Widget _buildFAB(List<X> licences) {
if (licences.isEmpty) {
return Container();
} else {
return LicencesWidget(selectedLicences: licences);
}
}
What's the best practice?