How to execute some work when widget is disposed with riverpod? #3273
Trung15010802
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
This is my way to execute some work when widget is disposed and to avoid error "cannot use "ref" after the widget was disposed"
![image](https://private-user-images.githubusercontent.com/90593296/296261955-81a59f6d-19ec-4c3c-9b9d-1abfdff75aa1.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTk4OTcwMjEsIm5iZiI6MTcxOTg5NjcyMSwicGF0aCI6Ii85MDU5MzI5Ni8yOTYyNjE5NTUtODFhNTlmNmQtMTllYy00YzNjLTliOWQtMWFiZmRmZjc1YWExLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MDIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzAyVDA1MDUyMVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTg0NmZhN2I5NjkzZThiNjhkZWQxMjUzYzBhNGU5ZWJiMTI1MTZhN2ExY2VmZWQ4NmE5NWNhZjkwNDgyN2VjMjAmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.ObxPA8m4DR4kaURio7867HZLX1Np8d3HFZM5h-fNY9E)
In widget's initState:
ref.listenManual(widgetIsDisposedProvider, (_, __) {});
I hope someone will show me a better way
Beta Was this translation helpful? Give feedback.
All reactions