Skip to content

Commit

Permalink
fix: check for widget mount status before using context post-async
Browse files Browse the repository at this point in the history
  • Loading branch information
jacob-i committed Jan 18, 2024
1 parent bfe5625 commit 9faaa4b
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions app/lib/views/widgets/paint_window.dart
Original file line number Diff line number Diff line change
Expand Up @@ -142,15 +142,18 @@ class PaintWindowState extends State<PaintWindow> {
htmlContent = htmlResponse;
}

Navigator.push(
context,
MaterialPageRoute(
builder: (context) => HtmlViewScreen(
htmlContent: htmlContent,
appName: creationName,
// Use the captured context after the async gap
if (mounted) {
Navigator.push(
context, // use the safeContext that was captured before the async gap
MaterialPageRoute(
builder: (context) => HtmlViewScreen(
htmlContent: htmlContent,
appName: creationName,
),
),
),
);
);
}

setState(() {
isLoading = false;
Expand Down

0 comments on commit 9faaa4b

Please sign in to comment.