Skip to content

Conversation

@krushnarout
Copy link
Member

@krushnarout krushnarout commented Dec 16, 2025

Line of code, what is the cause that leads to this fix? Which variable is potentially null?

here dialog was called after async work, that's why State.context becomes null after the widget is disposed

closes #3801

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request effectively resolves a null crash that occurred when displaying a firmware warning. The primary fix involves adding a mounted check before showing the dialog, which is a critical safeguard to prevent using the widget's context after it has been unmounted, especially in asynchronous operations. Additionally, the code quality is improved by using a distinct dialogContext within the dialog builder, which avoids variable shadowing and ensures the dialog is dismissed using the correct context. These changes make the code more robust and stable.

@beastoin
Copy link
Collaborator

beastoin commented Dec 17, 2025

with every single fix, you must include the cause at the loc level.

For example, what is the cause that leads to this fix? Which variable is potentially null?

---

Screenshot 2025-12-17 at 10 27 19 Screenshot 2025-12-17 at 10 27 04

@krushnarout
Copy link
Member Author

with every single fix, you must include the cause at the loc level.

For example, what is the cause that leads to this fix? Which variable is potentially null?

added #3802 (comment)

@beastoin
Copy link
Collaborator

I don't see that these lines of code match the bug reports. Can you check it again?

Screenshot 2025-12-25 at 11 21 48 Screenshot 2025-12-25 at 11 21 45

@krushnarout
Copy link
Member Author

krushnarout commented Dec 25, 2025

I don't see that these lines of code match the bug reports. Can you check it again?

@beastoin I added the line of code that actually causes the crash, which is await showDialog(context: context, ...). In the bug report, _0x0 _FoundDevicesState._showFirmwareWarningIfNeeded + 157 (found_devices.dart:157) only points to the function where the error occurred, not the exact statement.

@mdmohsin7
Copy link
Member

mdmohsin7 commented Jan 3, 2026

pls resolve conflicts

@krushnarout
Copy link
Member Author

pls resolve conflicts

done

@mdmohsin7 mdmohsin7 merged commit 8b9c8e5 into main Jan 5, 2026
1 check passed
@mdmohsin7 mdmohsin7 deleted the fix/null-crash-3801 branch January 5, 2026 14:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FlutterError - Null check operator used on a null value - _showFirmwareWarningIfNeeded

4 participants