Skip to content

Commit b67fddd

Browse files
author
Emmanuel Garcia
authored
Fix bug in unmountWidgetAdId (#42)
1 parent 3760ee2 commit b67fddd

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

packages/google_mobile_ads/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
## 0.11.0+2
22

33
* Set min Android version to `19`.
4+
* Fixes bug that displayed "This AdWidget is already in the Widget tree".
45

56
## 0.11.0+1
67

packages/google_mobile_ads/lib/src/ad_instance_manager.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ class AdInstanceManager {
116116
void mountWidgetAdId(int adId) => _mountedWidgetAdIds.add(adId);
117117

118118
/// Indicates that [adId] is unmounted from the widget tree.
119-
void unmountWidgetAdId(int adId) => _mountedWidgetAdIds.add(adId);
119+
void unmountWidgetAdId(int adId) => _mountedWidgetAdIds.remove(adId);
120120

121121
/// Starts loading the ad if not previously loaded.
122122
///

packages/google_mobile_ads/test/ad_containers_test.dart

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,9 @@ void main() {
227227
listener: AdListener(),
228228
request: AdRequest(),
229229
);
230+
231+
await ad.load();
232+
230233
try {
231234
await tester.pumpWidget(
232235
Directionality(
@@ -265,6 +268,9 @@ void main() {
265268
listener: AdListener(),
266269
request: AdRequest(),
267270
);
271+
272+
await ad.load();
273+
268274
final AdWidget widget = AdWidget(ad: ad);
269275
try {
270276
await tester.pumpWidget(
@@ -306,6 +312,7 @@ void main() {
306312
listener: AdListener(),
307313
request: AdRequest(),
308314
);
315+
await ad.load();
309316
final AdWidget widget = AdWidget(ad: ad);
310317
try {
311318
await tester.pumpWidget(
@@ -318,6 +325,9 @@ void main() {
318325
),
319326
),
320327
);
328+
329+
await tester.pumpWidget(Container());
330+
321331
await tester.pumpWidget(
322332
Directionality(
323333
textDirection: TextDirection.ltr,

0 commit comments

Comments
 (0)