fix: use_build_context_synchronously 解消
_reanalyze で nav / messenger を async gap 前にキャプチャするよう移動。 showDialog の context 引数を ignore 対象行に統合。 dart analyze: No issues found Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
2e770ff98d
commit
1a84163654
|
|
@ -302,6 +302,10 @@ class _SakeDetailScreenState extends ConsumerState<SakeDetailScreen> {
|
||||||
// 1. Check Locks
|
// 1. Check Locks
|
||||||
if (_isAnalyzing) return;
|
if (_isAnalyzing) return;
|
||||||
|
|
||||||
|
// async gap 前に context 依存オブジェクトをキャプチャ
|
||||||
|
final nav = Navigator.of(context);
|
||||||
|
final messenger = ScaffoldMessenger.of(context);
|
||||||
|
|
||||||
// 2. Check Quota Lockout
|
// 2. Check Quota Lockout
|
||||||
final quotaLockout = ref.read(quotaLockoutProvider);
|
final quotaLockout = ref.read(quotaLockoutProvider);
|
||||||
if (quotaLockout != null) {
|
if (quotaLockout != null) {
|
||||||
|
|
@ -309,7 +313,7 @@ class _SakeDetailScreenState extends ConsumerState<SakeDetailScreen> {
|
||||||
if (remaining.isNegative) {
|
if (remaining.isNegative) {
|
||||||
ref.read(quotaLockoutProvider.notifier).set(null);
|
ref.read(quotaLockoutProvider.notifier).set(null);
|
||||||
} else {
|
} else {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
messenger.showSnackBar(
|
||||||
SnackBar(content: Text('AI利用制限中です。あと${remaining.inSeconds}秒お待ちください。')),
|
SnackBar(content: Text('AI利用制限中です。あと${remaining.inSeconds}秒お待ちください。')),
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
|
|
@ -326,8 +330,6 @@ class _SakeDetailScreenState extends ConsumerState<SakeDetailScreen> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!mounted) return;
|
if (!mounted) return;
|
||||||
final nav = Navigator.of(context);
|
|
||||||
final messenger = ScaffoldMessenger.of(context);
|
|
||||||
|
|
||||||
if (existingPaths.isEmpty) {
|
if (existingPaths.isEmpty) {
|
||||||
messenger.showSnackBar(
|
messenger.showSnackBar(
|
||||||
|
|
@ -340,12 +342,7 @@ class _SakeDetailScreenState extends ConsumerState<SakeDetailScreen> {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// ignore: use_build_context_synchronously
|
// ignore: use_build_context_synchronously
|
||||||
// mounted チェック済み(334行目)かつ await なしで呼び出すため安全
|
showDialog(context: context, barrierDismissible: false, builder: (context) => const AnalyzingDialog());
|
||||||
showDialog(
|
|
||||||
context: context,
|
|
||||||
barrierDismissible: false,
|
|
||||||
builder: (context) => const AnalyzingDialog(),
|
|
||||||
);
|
|
||||||
|
|
||||||
final geminiService = ref.read(geminiServiceProvider);
|
final geminiService = ref.read(geminiServiceProvider);
|
||||||
final result = await geminiService.analyzeSakeLabel(existingPaths, forceRefresh: true);
|
final result = await geminiService.analyzeSakeLabel(existingPaths, forceRefresh: true);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue