From 6c72e7fb8f11557bd81ec9667fa45de381be383a Mon Sep 17 00:00:00 2001 From: toly <1981462002@qq.com> Date: Tue, 18 Apr 2023 09:41:37 +0800 Subject: [PATCH] =?UTF-8?q?=E7=8A=B6=E6=80=81=E6=95=B0=E6=8D=AE=E4=B8=8E?= =?UTF-8?q?=E7=95=8C=E9=9D=A2=E6=9B=B4=E6=96=B0=20-1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/guess/guess_page.dart | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/lib/guess/guess_page.dart b/lib/guess/guess_page.dart index 3be9140..cfbf9c1 100644 --- a/lib/guess/guess_page.dart +++ b/lib/guess/guess_page.dart @@ -18,10 +18,13 @@ class _GuessPageState extends State { int _value = 0; Random _random = Random(); + bool _guessing = false; void _generateRandomValue() { setState(() { + _guessing = true; _value = _random.nextInt(100); + print(_value); }); } @@ -31,22 +34,21 @@ class _GuessPageState extends State { appBar: GuessAppBar(), body: Stack( children: [ - Column( - children: [ - ResultNotice(color:Colors.redAccent,info:'大了'), - ResultNotice(color:Colors.blueAccent,info:'小了'), - ], - ), + // Column( + // children: [ + // ResultNotice(color:Colors.redAccent,info:'大了'), + // ResultNotice(color:Colors.blueAccent,info:'小了'), + // ], + // ), Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ - const Text( - '点击生成随机数值', - ), + if(!_guessing) + const Text('点击生成随机数值',), Text( - '$_value', - style: Theme.of(context).textTheme.headlineMedium, + _guessing ? '**' : '$_value', + style: const TextStyle(fontSize: 68, fontWeight: FontWeight.bold), ), ], ), @@ -54,7 +56,8 @@ class _GuessPageState extends State { ], ), floatingActionButton: FloatingActionButton( - onPressed: _generateRandomValue, + onPressed: _guessing?null:_generateRandomValue, + backgroundColor: _guessing ? Colors.grey : Colors.blue, tooltip: 'Increment', child: const Icon(Icons.generating_tokens_outlined), ),