vegidio / flutter-appodeal

A Flutter plugin to display ads from Appodeal; it supports consent dialog to track users.
https://pub.dev/packages/appodeal_flutter
MIT License
31 stars 19 forks source link

App crashes while initializing Appodeal in the latest version (1.0.0) #33

Closed ghost closed 3 years ago

ghost commented 3 years ago

Crash Log: Unhandled Exception: type '(dynamic) => Null' is not a subtype of type '((MethodCall) => Future)?' in type cast

0 Appodeal._setCallbacks (package:appodeal_flutter/src/appodeal.dart:126:7)

1 Appodeal.initialize (package:appodeal_flutter/src/appodeal.dart:37:5)

Any fix would be greatly appreciated.

vegidio commented 3 years ago

Thanks for reporting it. Can you share a piece of code that recreates this bug?

ghost commented 3 years ago

This is my entry point in main.dart file and this is how I initialize Appodeal.

`Future mainDelegate() async { SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle( statusBarColor: Colors.transparent, // status bar color statusBarBrightness: Brightness.dark, //status bar brigtness statusBarIconBrightness: Brightness.dark, //status barIcon Brightness systemNavigationBarIconBrightness: Brightness.dark, //navigation bar icon )); Appodeal.setAppKeys( androidAppKey: 'android_api_key', iosAppKey: 'ios_api_key', );

//Crashes here while initialization await Appodeal.initialize( hasConsent: true, adTypes: [AdType.BANNER, AdType.INTERSTITIAL, AdType.REWARD, AdType.NON_SKIPPABLE], testMode: true, verbose: true);

runApp(MyApp()); }`

To debug more, I edited the Appodel library directly and commented out _setCallbacks() function, and removed calling _setCallbacks() function inside initialize() method. Then it worked as expected.

as Future Function(MethodCall)?); - This particular piece of code is added in the latest version at _setCallbacks() method.

I tried out the example project provided in the library. It works fine because it is using version 0.6.0.

vegidio commented 3 years ago

Thanks, I will investigate this later today.

Just curious, why do you think the example project is using version 0.6.0? It actually imports the library directly from the /lib folder.

ghost commented 3 years ago

as Future Function(MethodCall)?); - I couldn't find this piece of code at _setCallbacks() method in the example project and checked pubspec.yaml, it shows the library version is 0.6.0. So I guessed it is using the older version of the library. Correct me if I'm wrong.

SleepyMrPanda commented 3 years ago

Hello, Are there any updates? I have a same issue in 1.0.0.

vegidio commented 3 years ago

@senthamizhraj @SleepyMrPanda Please update your pubspec.yaml file and import appodeal_flutter directly from the bugfix branch that I created (see below). Let me know if the version in this branch fixed the error and I will merge it in case it's working.

appodeal_flutter:
  git:
    url: https://github.com/vegidio-flutter/appodeal.git
    ref: bugfix/set-callback

Thanks.

SleepyMrPanda commented 3 years ago

@vegidio It's working for me.

ghost commented 3 years ago

@vegidio It is working fine now. Thanks for your time.

vegidio commented 3 years ago

Fixed in version 1.0.1