I currently have an interesting issue related to displaying of a snackbar based on a user action.
Above sounds very trivial, but lets elaborate:
I have 2 screens:
- list of employees
- Add employee
The application uses the bloc pattern (with streams/rxdart).
Here is what I want:
- User clicks on add employee FAB button in list of employees screen and is navigated to the Add Employee screen (works perfectly fine)
- User fills in employee details and clicks save
- Upon save, employee is added to the stream, and updated the list of employees screen (works fine)
- User is navigated BACK to list of employees (works fine)
- Snackbar is displayed stating that the employee has successfully been added (This is the problem)
I tried several ways of implementing this:
Add a new stream (employeeAdded), and when adding an employee to the employees stream, additionally push a boolean to employee added.
In the list of employees, add a new stream builder and in the builder logic add the snackbar.
This gives all sorts of problems, for example trying to display the snackbar before the page has been (re)build, and so on.
The question is twofold: What is good UX practice for this scenario, and what would be a good solution for this problem?
(will post code on request)
Thanks for the help!