Flutter - 按钮内的文字不会改变

Flutter - The text inside the button does not change

我正在创建一个计时器,它有一个播放和暂停按钮,可以更改计时器内的文本,我按下“播放”,计时器开始计时,但是当我暂停时,按钮上的文本和定时器里面的文字没有改变,有人知道为什么吗?

AnimatedBuilder(
                  animation: controller,
                     builder: (context, child) {
                       return Padding(
                         padding: const EdgeInsets.fromLTRB(0, 10, 0, 0),
                         child: FloatingActionButton.extended(
                           backgroundColor: Colors.grey[50],
                             onPressed: () {
                               if (controller.isAnimating){
                                 controller.stop();
                                 }
                               else {
                                 controller.reverse(
                                     from: controller.value == 0.0
                                         ? 1.0
                                         : controller.value);
                               }
                             },
                             icon: Icon(controller.isAnimating
                                 ? Icons.pause
                                 : Icons.play_arrow),
                             label: Text(
                                 controller.isAnimating ? "Pause" : "Play")),
                       );
                     }),

Normal

Couting

Paused

尝试将 controller.stop(); 调用成 setState

像这样:

setState(() {
  controller.stop();
});