To log a user in/out of your app, you should use the logIn and logOut methods rather than calling Purchases.setup multiple times. The setup method is meant to be called once, at the start of your app. That’s because it does a lot of setup that is required on iOS and Android to detect purchases made outside of your app (e.g. via App Store promoted in-app purchases.) So it doesn’t make sense to run all of that code multiple times.
To log in:
await Purchases.logIn(appUserId); // Fetches appUserId's info from RevenueCat
To log out:
await Purchases.logOut(); // clears local user data and creates an anonymous user
If you’re using v3.3.1 or earlier of the Flutter SDK then you need to use identify and reset:
await Purchases.identify(appUserId); // Fetches appUserId's info from RevenueCat
await Purchases.reset(); // clears local user data and identifies as an anonymous user
You can (and should) call logOut whenever a user logs out and logIn whenever a new user logs in. Calling logOut wipes the cache on the device and resets RevenueCat to a near-fresh state, so it’s accomplishing what you’re trying to do by calling init multiple times.
For more information, take a look at our guide on identifying users.