getErrorView method
Creates an error view with title, error icon, and message.
Displays an error state with a title, error icon, and descriptive message in an elevated card. Similar to getEmptyView but specifically styled for error conditions.
Parameters:
title: The error heading text.msg: The error description or details.iconSize: Size of the error icon.width: Container width. Defaults to full screen width.iconColor: Color of the error icon (defaults to red).verticalSpace: Spacing between elements. Defaults toUtils.appConstants.zeroPointZeroOne.titleFontFamily: Font family for title. Defaults toUtils.appConstants.boldFontFamily.valueFontFamily: Font family for message. Defaults toUtils.appConstants.mediumFontFamily.titleFontSize: Title font size. Defaults toUtils.appConstants.textButtonFontSize.valueFontSize: Message font size. Defaults toUtils.appConstants.textSubHeaderFontSize.titleTextColor: Title text color (defaults to black).valueTextColor: Message text color (defaults to black).
Returns a Wrap containing an elevated box with error state content.
Example:
getErrorView(
title: 'Error Loading Data',
msg: 'Unable to connect to the server. Please try again.',
iconColor: Colors.red[700],
iconSize: 48,
);
Implementation
Widget getErrorView(
{required String title,
required String msg,
double? iconSize,
double? width,
Color iconColor = Colors.red,
double? verticalSpace,
String? titleFontFamily,
String? valueFontFamily,
double? titleFontSize,
double? valueFontSize,
Color titleTextColor = Colors.black,
Color valueTextColor = Colors.black}) {
return Wrap(children: [
getBoxWithElevation(
child: SizedBox(
width: width ?? Get.width,
child: Column(
children: [
setText(
title,
titleFontFamily ?? Utils.appConstants.boldFontFamily,
titleTextColor,
titleFontSize ?? Utils.appConstants.textButtonFontSize),
addVerticalSpace(
verticalSpace ?? Utils.appConstants.zeroPointZeroOne),
Icon(
Icons.error, // Use a cloud icon with an "X"
size: iconSize, color: iconColor,
),
addVerticalSpace(
verticalSpace ?? Utils.appConstants.zeroPointZeroOne),
setText(
msg,
valueFontFamily ?? Utils.appConstants.mediumFontFamily,
valueTextColor,
valueFontSize ?? Utils.appConstants.textSubHeaderFontSize),
],
),
),
),
]);
}