-
Notifications
You must be signed in to change notification settings - Fork 0
flutter: context cleanup batch 6 — right_click_copy + custom_theme_editor #76
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
…s in color_picker_dialog, refreshable_list, currency_converter
…; custom_theme_editor mounted guard and messenger reuse
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 上下文清理和多个 UI 组件的健壮性改进。它确保在异步操作之前安全地访问 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 for better asynchronous handling patterns. It captures ScaffoldMessenger references before async operations and uses mounted checks instead of context.mounted to prevent widget lifecycle issues.
- Capture ScaffoldMessenger before await operations to avoid context usage after disposal
- Replace context.mounted with mounted for StatefulWidget lifecycle checks
- Remove unnecessary const keywords from SizedBox widgets with dynamic properties
Reviewed Changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| jive-flutter/test/transactions/transaction_list_grouping_widget_test.dart | Remove unused import |
| jive-flutter/lib/widgets/theme_share_dialog.dart | Context cleanup with ScaffoldMessenger capture and mounted checks |
| jive-flutter/lib/widgets/states/loading_indicator.dart | Remove const from SizedBox with dynamic size |
| jive-flutter/lib/widgets/qr_code_generator.dart | Remove const from Center widgets with dynamic properties |
| jive-flutter/lib/widgets/dialogs/delete_family_dialog.dart | Context cleanup with Navigator/ScaffoldMessenger capture |
| jive-flutter/lib/widgets/custom_theme_editor.dart | Context cleanup with ScaffoldMessenger capture |
| jive-flutter/lib/widgets/currency_converter.dart | Remove const from SizedBox with dynamic properties |
| jive-flutter/lib/widgets/common/right_click_copy.dart | Move ScaffoldMessenger capture before async operation |
| jive-flutter/lib/widgets/common/refreshable_list.dart | Remove const from SizedBox with dynamic height |
| jive-flutter/lib/widgets/color_picker_dialog.dart | Remove const from SizedBox with dynamic properties |
| jive-flutter/lib/screens/auth/login_screen.dart | Context cleanup with router/messenger capture and string interpolation fixes |
| PR_71_FIX_REPORT.md | Documentation file - no code changes |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| } | ||
|
|
||
| Future<void> _generateShareLink() async { | ||
| final messenger = ScaffoldMessenger.of(context); |
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.
Consider using ScaffoldMessenger.maybeOf(context) instead of ScaffoldMessenger.of(context) to handle cases where there might not be a Scaffold ancestor, which would prevent potential exceptions.
Copilot uses AI. Check for mistakes.
| 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. The backslashes should be removed to enable proper variable interpolation: '${result.userData?.username}' should be '${result.userData?.username}' and '$error' should be '$error'.
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. The backslashes should be removed to enable proper variable interpolation: '${result.userData?.username}' should be '${result.userData?.username}' and '$error' should be '$error'.
| content: Text('微信登录失败: \$error'), | |
| content: Text('微信登录失败: $error'), |
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
This pull request focuses on context cleanup, primarily by capturing ScaffoldMessenger and Navigator instances before await calls to avoid using BuildContext across async gaps. This is a great improvement for the robustness of the UI code.
The changes are well-implemented, and I've found only a couple of minor issues:
- In
login_screen.dart, there are two instances of incorrect string interpolation due to an escaped dollar sign, which would lead to incorrect text being displayed to the user. - In
custom_theme_editor.dart, there is a minor indentation issue.
I've left specific comments with suggestions for these points. Overall, this is a solid refactoring effort.
| 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.
The dollar sign $ in the string interpolation is escaped, which will cause it to be displayed literally in the UI (e.g., 欢迎回来,${result.userData?.username}!) instead of interpolating the variable. Please remove the backslash to fix the string interpolation.
| content: Text('欢迎回来,\${result.userData?.username}!'), | |
| content: Text('欢迎回来,${result.userData?.username}!'), |
| 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.
The dollar sign $ in the string interpolation is escaped. This will cause the literal string \$error to be displayed instead of the value of the error variable. Please remove the backslash to correctly display the error message.
| content: Text('微信登录失败: \$error'), | |
| content: Text('微信登录失败: $error'), |
|
|
||
| ScaffoldMessenger.of(context).showSnackBar( | ||
| final messenger = ScaffoldMessenger.of(context); | ||
| messenger.showSnackBar( |
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.
Capture ScaffoldMessenger before awaits; guard mounted; no behavior changes. Files: widgets/common/right_click_copy.dart, widgets/custom_theme_editor.dart. Tests: all green.