Closed redimongo closed 4 years ago
@redimongo Hi there!
Good to see you're making a 'static wrapper' class. It's almost finished but 'AdEventListener' isn't a type. It is not defined.
Change the following line: static AdEventListener _eventListener = (MobileAdEvent event) {
To this line: static MobileAdListener _eventListener = (MobileAdEvent event) {
Are you sure about that comment above? as
AdEventListener listener
,
is in the static void showBanner(
/// Assign a listener.
static AdEventListener _eventListener = (MobileAdEvent event) {
if (event == MobileAdEvent.clicked) {
print("The opened ad is clicked on.");
}
};
static void showBanner(
{String adUnitId,
AdSize size,
List<String> keywords,
String contentUrl,
bool childDirected,
List<String> testDevices,
bool testing,
AdEventListener listener,
Yes it is found in the wrapper code you wrote, but you didn't define it. You're error message even says so: "... Error: 'AdEventListener' isn't a type."
What happens when you change the line?
The type, AdEventListener, was found in old versions of the library, but replaced by a MobileAdListener
Future<bool> showBannerAd({
String adUnitId,
MobileAdTargetingInfo targetInfo,
List<String> keywords,
String contentUrl,
bool childDirected,
List<String> testDevices,
bool testing,
MobileAdListener listener,
AdSize size,
double anchorOffset,
double horizontalCenterOffset,
AnchorType anchorType,
State state,
Ensure you're using the most 'up-to-date' library package with the following in your pubspec.yaml:
dependencies:
ads:^1.0.0
So I copied the following code and yes I changed my admob appId
however, I cant seem to call a test ad when i import the ad.dart file into the script.
I want to show the Banner on my news articles. You can see AppAds.showBannerAd(); but it brings an error
Compiler message: lib/model/ads.dart:19:10: Error: Type 'AdEventListener' not found. static AdEventListener _eventListener = (MobileAdEvent event) { ^^^^^^^^^^^^^^^ lib/model/ads.dart:33:9: Error: Type 'AdEventListener' not found. AdEventListener listener, ^^^^^^^^^^^^^^^ lib/screens/newswidget.dart:156:12: Error: Method not found: 'AppAds.showBannerAd'. AppAds.showBannerAd(); ^^^^^^^^^^^^ lib/model/ads.dart:19:10: Error: 'AdEventListener' isn't a type. static AdEventListener _eventListener = (MobileAdEvent event) { ^^^^^^^^^^^^^^^ lib/model/ads.dart:33:9: Error: 'AdEventListener' isn't a type. AdEventListener listener,