'Unable to update value: tween of TweenAnimationBuilder Flutter

I am trying to show countdown timer in my project app. First when user open a screen they can choose the duration of count down time by showing the radio button (10 minutes, 20 minutes, or 30 minutes). First I choose to show a timer with 10 minutes duration and it works fine, but when I try to change the duration into another duration, the value of tween (begin and end) doesn't update. Is there a way to update the value of tween? I have tried to update the value from showTimerModel but it's still fail: Here is part of the code:

ValueListenableBuilder(
                        valueListenable: showTimerModel,
                        builder: (_, value, __) {
                          return Column(
                            crossAxisAlignment: CrossAxisAlignment.center,
                            children: [
                              showTimerModel.value.showTimer
                                  ? TweenAnimationBuilder<Duration>(
                                      duration: Duration(
                                          minutes:
                                              showTimerModel.value.duration),
                                      tween: Tween(
                                          begin: Duration(
                                              minutes: showTimerModel
                                                  .value.duration),
                                          end: Duration.zero),
                                      onEnd: () async {
                                        setState(() {
                                          play = !play;
                                        });
                                        await playerA.stop();
                                        showTimerModel.value = PlayerModel(
                                            showTimer: false,
                                            duration:
                                                showTimerModel.value.duration);
                                        // showTimer.value = false;
                                      },
                                      builder: (BuildContext context,
                                          Duration value, Widget? child) {
                                        final minutes = value.inMinutes;
                                        final seconds = value.inSeconds % 60;
                                        return Padding(
                                            padding: const EdgeInsets.symmetric(
                                                vertical: 5),
                                            child: Text('$minutes:$seconds',
                                                textAlign: TextAlign.center,
                                                style: TextStyle(
                                                    color: Colors.black,
                                                    fontWeight:
                                                        FontWeight.bold)));
                                      })
                                  : Container(),
                              InkWell(
                                onTap: () {
                                  addingTimer();
                                },
                                child: Icon(Icons.timer,
                                    color: Colors.black, size: 30),
                              ),
                            ],
                          );
                        }),

and here is the way I try to edit the value:

Widget radioButton(String time, int value, int duration) {
    return RadioListTile(
      value: value,
      groupValue: groupValue,
      onChanged: (int? val) {
        setState(() {
          groupValue = val!;
        });

        showTimerModel.value = PlayerModel(showTimer: true, duration: duration);
        Navigator.of(context).pop();
      },
      title: Text(time),
    );
  }


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source