text
stringlengths
1
474
Adding documentation
It is recommended practice to add the following documentation
to all packages:<topic_end>
<topic_start>
API documentation
When you publish a package,
API documentation is automatically generated and
published to pub.dev/documentation.
For example, see the docs for device_info.If you wish to generate API documentation locally on
your development machine, use the following commands:Change directory to the location of your package:Tell the documentation tool where the
Flutter SDK is located (change the following commands to reflect
where you placed it):Run the dart doc tool
(included as part of the Flutter SDK), as follows:For tips on how to write API documentation, see
Effective Dart Documentation.<topic_end>
<topic_start>
Adding licenses to the LICENSE file
Individual licenses inside each LICENSE file
should be separated by 80 hyphens
on their own on a line.If a LICENSE file contains more than one
component license, then each component
license must start with the names of the
packages to which the component license applies,
with each package name on its own line,
and the list of package names separated from
the actual license text by a blank line.
(The packages need not match the names of
the pub package. For example, a package might itself contain
code from multiple third-party sources,
and might need to include a license for each one.)The following example shows a well-organized license file:Here is another example of a well-organized license file:Here is an example of a poorly-organized license file:Another example of a poorly-organized license file:<topic_end>
<topic_start>
Publishing your package
lightbulb Tip
Have you noticed that some of the packages and plugins
on pub.dev are designated as Flutter Favorites?
These are the packages published by verified developers
and are identified as the packages and plugins you
should first consider using when writing your app.
To learn more,
see the Flutter Favorites program.Once you have implemented a package, you can publish it on
pub.dev, so that other developers can easily use it.Prior to publishing, make sure to review the pubspec.yaml,
README.md, and CHANGELOG.md files to make sure their
content is complete and correct. Also, to improve the
quality and usability of your package (and to make it
more likely to achieve the status of a Flutter Favorite),
consider including the following items:Next, run the publish command in dry-run mode
to see if everything passes analysis:The next step is publishing to pub.dev,
but be sure that you are ready because
publishing is forever:For more details on publishing, see the
publishing docs on dart.dev.<topic_end>
<topic_start>
Handling package interdependencies
If you are developing a package hello that depends on
the Dart API exposed by another package, you need to add
that package to the dependencies section of your
pubspec.yaml file. The code below makes the Dart API
of the url_launcher plugin available to hello:You can now import 'package:url_launcher/url_launcher.dart'
and launch(someUrl) in the Dart code of hello.This is no different from how you include packages in
Flutter apps or any other Dart project.But if hello happens to be a plugin package
whose platform-specific code needs access
to the platform-specific APIs exposed by url_launcher,
you also need to add suitable dependency declarations
to your platform-specific build files, as shown below.<topic_end>
<topic_start>
Android
The following example sets a dependency for
url_launcher in hello/android/build.gradle:You can now import io.flutter.plugins.urllauncher.UrlLauncherPlugin
and access the UrlLauncherPlugin
class in the source code at hello/android/src.For more information on build.gradle files, see the
Gradle Documentation on build scripts.<topic_end>
<topic_start>
iOS
The following example sets a dependency for
url_launcher in hello/ios/hello.podspec:You can now #import "UrlLauncherPlugin.h" and
access the UrlLauncherPlugin class in the source code
at hello/ios/Classes.For additional details on .podspec files, see the
CocoaPods Documentation on them.<topic_end>
<topic_start>
Web
All web dependencies are handled by the pubspec.yaml
file like any other Dart package.
<topic_end>
<topic_start>Flutter Favorite program
The aim of the Flutter Favorite program is to identify
packages and plugins that you should first consider when
building your app.
This is not a guarantee of quality or suitability to your
particular situation—you should always perform your
own evaluation of packages and plugins for your project.You can see the complete list of
Flutter Favorite packages on pub.dev.info Note
If you came here looking for the Happy Paths recommendations,
we have discontinued that project in favor of Flutter Favorites.<topic_end>
<topic_start>
Metrics
Flutter Favorite packages have passed high quality standards
using the following metrics:<topic_end>
<topic_start>
Flutter Ecosystem Committee
The Flutter Ecosystem Committee is comprised of Flutter
team members and Flutter community members spread
across its ecosystem.