fix(mining-app): 强制用 Future.delayed+hideCurrentSnackBar 关闭提示
Flutter SnackBar duration 在某些版本不可靠,改为手动延迟后强制关闭。 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
acc5c2be80
commit
e4a2690130
|
|
@ -86,12 +86,13 @@ class _LoginPageState extends ConsumerState<LoginPage> {
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
} else if (message.contains('还剩')) {
|
} else if (message.contains('还剩')) {
|
||||||
// 密码错误但还有机会 → SnackBar 提醒 + 找回密码入口
|
// 密码错误但还有机会 → SnackBar 提醒 + 找回密码入口(4秒后强制关闭)
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
final messenger = ScaffoldMessenger.of(context);
|
||||||
|
messenger.showSnackBar(
|
||||||
SnackBar(
|
SnackBar(
|
||||||
content: Text(message),
|
content: Text(message),
|
||||||
backgroundColor: Colors.orange.shade800,
|
backgroundColor: Colors.orange.shade800,
|
||||||
duration: const Duration(seconds: 5),
|
duration: const Duration(seconds: 4),
|
||||||
action: SnackBarAction(
|
action: SnackBarAction(
|
||||||
label: '找回密码',
|
label: '找回密码',
|
||||||
textColor: Colors.white,
|
textColor: Colors.white,
|
||||||
|
|
@ -99,10 +100,15 @@ class _LoginPageState extends ConsumerState<LoginPage> {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
Future.delayed(const Duration(seconds: 4), () {
|
||||||
|
messenger.hideCurrentSnackBar();
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
final messenger = ScaffoldMessenger.of(context);
|
||||||
SnackBar(content: Text(message)),
|
messenger.showSnackBar(SnackBar(content: Text(message)));
|
||||||
);
|
Future.delayed(const Duration(seconds: 3), () {
|
||||||
|
messenger.hideCurrentSnackBar();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue