-
Notifications
You must be signed in to change notification settings - Fork 0
flutter: context cleanup batch 5 — post‑await captures #74
New issue
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
Conversation
… mounted in ThemeShareDialog, DeleteFamilyDialog, LoginScreen; remove unused test import
… duplicated lines and define messenger/router captures
…assword link; fix stray duplication
Summary of ChangesHello @zensgit, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! 此拉取请求主要侧重于 Flutter 应用程序中的上下文管理和代码清理。它通过在异步操作之前预先获取 Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR implements Flutter context cleanup improvements by pre-fetching navigator and messenger instances to avoid context access after async operations. The changes focus on preventing potential issues when widgets are unmounted after awaits in dialogs and authentication screens.
- Pre-fetches
Navigator.of(context)andScaffoldMessenger.of(context)before async operations - Replaces
context.mountedchecks withmountedchecks for consistency - Removes unused test import and fixes minor const issues
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| jive-flutter/test/transactions/transaction_list_grouping_widget_test.dart | Removes unused TransactionCard import |
| jive-flutter/lib/widgets/theme_share_dialog.dart | Pre-fetches messenger, uses mounted checks, fixes const usage |
| jive-flutter/lib/widgets/states/loading_indicator.dart | Removes unnecessary const keywords |
| jive-flutter/lib/widgets/qr_code_generator.dart | Removes unnecessary const keywords |
| jive-flutter/lib/widgets/dialogs/delete_family_dialog.dart | Pre-fetches navigator/messenger, uses mounted checks |
| jive-flutter/lib/screens/auth/login_screen.dart | Pre-fetches messenger/router, uses mounted checks, fixes string interpolation |
| PR_71_FIX_REPORT.md | Adds documentation for previous PR fixes |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| SnackBar( | ||
| content: | ||
| Text('欢迎回来,${result.userData?.username}!'), | ||
| content: Text('欢迎回来,\${result.userData?.username}!'), |
Copilot
AI
Sep 30, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
String interpolation is broken due to escaped dollar signs. Remove the backslashes to properly interpolate the variables.
| content: Text('欢迎回来,\${result.userData?.username}!'), | |
| content: Text('欢迎回来,${result.userData?.username}!'), |
Copilot uses AI. Check for mistakes.
| messenger.showSnackBar( | ||
| SnackBar( | ||
| content: Text('微信登录失败: $error'), | ||
| content: Text('微信登录失败: \$error'), |
Copilot
AI
Sep 30, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
String interpolation is broken due to escaped dollar signs. Remove the backslashes to properly interpolate the variables.
| content: Text('微信登录失败: \$error'), | |
| content: Text('微信登录失败: $error'), |
Copilot uses AI. Check for mistakes.
|
|
||
| // 刷新Family列表 | ||
| ref.refresh(userFamiliesProvider); | ||
| final _ = ref.refresh(userFamiliesProvider); |
Copilot
AI
Sep 30, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using underscore assignments for ignored return values is unnecessary and reduces code clarity. Simply call the methods without assignment: ref.refresh(userFamiliesProvider);
Copilot uses AI. Check for mistakes.
| if (!context.mounted) return; | ||
| ref.refresh(currentFamilyProvider); | ||
| if (!mounted) return; | ||
| final _ = ref.refresh(currentFamilyProvider); |
Copilot
AI
Sep 30, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using underscore assignments for ignored return values is unnecessary and reduces code clarity. Simply call the methods without assignment: ref.refresh(userFamiliesProvider);
Copilot uses AI. Check for mistakes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
本次 PR 很好地实践了在 await 调用之前捕获依赖 BuildContext 的对象,以避免异步调用后使用 BuildContext 可能引发的问题,这对于应用的健壮性是很好的提升。在 theme_share_dialog.dart、delete_family_dialog.dart 和 login_screen.dart 中的修改都很好。不过,我在 login_screen.dart 中发现了几处关键的字符串插值问题,以及在 qr_code_generator.dart 中有一处轻微的性能退步。请查看我的具体评论。
| SnackBar( | ||
| content: | ||
| Text('欢迎回来,${result.userData?.username}!'), | ||
| content: Text('欢迎回来,\${result.userData?.username}!'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| messenger.showSnackBar( | ||
| SnackBar( | ||
| content: Text('微信登录失败: $error'), | ||
| content: Text('微信登录失败: \$error'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| child: Center( | ||
| child: const CircularProgressIndicator(), | ||
| ), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pre-fetch navigator/messenger, guard mounted after awaits in dialogs and auth screen. Files: widgets/theme_share_dialog.dart, widgets/dialogs/delete_family_dialog.dart, screens/auth/login_screen.dart. Also removes an unused test import. Tests: flutter test all green. Links: #72.