How do I create a pub package that works with Flutter?
2 answers
To declare a dependency on Flutter, from the pub package add this to yours pubspec.yaml
:
dependencies:
flutter:
sdk: flutter
You should use flutter packages get
instead pub get
because Flutter has to set the appropriate environment variables for sdk: flutter
location mapping .
Use the stagehand tool to quickly and easily create a new pub pack . After installing stagehand follow these instructions:
$ mkdir fancy_project
$ cd fancy_project
$ stagehand package-simple
After creating a new package, edit pubspec.yaml
and add sdk:flutter
as shown above.
+4
source to share