How to use npm packages inside dart code?

5,284

Dart and Javascript are different programming languages. While it might be possible to transpile you lib from js to dart, it is not easily doable, nor maintainable, and most likely not generalisable.

Unless you are comfortable with both languages and their limitations, you should not try to convert an NPM package to some Dart code unless you don't have any other choice.

I would advise you to rewrite the NPM package in Dart instead.

REMARK : this answer is based on the hypothesis that you don't want to integrate JS code in a webview but actually use the code inside the Dart VM.

Share:
5,284
Waqar Ul Khaf
Author by

Waqar Ul Khaf

Updated on December 11, 2022

Comments

  • Waqar Ul Khaf
    Waqar Ul Khaf over 1 year

    I have a flutter application running on the Dart programming language. I have published an npm package that I want to use in my flutter application. Is there any way I can use the existing npm package in dart or somehow automatically convert npm package to dart package?