text
stringlengths
1
372
if you do not supply the -d flag, flutter run lists
the available targets to choose from.
<topic_end>
<topic_start>
build a release app
to generate a release build,
run one of the following commands:
<topic_end>
<topic_start>
add desktop support to an existing flutter app
to add desktop support to an existing flutter project,
run the following command in a terminal from the
root project directory:
this adds the necessary desktop files and directories
to your existing flutter project.
to add only specific desktop platforms,
change the platforms list to include only
the platform(s) you want to add.
<topic_end>
<topic_start>
plugin support
flutter on the desktop supports using and creating plugins.
to use a plugin that supports desktop,
follow the steps for plugins in using packages.
flutter automatically adds the necessary native code
to your project, as with any other platform.
<topic_end>
<topic_start>
writing a plugin
when you start building your own plugins,
you’ll want to keep federation in mind.
federation is the ability to define several
different packages, each targeted at a
different set of platforms, brought together
into a single plugin for ease of use by developers.
for example, the windows implementation of the
url_launcher is really url_launcher_windows,
but a flutter developer can simply add the
url_launcher package to their pubspec.yaml
as a dependency and the build process pulls in
the correct implementation based on the target platform.
federation is handy because different teams with
different expertise can build plugin implementations
for different platforms.
you can add a new platform implementation to any
endorsed federated plugin on pub.dev,
so long as you coordinate this effort with the
original plugin author.
for more information, including information
about endorsed plugins, see the following resources:
<topic_end>
<topic_start>
samples and codelabs
you can run the following samples as desktop apps,
as well as download and inspect the source code to
learn more about flutter desktop support.
<topic_end>
<topic_start>
writing custom platform-specific code
this guide describes how to write custom platform-specific code.
some platform-specific functionality is available
through existing packages;
see using packages.
info note
the information in this page is valid for most platforms,
but platform-specific code for the web generally uses
JS interoperability or the dart:html library instead.
flutter uses a flexible system that allows you to call
platform-specific APIs in a language that works directly
with those APIs:
flutter’s builtin platform-specific API support
doesn’t rely on code generation,
but rather on a flexible message passing style.
alternatively, you can use the pigeon
package for sending structured typesafe messages
with code generation:
the flutter portion of the app sends messages to its host,
the non-Dart portion of the app, over a platform channel.
the host listens on the platform channel, and receives the message.
it then calls into any number of platform-specific APIs—using
the native programming language—and sends a response back to the
client, the flutter portion of the app.
info note
this guide addresses using the platform channel mechanism
if you need to use the platform’s APIs in a non-Dart language.
but you can also write platform-specific dart code
in your flutter app by inspecting the
defaultTargetPlatform property.
platform adaptations lists some
platform-specific adaptations that flutter
automatically performs for you in the framework.
<topic_end>
<topic_start>
architectural overview: platform channels
messages are passed between the client (ui)
and host (platform) using platform
channels as illustrated in this diagram:
messages and responses are passed asynchronously,
to ensure the user interface remains responsive.
info note