'How to not change the state in widget that shared in two differents Tabs

I'm creating an app and I'm using AutoTabs so I can have different widget tree and be able to move between them without losing state from one tree to another.

I have a small problem and it is that when I share the same widget in two trees and change the state of one, using a StateNotifier, it is logically changed also in the other.

For example, I'm on Tab1 on a page that is an article searched and I move to Tab2 and navigate to the page to find an article that is shared, How can I do so that when changing the state of the searched in Tab1, the state is not modified on the same page but in Tab2? being able to share the max code



Solution 1:[1]

It sounds like you're using Riverpod to represent local widget state.
Riverpod is about shared state. So the state being shared between widgets is logical

If you don't want that, you can use a normal StatefulWidget, or flutter_hook's HookWidget

Solution 2:[2]

if you don't want to lose your state. you can use IndexedStack widget

Sources

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

Source: Stack Overflow

Solution Source
Solution 1 Rémi Rousselet
Solution 2 Hadi