ui/wc_modal library

A modal widget that displays an error message along with an icon and an optional action button. It is useful for scenarios where you need to inform the user about an error and optionally provide a way to take action.

The widget takes the following parameters:

  • error: An instance of WcBaseError that contains the error details.
  • backgroundColor: The background color of the modal. Defaults to Colors.deepPurple.
  • textColor: The color of the text displayed in the modal. Defaults to Colors.white.
  • icon: The icon displayed at the top of the modal. Defaults to Icons.error_outline.
  • iconColor: The color of the icon. Defaults to Colors.white.
  • onPressed: An optional callback function that is triggered when the action button is pressed.

Example usage:

WcModal(
  error: WcBaseError(
    title: 'Error Title',
    message: 'Error message goes here.',
  ),
  backgroundColor: Colors.red,
  textColor: Colors.white,
  icon: Icons.error,
  iconColor: Colors.white,
  onPressed: () {
    print('Action button pressed');
  },
);

This widget is stateless, meaning it does not maintain any state across rebuilds.

Classes

WcModal

Functions

showWcModal(BuildContext context, WcBaseError error, {Color backgroundColor = Colors.deepPurple, Color textColor = Colors.white, IconData icon = Icons.error_outline, Color iconColor = Colors.white, int durationSeconds = 3, double height = 300, double width = 200, Alignment alignment = Alignment.center, VoidCallback? onPressed, String buttonText = 'Action'}) → void