Skip to content

Conversation

zensgit
Copy link
Owner

@zensgit zensgit commented Sep 30, 2025

Capture ScaffoldMessenger before awaits; guard mounted; no behavior changes. Files: widgets/common/right_click_copy.dart, widgets/custom_theme_editor.dart. Tests: all green.

… mounted in ThemeShareDialog, DeleteFamilyDialog, LoginScreen; remove unused test import
… duplicated lines and define messenger/router captures
…s in color_picker_dialog, refreshable_list, currency_converter
…; custom_theme_editor mounted guard and messenger reuse
@Copilot Copilot AI review requested due to automatic review settings September 30, 2025 05:53
@zensgit zensgit enabled auto-merge (squash) September 30, 2025 05:53
@gemini-code-assist
Copy link

Summary of Changes

Hello @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 组件的健壮性改进。它确保在异步操作之前安全地访问 ScaffoldMessengerGoRouter 上下文,并检查小部件的 mounted 状态,从而防止潜在的运行时错误。此外,它还包含一份全面的报告,详细说明了之前拉取请求的 CI 失败解决方案,为过去的调试工作提供了宝贵的见解。

Highlights

Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@Copilot Copilot AI left a 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);
Copy link

Copilot AI Sep 30, 2025

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}!'),
Copy link

Copilot AI Sep 30, 2025

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'),
Copy link

Copilot AI Sep 30, 2025

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'.

Suggested change
content: Text('微信登录失败: \$error'),
content: Text('微信登录失败: $error'),

Copilot uses AI. Check for mistakes.

Copy link

@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 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}!'),

Choose a reason for hiding this comment

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

high

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.

Suggested change
content: Text('欢迎回来,\${result.userData?.username}!'),
content: Text('欢迎回来,${result.userData?.username}!'),

messenger.showSnackBar(
SnackBar(
content: Text('微信登录失败: $error'),
content: Text('微信登录失败: \$error'),

Choose a reason for hiding this comment

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

high

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.

Suggested change
content: Text('微信登录失败: \$error'),
content: Text('微信登录失败: $error'),


ScaffoldMessenger.of(context).showSnackBar(
final messenger = ScaffoldMessenger.of(context);
messenger.showSnackBar(

Choose a reason for hiding this comment

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

medium

There's an extra indentation on this line, which is inconsistent with the surrounding code style. Please remove the extra spaces to improve code readability and maintain a consistent format.

Suggested change
messenger.showSnackBar(
messenger.showSnackBar(

@zensgit zensgit merged commit 64c8f3a into main Oct 8, 2025
7 checks passed
@zensgit zensgit deleted the flutter/context-cleanup-batch6 branch October 8, 2025 02:46
@zensgit zensgit mentioned this pull request Oct 15, 2025
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.

1 participant