Can I disable a specific dependency for Flutter web?

331

You can do something like below

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

if (kIsWeb) {
  // Do nothing
} else {
  // Init Your dependency
}
Share:
331
Admin
Author by

Admin

Updated on December 28, 2022

Comments

  • Admin
    Admin over 1 year

    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