"This AdWidget is already in the Widget tree" — It Only Crashed After One Specific Flow
The Error I was working on a Flutter app that uses google_mobile_ads for banner ads. One day, I got this error on the MyPage screen: This AdWidget is already in the Widget tree Make sure you are no...

Source: DEV Community
The Error I was working on a Flutter app that uses google_mobile_ads for banner ads. One day, I got this error on the MyPage screen: This AdWidget is already in the Widget tree Make sure you are not using the same ad object in more than one AdWidget. The error message was clear. But the weird thing was — it didn't always happen. Finding the Pattern I tested different scenarios and found a pattern: Switch tabs normally → no crash Go to another page and come back → no crash Update address → go back to main page → open MyPage tab → crash So the question became: what's different about the address update flow? What Was Different The app uses BottomNavigationBar with IndexedStack. After the address update, the code navigated back to the main page like this: Navigator.push( context, MaterialPageRoute(builder: (context) => MainPage()), ); This looks normal. But Navigator.push adds a new page on top of the stack. It does not remove the old one. So the old MainPage — and the old MyPage inside