getErrorView method

Widget getErrorView({
  1. required String title,
  2. required String msg,
  3. double? iconSize,
  4. double? width,
  5. Color iconColor = Colors.red,
  6. double? verticalSpace,
  7. String? titleFontFamily,
  8. String? valueFontFamily,
  9. double? titleFontSize,
  10. double? valueFontSize,
  11. Color titleTextColor = Colors.black,
  12. Color valueTextColor = Colors.black,
})

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 to Utils.appConstants.zeroPointZeroOne.
  • titleFontFamily: Font family for title. Defaults to Utils.appConstants.boldFontFamily.
  • valueFontFamily: Font family for message. Defaults to Utils.appConstants.mediumFontFamily.
  • titleFontSize: Title font size. Defaults to Utils.appConstants.textButtonFontSize.
  • valueFontSize: Message font size. Defaults to Utils.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),
          ],
        ),
      ),
    ),
  ]);
}