title: Flutter : didUpdateWidget not giving old value of oldWidget
body: <p>I've horizontal list, in which i need to update value for each row. As, it will call didUpdateWidget every time once it's initialized once, we should get old widgets value to match. Issue is i'm not getting oldWidget's value, every time it's providing updated value.</p>
  <p>Here, i've attached image for reference.
  <a href="https://i.stack.imgur.com/v9jYP.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/v9jYP.png" alt="enter image description here" /></a></p>
  <p>It's dynamic list, where if one item is selected it will show same as first item with animation and other should show with down value.
  Listview Snippet :</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>   controller.categories.isNotEmpty
                          ? SizedBox(
                              height: 110.h,
                              child: ListView.builder(
                                shrinkWrap: true,
                                scrollDirection: Axis.horizontal,
                                itemCount: controller.categories.length,
                                itemBuilder: (BuildContext context, int index) {
                                  return SpecialMealTile(
                                    index: index,
                                    categories: controller.categories[index],
                                  );
                                },
                              ),
                            )
                          : const SizedBox.shrink(),</code></pre>
  </div>
  </div>
  </p>
  <p>Tile Snippet:</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>class SpecialMealTile extends StatefulWidget {
    final int index;
    final Categories categories;
  
    SpecialMealTile({
      Key? key,
      required this.index,
      required this.categories,
    }) : super(key: key);
  
    @override
    State&lt;SpecialMealTile&gt; createState() =&gt; _SpecialMealTileState();
  }
  
  class _SpecialMealTileState extends State&lt;SpecialMealTile&gt;
      with TickerProviderStateMixin {
    late AnimationController _animationController;
    late Animation _colorTween;
    late AnimationController _controller;
    late Animation&lt;double&gt; _animation;
    bool upDown = true;
    final InFlightMealController _inFlightMealController = Get.find();
    late Categories _oldCategory;
  
    @override
    void initState() {
      _controller = AnimationController(
        vsync: this,
        duration: const Duration(seconds: 1),
      );
      _animation = CurvedAnimation(
        parent: _controller,
        curve: const Interval(0.0, 1.0, curve: Curves.decelerate),
      );
      _animationController = AnimationController(
        vsync: this,
        duration: const Duration(milliseconds: 1000),
      );
      _colorTween = ColorTween(begin: ThemeColor.white, end: ThemeColor.darkBlue)
          .animate(_animationController);
      // _up(_inFlightMealController.categories[widget.index]!.isSelected);
      _oldCategory = widget.categories;
  
      log("--Come--Category---&gt;&gt;&gt;&gt;&gt;&gt; ${widget.categories.isSelected.toString()}");
      super.initState();
    }
  
    @override
    void didUpdateWidget(covariant SpecialMealTile oldWidget) {
      // print('in did update NEW dependencies' +
      //     widget.categories.isSelected.toString());
      // print(
      //     'in did update OLD dependencies' + _oldCategory.isSelected.toString());
  
      // if (oldWidget.categories.isSelected != widget.categories.isSelected) {
  
      _up(_inFlightMealController.categories[widget.index].isSelected);
  
      log("--Old--Category---&gt;&gt;&gt;&gt;&gt;&gt; ${_oldCategory.isSelected}");
      // }
      // print(inFlightMealController.categories[widget.index]!.isSelected);
      super.didUpdateWidget(oldWidget);
    }
  
    @override
    void didChangeDependencies() {
      super.didChangeDependencies();
    }
  
    @override
    Widget build(BuildContext context) {
      return GestureDetector(
        onTap: () {
          _onTap();
        },
        child: _childWidget(),
      );
    }
  
    void _onTap() {
      _inFlightMealController.showNourishSpecial.value =
          !_inFlightMealController.showNourishSpecial.value;
      _inFlightMealController.showHalalFood.value =
          !_inFlightMealController.showHalalFood.value;
  
      Future.delayed(const Duration(milliseconds: 300), () {
        setState(() {
          _inFlightMealController.showNourishSpecial.value =
              !_inFlightMealController.showNourishSpecial.value;
        });
      });
  
      if (_animationController.status == AnimationStatus.completed) {
        _animationController.reverse();
      } else {
        _animationController.forward();
      }
      _inFlightMealController.selectedMeal.value = _inFlightMealController
          .inFlightModel.value.categories![widget.index].categoryInfo!.name!;
      _inFlightMealController.selectedMealIndex.value = widget.index;
  
      for (int i = 0; i &lt; _inFlightMealController.categories.length; i++) {
        if (i == widget.index) {
          if (_inFlightMealController.categories[i].isSelected) {
            _inFlightMealController.categories[i].isSelected = false;
          } else {
            _inFlightMealController.categories[i].isSelected = true;
          }
        } else {
          _inFlightMealController.categories[i].isSelected = false;
        }
      }
      // _inFlightMealController.categories.refresh();
    }
  
    Widget _childWidget() {
      return Container(
        width: 108.w,
        margin: ltrb(right: 10),
        decoration: BoxDecoration(
          color: HexColor(_inFlightMealController
              .categories[widget.index].categoryInfo!.color!),
          borderRadius: const BorderRadius.all(
            Radius.circular(25),
          ),
        ),
        child: Stack(
          children: [
            AnimatedBuilder(
              animation: _animation,
              builder: (BuildContext context, Widget? child) {
                return Positioned(
                  bottom: 0.0,
                  child: Container(
                    alignment: Alignment.bottomCenter,
                    child: Column(
                      mainAxisSize: MainAxisSize.min,
                      children: [
                        Container(
                          width: 25.w,
                          height: 3.h,
                          decoration: BoxDecoration(
                            color: HexColor.darken(HexColor(
                                _inFlightMealController.categories[widget.index]
                                    .categoryInfo!.color!)),
                            borderRadius: const BorderRadius.all(
                              Radius.circular(2),
                            ),
                          ),
                        ),
                        HeightSizedBox(8),
                        Container(
                          width: 108.w,
                          height: 90.h * _animation.value == 0
                              ? 20.h
                              : 90.h * _animation.value,
                          decoration: BoxDecoration(
                            color: HexColor.darken(HexColor(
                                _inFlightMealController.categories[widget.index]
                                    .categoryInfo!.color!)),
                            borderRadius: const BorderRadius.only(
                              bottomLeft: Radius.circular(25),
                              bottomRight: Radius.circular(25),
                            ),
                          ),
                        )
                      ],
                    ),
                  ),
                );
              },
            ),
            Align(
              child: AnimatedBuilder(
                animation: _colorTween,
                builder: (BuildContext context, Widget? child) =&gt; Text(
                  _inFlightMealController
                          .categories[widget.index].categoryInfo!.name ??
                      "",
                  style: AppFont.SubTitle1_Medium(
                      color: _colorTween.value, size: 12.sp),
                  textAlign: TextAlign.center,
                ),
              ),
              alignment: Alignment.center,
            ),
          ],
        ),
      );
    }
  
    void _up(bool upDown) {
      if (upDown) {
        upDown = false;
        _controller.forward(from: 0.0);
      } else {
        upDown = true;
        _controller.reverse(from: 1.0);
      }
      /* setState(() {
  
      });*/
    }
  }</code></pre>
  </div>
  </div>
  </p>