-
-
Notifications
You must be signed in to change notification settings - Fork 11
Adding packages
Jonathan Rezende edited this page Apr 11, 2023
·
1 revision
- The version of the package can not be
latest. Please, add a real version there. - Add a test in the
test/d/PACKAGE.dart - Add a library to the main file called
typings.PACKAGEand add a documentation to the library clause with usage example.
Instead of right adding the annotation and executing the builder, try adding the package in the main.dart file and executing dart run.
Check out the main.dart file for an usage example.
The GoJS is a good example to use as base.
- Create a file in
typings/lib/d/PACKAGE.dart - Add an export to
yourpackage/yourpackage.dart - Add an annotation to the export that will guide the package on how to sync from NPM or any other kind of source.
Example:
File /typings/d/gojs.dart
import 'package:typings/annotations.dart';
@Typings.npm(
package: 'gojs', // package name
version: '2.3.5', // the version that should be fetched from NPM
dirName: 'gojs', // the dir name to be created
contextCheck: 'go', // optionally the namespace to be checked in the JS when the JS file is imported
uses: [
'core' // the GoJS uses the core (DOM) types
]
)
export 'gojs/gojs.dart';With this info the builder will automatically fetch the package from NPM, parse the package.json and from there generate the import file and the interop bindings.
Call the builder: dart run --enable-asserts --enable-experiment="inline-class" build_runner build --enable-experiment="inline-class"