noItemFoundUI method
Widget
noItemFoundUI({
- required String msg,
- Alignment? containerAlignment,
- double? containerWidth,
- double? containerHeight,
- double? vwNoItemFoundBorderWidth,
- double? vwNoItemFoundBorderRadius,
- EdgeInsets? containerPadding,
- Color? vwNoItemFoundBgColor,
- Color? vwNoItemFoundBorderColor,
- Icon? noItemIcon,
- TextStyle? txtNoFollowingFoundStyle,
- TextAlign? textAlign,
Creates a "no items found" empty state UI with icon and message.
Displays a centered container with a "no items" icon and customizable message. Useful for empty lists, search results, or collections.
Parameters:
msg: The message to display to the user.containerAlignment: Alignment of content within the container. Defaults to Alignment.center.containerWidth: Width of the container. Defaults toUtils.appConstants.vwNoItemFoundWidth.containerHeight: Height of the container. Defaults toUtils.appConstants.vwNoItemFoundHeight.vwNoItemFoundBorderWidth: Border width. Defaults toUtils.appConstants.vwNoItemFoundBorderWidth.vwNoItemFoundBorderRadius: Corner radius. Defaults toUtils.appConstants.vwNoItemFoundBorderRadius.containerPadding: Internal padding. Defaults toUtils.appConstants.vwNoItemFoundPadding.vwNoItemFoundBgColor: Background color. Defaults toUtils.appConstants.vwNoItemFoundBgColor.vwNoItemFoundBorderColor: Border color. Defaults toUtils.appConstants.vwNoItemFoundBorderColor.noItemIcon: Custom icon to display. Defaults toUtils.appConstants.imgNoItemFound.txtNoFollowingFoundStyle: Text style for the message. Defaults toUtils.appConstants.txtNoFollowingFoundStyle.textAlign: Text alignment. Defaults to TextAlign.center.
Returns a centered Container with the empty state UI.
The UI uses AutoSizeText to ensure the message fits within the available space.
Example:
noItemFoundUI(
msg: 'No followers yet',
vwNoItemFoundBgColor: Colors.grey[50],
noItemIcon: Icon(Icons.people_outline, size: 64),
);
Implementation
Widget noItemFoundUI(
{required String msg,
Alignment? containerAlignment,
double? containerWidth,
double? containerHeight,
double? vwNoItemFoundBorderWidth,
double? vwNoItemFoundBorderRadius,
EdgeInsets? containerPadding,
Color? vwNoItemFoundBgColor,
Color? vwNoItemFoundBorderColor,
Icon? noItemIcon,
TextStyle? txtNoFollowingFoundStyle,
TextAlign? textAlign}) {
return Center(
child: Container(
alignment: containerAlignment ?? Alignment.center,
width: containerWidth ?? Utils.appConstants.vwNoItemFoundWidth,
height: containerHeight ?? Utils.appConstants.vwNoItemFoundHeight,
padding: containerPadding ?? Utils.appConstants.vwNoItemFoundPadding,
decoration: BoxDecoration(
color:
vwNoItemFoundBgColor ?? Utils.appConstants.vwNoItemFoundBgColor,
border: Border.all(
color: vwNoItemFoundBorderColor ??
Utils.appConstants.vwNoItemFoundBorderColor,
width: vwNoItemFoundBorderWidth ??
Utils.appConstants.vwNoItemFoundBorderWidth,
),
borderRadius: BorderRadius.circular(vwNoItemFoundBorderRadius ??
Utils.appConstants.vwNoItemFoundBorderRadius),
),
child: Column(
mainAxisSize: MainAxisSize.max,
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
noItemIcon ?? Utils.appConstants.imgNoItemFound,
AutoSizeText(
msg,
style: txtNoFollowingFoundStyle ??
Utils.appConstants.txtNoFollowingFoundStyle,
textAlign: textAlign ?? TextAlign.center,
),
],
),
),
);
}