pub is Dart's package manager. Flutter is a mobile app SDK that uses Dart. How can I create a package that depends on, or targets, Flutter?
To declare a dependency on Flutter, from a pub package, add this to your pubspec.yaml:
dependencies:
flutter:
sdk: flutter
You must use flutter packages get instead of pub get, because Flutter needs to set the appropriate environment variables to map the sdk: flutter to a location.
To easily and quickly create a new pub package, use the stagehand tool. After you install stagehand, follow these instructions:
$ mkdir fancy_project
$ cd fancy_project
$ stagehand package-simple
After you create your new package, edit the pubspec.yaml and add the sdk:flutter as shown above.
A trick I also use is to just flutter create foo (which creates a full-fledged Flutter app, more than you need) and then rm -rf foo/ios foo/android and edit/remove foo/lib/main.dart, etc.
The stagehand solution from @sethladd is more elegant, but requires having installed stagehand.
flutter create now supports templates.
The package template creates exactly that:
flutter create -t package
or to create a plugin that depends on platform-specific code:
flutter create -t plugin