Can I disable a specific dependency for Flutter web?

Viewed 443

I'm usingAdMob and Google Mobile Ads package for my flutter app and it works fine on iOS and Android, but as I understood it can't be used on flutter web and when I try to run my code on web it throws an exception for that dependency not being initialized. Is there a way to disable that dependency only for Flutter web? Or if there is a way to implement Google Ads on web?

Thank you

1 Answers

You can do something like below

import 'package:flutter/foundation.dart' show kIsWeb;

if (kIsWeb) {
  // Do nothing
} else {
  // Init Your dependency
}
Related