Skip to content

Commit

Permalink
prevent ads from being reloaded (#129)
Browse files Browse the repository at this point in the history
  • Loading branch information
brnostone authored Feb 10, 2020
1 parent b5c5bd5 commit 97b0000
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/src/admob_banner.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class AdmobBanner extends StatefulWidget {
}

class _AdmobBannerState extends State<AdmobBanner> {
UniqueKey _key = UniqueKey();
AdmobBannerController _controller;

@override
Expand All @@ -33,28 +34,28 @@ class _AdmobBannerState extends State<AdmobBanner> {
width: widget.adSize.width >= 0 ? widget.adSize.width.toDouble() : double.infinity,
height: widget.adSize.height >= 0 ? widget.adSize.height.toDouble() : double.infinity,
child: AndroidView(
key: UniqueKey(),
key: _key,
viewType: 'admob_flutter/banner',
creationParams: <String, dynamic>{
"adUnitId": widget.adUnitId,
"adSize": widget.adSize.toMap,
},
creationParamsCodec: StandardMessageCodec(),
creationParamsCodec: const StandardMessageCodec(),
onPlatformViewCreated: _onPlatformViewCreated,
),
);
} else if (defaultTargetPlatform == TargetPlatform.iOS) {
return Container(
key: UniqueKey(),
width: widget.adSize.width.toDouble(),
height: widget.adSize.height.toDouble(),
child: UiKitView(
key: _key,
viewType: 'admob_flutter/banner',
creationParams: <String, dynamic>{
"adUnitId": widget.adUnitId,
"adSize": widget.adSize.toMap,
},
creationParamsCodec: StandardMessageCodec(),
creationParamsCodec: const StandardMessageCodec(),
onPlatformViewCreated: _onPlatformViewCreated,
),
);
Expand Down

3 comments on commit 97b0000

@benevolent13
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do I use this? Is it published in the latest version?

@kmcgill88
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not in beta yet. You can reference the git hash to use it for now.

@zfc0812
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you. This is finally work! By the way, this is how to reference the git hash. Just add this to pubspec.yaml

admob_flutter:
    git:
      url: https://github.com/kmcgill88/admob_flutter.git

Please sign in to comment.