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

Can typings be used in a flutter app targeting iOS/Android? #9

Closed
SunlightBro opened this issue Oct 25, 2023 · 4 comments
Closed

Can typings be used in a flutter app targeting iOS/Android? #9

SunlightBro opened this issue Oct 25, 2023 · 4 comments

Comments

@SunlightBro
Copy link

Creating a flutter example CounterApp and adding typings will not compile to Android.

Maybe I'm missing something, or the pub.dev metadata is wrong and should only state WEB as supported platform.
image

@jodinathan
Copy link
Owner

Typings should work with Flutter.

Is this the problem you are having?

@SunlightBro
Copy link
Author

No I think my issue is maybe a miss-understanding of the capabilities js_interop.

I used ffigen before with C and GoLang, to package a compiled library inside a Flutter-App and call the functions from dart.

That way my Flutter Android/iOS App can call go code directly, which is really useful,
when I just wanna use the official mongoDB go library maintained by the MongoDb-Team.

So when I saw js_interop and typings, I wanted to try to use an npm package,
and call it from my Flutter-Android-App.

@SunlightBro
Copy link
Author

SunlightBro commented Oct 26, 2023

My question is, would it be possible to have a flutter app compile to Andoird/iOS that calls javascript?

import 'package:typings/core.dart' as js;
//...
  void my_dart_function() {
    // Call javascript from dart to calculate the sqrt of 9
    final num sqrtOfNine = js.Math().sqrt(9);
    
    print(sqrtOfNine);
  }

@jodinathan
Copy link
Owner

My question is, would it be possible to have a flutter app compile to Andoird/iOS that calls javascript?

I am no Flutter expert but I think it can with webviews or Flutter Web.

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