'Force views to replace instead of stack

I am rendering views based on true/false. In both views I have stream listeners and the dispose method doesn't trigger at all. Is it because I am using a Stack widget? I've tried changing it to column but I am getting Failed assertion: line 588 pos 12: 'size.isFinite': is not true. How do I make sure both of the Gmap widgets are being disposed properly?

    body: Stack(children: [
              AnimatedSwitcher(
                  child: context.watch<UseAuth>().userStarted == true
                      ? const GmapStarted()
                      : const Gmap(),
                  duration: const Duration(seconds: 1)),
            ])),


Sources

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

Source: Stack Overflow

Solution Source