07-21-2023, 06:12 PM
You can use builder in following manning:
I have consider a condition where we can get image url as null, hence if null I show a shrink sizedbox as it has no property a completely void widget.
Builder(builder: (BuildContext context) {
if (iconPath != null) {
return ImageIcon(
AssetImage(iconPath!),
color: AppColors.kPrimaryColor,
);
} else {
return SizedBox.shrink();
}
})
I have consider a condition where we can get image url as null, hence if null I show a shrink sizedbox as it has no property a completely void widget.
Builder(builder: (BuildContext context) {
if (iconPath != null) {
return ImageIcon(
AssetImage(iconPath!),
color: AppColors.kPrimaryColor,
);
} else {
return SizedBox.shrink();
}
})