import_js_library 0.0.1 copy "import_js_library: ^0.0.1" to clipboard
import_js_library: ^0.0.1 copied to clipboard

outdated

Import & use javascript libraries in your flutter web projects

Import JS Library #

Import & use javascript libraries in your flutter web projects.

Created to make it simpler to build Flutter Plugins compatible with web.

Example #

to include howler.js & use it in a flutter web project :

  1. Add the js library in your assets
  2. Declare it inside your pubspec.yaml
flutter:
  assets:
    - assets/howler.js
  1. Anywhere in your Flutter project, import this js lib

For example, on the main.dart

void main() {
  importJsLibrary("./assets/howler.js");
  runApp(MyApp());
}

You can also import it later in a custom class.

  1. Using package:js, wrap your js methods/classes
@JS()
library howl.js;

import 'package:js/js.dart';

@JS("Howl")
class Howl {
  external Howl({List<String> src}); 

  external play();
}
  1. Use your library !
final audio = Howl(src: ["./assets/astronomia.mp3"]);
audio.play();
55
likes
0
pub points
42%
popularity

Publisher

unverified uploader

Import & use javascript libraries in your flutter web projects

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter, flutter_web_plugins, html

More

Packages that depend on import_js_library