Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to make web only injection? #291

Closed
mirkancal opened this issue Jun 6, 2022 · 3 comments
Closed

Is it possible to make web only injection? #291

mirkancal opened this issue Jun 6, 2022 · 3 comments

Comments

@mirkancal
Copy link

I've separated the environments by web and mobile. Both my WebDownloader and MobileDownloader are registered as ImageDownloader(abstract class). But since WebDownloader's file has dart:js and dart:html imports, app throws:

Error: Not found: 'dart:html' errors

Is there any other way to make generated file doesn't import the file with web imports at all?

@leoshusar
Copy link

This has to be done compile time, you have 2 ways (afaik):

  1. use conditional import, explained for example here
  2. create plugin, you will have a package for each platform you want to support with the platform specific code (can also be Dart only) and then one main package with the abstract interface. Compiler will then use the correct platform package.

First way is simpler for things like single class, but I think you will have to name those classes the same (you cannot have one named Mobile and the other Web I believe). With the second way wou'll have much more flexibility, but might be overkill for your need.

@mkysel
Copy link

mkysel commented Nov 12, 2022

@github-actions
Copy link

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants