Home > Net >  flutter: google_mobile_ads is not displayed
flutter: google_mobile_ads is not displayed

Time:09-09

When I try to use google_mobile_ads, I get the following text and it does not work. I also tried using adMob_flutter and that one worked fine.

Unhandled Exception: MissingPluginException(No implementation found for method MobileAds#initialize on channel plugins.flutter.io/google_mobile_ads)

This is main.dart file:

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await Firebase.initializeApp();
  MobileAds.instance.initialize();
  runApp((myApp()));
}

How can I solve this problem?

CodePudding user response:

Whenever you add a plugin in your pubspec. yaml, you need to stop the app and re-run it again because the plugin contains native on both platforms.

If it still does not work, then do flutter clean and run.

CodePudding user response:

I was facing the same issue. What I did is wrap everything in MaterialApp and put routes on my main Widget.

runApp( 
MaterialApp( 
routes: 
<String, WidgetBuilder>
{ '/': (BuildContext context) => 
MyApp()}
,)
,);

As for how this works, I don't know how it fix everything but it might help you

  • Related