dartdartium

How to create libraries for Dart?


How can I create libraries using Dart?

I want to start porting some JavaScript (and other languages) libraries I've created to Dart.


Solution

  • Just put this in your library file (first place):

    library mylibraryname;
    

    You can then import this lib with:

    import "path/to/mylibraryname.dart";
    

    Other options are available, for example part which acts as include.

    For a more in-depth tutorial I recommend you this blog post from Dartwatch.