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

How to use it with dart libraries that dependes on dart:io? #73

Open
shinayser opened this issue Jan 23, 2020 · 3 comments
Open

How to use it with dart libraries that dependes on dart:io? #73

shinayser opened this issue Jan 23, 2020 · 3 comments

Comments

@shinayser
Copy link

Hello!

I am trying to develop a bot for Telegram and I am using the teledart library from pub dev. But it depends on dart:io since it does some network calls.

There is a way to make it work?

@pulyaevskiy
Copy link
Owner

Looking at the code in teledart repository you'll have to fork it and replace all usages of dart:io with corresponding alternative in node_io package.

Also (luckily) teledart uses package:http which is implemented by node_http so you'll need to replace all usages of it with node_http.

Hopefully this is all that's needed. But there is a chance they use some APIs not covered by this library yet. In which case feel free to let me know and I'll try to help.

@shinayser
Copy link
Author

THanks for you answer @pulyaevskiy!

So to wrap up: I have to fork the library changing the packages to node correpondents and do it recursivelly for each libraries that those packages may depend on?

@shinayser
Copy link
Author

shinayser commented Jan 31, 2020

I went for a different path, using conditional imports and seems to be working until I tried to compile it.
Unfortunatly not all the http and io library features are implemented. I tried to compile to javascript using the node compilers and this was the some of the errors:

Error: 'MultipartFile' isn't a type.
  Future<dynamic> httpMultipartPost(String url, List<http.MultipartFile> files,
                                                          ^^^^^^^^^^^^^
Error: Method not found: 'MultipartRequest'.
    var request = http.MultipartRequest('POST', Uri.parse(url))
                  ^^^^^^^^^^^^^^^^
Error: Method not found: 'HttpServer.bindSecure'.
    Future<dynamic> serverFuture = io.HttpServer.bindSecure(
                                                 ^^^^^^^^^^
-------------------------------------------------------------------------------
Error: Method not found: 'SecurityContext'.
    _context = io.SecurityContext();
               ^^^^^^^^^^^^^^^
Error: Getter not found: 'anyIPv4'.
        io.InternetAddress.anyIPv4.address, port, _context);
                           ^^^^^^^

The teledart library uses a lot of those MultiPart files requests...

Tehre is any workaround you can insight me ?

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

No branches or pull requests

2 participants