public override void paint(PaintingContext context, Offset offset)
        {
            List <RenderBox> children = getChildrenAsList();

            // Paint thumb if highlightedIndex is not null.
            if (highlightedIndex != null)
            {
                if (_childAnimations == null)
                {
                    _childAnimations = new Dictionary <RenderBox, _ChildAnimationManifest>();//<RenderBox, _ChildAnimationManifest> { };
                    for (int i = 0; i < childCount - 1; i += 1)
                    {
                        bool      shouldFadeOut = i == highlightedIndex || i == highlightedIndex - 1;
                        RenderBox child         = children[i];
                        _childAnimations[child] = new _ChildAnimationManifest(separatorOpacity: shouldFadeOut ? 0 : 1);
                    }
                }

                RenderBox selectedChild = children[highlightedIndex ?? 0];

                _SlidingSegmentedControlContainerBoxParentData childParentData =
                    selectedChild.parentData as _SlidingSegmentedControlContainerBoxParentData;
                Rect unscaledThumbTargetRect = CupertinoSlidingSegmentedControlsUtils._kThumbInsets.inflateRect(childParentData.offset & selectedChild.size);

                // Update related Tweens before animation update phase.
                if (_needsThumbAnimationUpdate)
                {
                    // Needs to ensure _currentThumbRect is valid.
                    _currentThumbTween = new RectTween(begin: currentThumbRect ?? unscaledThumbTargetRect, end: unscaledThumbTargetRect);

                    for (int i = 0; i < childCount - 1; i += 1)
                    {
                        bool      shouldFadeOut          = i == highlightedIndex || i == highlightedIndex - 1;
                        RenderBox child                  = children[i];
                        _ChildAnimationManifest manifest = _childAnimations[child];
                        D.assert(manifest != null);
                        manifest.separatorTween = new FloatTween(
                            begin: manifest.separatorOpacity,
                            end: shouldFadeOut ? 0 : 1
                            );
                    }

                    _needsThumbAnimationUpdate = false;
                }
                else if (_currentThumbTween != null && unscaledThumbTargetRect != _currentThumbTween.begin)
                {
                    _currentThumbTween = new RectTween(begin: _currentThumbTween.begin, end: unscaledThumbTargetRect);
                }

                for (int index = 0; index < childCount - 1; index += 1)
                {
                    _paintSeparator(context, offset, children[index]);
                }

                currentThumbRect = _currentThumbTween?.evaluate(state.thumbController)
                                   ?? unscaledThumbTargetRect;

                currentThumbScale = _thumbScaleTween.evaluate(state.thumbScaleController);

                Rect thumbRect = Rect.fromCenter(
                    center: currentThumbRect.center,
                    width: currentThumbRect.width * currentThumbScale,
                    height: currentThumbRect.height * currentThumbScale
                    );

                _paintThumb(context, offset, thumbRect);
            }
            else
            {
                // Reset all animations when there"s no thumb.
                currentThumbRect = null;
                _childAnimations = null;

                for (int index = 0; index < childCount - 1; index += 1)
                {
                    _paintSeparator(context, offset, children[index]);
                }
            }

            for (int index = 0; index < children.Count; index++)
            {
                _paintChild(context, offset, children[index], index);
            }
        }