-
Notifications
You must be signed in to change notification settings - Fork 35
Description
Describe the bug
- The current snackbar implementation in the canvas screen has several critical issues:
-
Message Overshadowing: The BlocConsumer listener automatically shows snackbars for any state.message using only CustomSnackbar.showInfo(), which can overshadow other snackbars triggered by user actions (like undo, redo, clear canvas operations).
-
Limited Snackbar Types: The automatic message system only uses showInfo(), preventing the use of showSuccess() or showError() snackbars for appropriate contextual feedback.
-
Inefficient State Management: The current system requires a message parameter in the state that needs to be manually cleared after each use, leading to unnecessary state updates and potential race conditions.
To Reproduce
Steps to reproduce the behavior:
- Open the canvas screen
- Perform an action that triggers a direct snackbar (e.g., click "Undo" when there's nothing to undo)
- Immediately perform a save/load operation that sets state.message
- Observe that the save/load snackbar may overshadow or conflict with the previous snackbar
- Notice that all automatic snackbars are blue "info" type, regardless of whether they should be success (green) or error (red)
Expected behavior
- Each snackbar should be displayed independently without conflicts
- Success operations (like successful save) should show green success snackbars
- Error operations (like failed save/load) should show red error snackbars
- Info operations should show blue info snackbars
- Multiple snackbars should queue properly or replace each other gracefully
- No unnecessary state updates for temporary UI feedback
Actual behavior
- Snackbars can conflict with each other
- All automatic snackbars are forced to be "info" type (blue)
Statecontains a message field that requires manual clearing- The
BlocConsumerlistener creates tight coupling between state and UI feedback
Current Problematic Code Location
- File: canvas_screen.dart (lines 224-229)
// Show snackbar when there's a message from save/load operations
if (state.message != null) {
CustomSnackbar.showInfo(state.message!);
// Clear the message after showing
context.read<CanvasCubit>().clearMessage();
}
Suggested Solution
Replace the current message state system.
- Remove message from CanvasState - UI feedback shouldn't be part of business logic state
- Implement snackbar queuing - Ensure multiple snackbars don't conflict
- Let developers use snackbars like this, e.g CustomSnackbar.showSuccess("New page Created"); instead of listening through state changes.
Additional details
Add any other context or screenshots about the feature request here.