We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Describe the bug StateError (Bad state: Cannot use "ref" after the widget was disposed.)
To Reproduce When i Click the Pay Now button i am getting this issue. if i remove
await ref .read(orderDetailNotifierProvider.notifier) .getOrderDetails( outletIdentifier: outletDetails .firstOrNull?.identifier ?.toInt() ?? 0, type: selectedTable != null ? 1 : 2, typeId: selectedTable?.tableId ?? selectedTakeAway?.takeAwayUid ?? takeAwayUuid, );
I am not getting any error. <Please add a small sample to that can be executed to reproduce the problem. As a general rule, 100 lines is the maximum>
Expected behavior Get order details and navigate to payement page if it orderdetail is not empty.
####### code------
onPressed: () async {
// Fetch order details await ref .read(orderDetailNotifierProvider.notifier) .getOrderDetails( outletIdentifier: outletDetails .firstOrNull?.identifier ?.toInt() ?? 0, type: selectedTable != null ? 1 : 2, typeId: selectedTable?.tableId ?? selectedTakeAway?.takeAwayUid ?? takeAwayUuid, ); // Order items if selectedMenuItems is not empty if (selectedMenuItems.isNotEmpty) { await ref .read(orderItemNotifierProvider.notifier) .orderItem( cover: widget.cover, kotNumber: 0, ); } // Retrieve order details after fetching final List<Orders> orderDetails = ref .read(orderDetailNotifierProvider) .data .data ?.orders ?? []; // Check if selectedMenuItems is empty and orderDetails is not empty if (selectedMenuItems.isEmpty && orderDetails.isNotEmpty) { // Fetch additional data ref .read(selectedTableTakeAwayProvider.notifier) .getNewTableOrTakeAway( outletDetails: outletDetails.firstOrNull, selectedTable: selectedTable, selectedTakeAway: selectedTakeAway, ); final newSelectedTable = ref .read(selectedTableTakeAwayProvider) .selectedTable; final newSelectedTakeAway = ref .read(selectedTableTakeAwayProvider) .selectedTakeAway; // Prepare bill ref .read(prepareBillNotifierProvider.notifier) .prepareBill( ouletIdentifer: outletDetails.firstOrNull?.identifier ?? 0, tableId: newSelectedTable?.tableId ?? 0, roomId: 0, takeAwayUid: newSelectedTable == null ? newSelectedTakeAway?.takeAwayUid ?? takeAwayUuid : null, ); // Get settlement data ref .read(settlementDataNotifierProvider.notifier) .getSettlementData( outletIdentifier: outletDetails.firstOrNull?.identifier ?? 0, ); // Navigate to the payment page if (context.mounted) { Navigator.pushNamed(context, AppRoutes.payementPage); } } },
The text was updated successfully, but these errors were encountered:
That's way too much code. Please make a minimal reproducible example.
Generally speaking, this error is expected and a mistake on your end. Chances are you used ref after an await without checking context.mounted
ref
await
context.mounted
Sorry, something went wrong.
Just noticed this this error in our Crashlytics logs, and saw that I had forgot to check context.mounted in one place.
Perhaps there should be a lint for this in package:riverpod_lint? Just like there is one for using context after await?
package:riverpod_lint
context
Closing in the lack of a minimal reproducing example
rrousselGit
No branches or pull requests
Describe the bug
StateError (Bad state: Cannot use "ref" after the widget was disposed.)
To Reproduce
When i Click the Pay Now button i am getting this issue. if i remove
I am not getting any error.
<Please add a small sample to that can be executed to reproduce the problem. As a general rule, 100 lines is the maximum>
Expected behavior
Get order details and navigate to payement page if it orderdetail is not empty.
####### code------
onPressed: () async {
The text was updated successfully, but these errors were encountered: