text
stringlengths
1
372
<topic_end>
<topic_start>
step 3: binding to native code
to use the native code, bindings in dart are needed.
to avoid writing these by hand,
they are generated from the header file
(src/hello.h) by package:ffigen.
reference the ffigen docs for information
on how to install this package.
regenerate the bindings by running the following:
<topic_end>
<topic_start>
step 4: invoking native code
very short-running native functions can be directly
invoked from any isolate.
for an example, see sum in lib/hello.dart.
longer-running functions should be invoked on a
helper isolate to avoid dropping frames in
flutter applications.
for an example, see sumAsync in lib/hello.dart.
<topic_end>
<topic_start>
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