text stringlengths 1 372 |
|---|
const DemoPage({super.key}); |
void launchURL() { |
launchUrl(p.toUri('https://flutter.dev')); |
} |
@override |
widget build(BuildContext context) { |
return scaffold( |
body: center( |
child: ElevatedButton( |
onPressed: launchURL, |
child: const Text('Show flutter homepage'), |
), |
), |
); |
} |
} |
<code_end> |
run the app (or stop and restart it, if it was already running |
before adding the plugin). click show flutter homepage. |
you should see the default browser open on the device, |
displaying the homepage for flutter.dev. |
<topic_end> |
<topic_start> |
developing packages & plugins |
<topic_end> |
<topic_start> |
package introduction |
packages enable the creation of modular code that can be shared easily. |
a minimal package consists of the following: |
info note |
for a list of dos and don’ts when writing an effective plugin, |
see the medium article by mehmet fidanboylu, |
writing a good plugin. |
<topic_end> |
<topic_start> |
package types |
packages can contain more than one kind of content: |
plugin packages can be written for android |
(using kotlin or java), iOS (using swift or Objective-C), |
web, macOS, windows, or linux, or any combination |
thereof. |
a concrete example is the url_launcher plugin package. |
to see how to use the url_launcher package, and how it |
was extended to implement support for web, |
see the medium article by harry terkelsen, |
how to write a flutter web plugin, part 1. |
<topic_end> |
<topic_start> |
developing dart packages |
the following instructions explain how to write a flutter |
package. |
<topic_end> |
<topic_start> |
step 1: create the package |
to create a starter flutter package, |
use the --template=package flag with flutter create: |
this creates a package project in the hello |
folder with the following content: |
<topic_end> |
<topic_start> |
step 2: implement the package |
for pure dart packages, simply add the functionality |
inside the main lib/<package name>.dart file, |
or in several files in the lib directory. |
to test the package, add unit tests |
in a test directory. |
for additional details on how to organize the |
package contents, |
see the dart library package documentation. |
<topic_end> |
<topic_start> |
developing plugin packages |
if you want to develop a package that calls into |
platform-specific APIs, |
you need to develop a plugin package. |
the API is connected to the platform-specific |
implementation(s) using a platform channel. |
<topic_end> |
<topic_start> |
federated plugins |
federated plugins are a way of splitting support for |
different platforms into separate packages. |
so, a federated plugin can use one package for iOS, |
another for android, another for web, |
and yet another for a car (as an example of an IoT device). |
among other benefits, this approach allows a domain expert |
to extend an existing plugin to work for the platform they know best. |
a federated plugin requires the following packages: |
<topic_end> |
<topic_start> |
endorsed federated plugin |
ideally, when adding a platform implementation to |
a federated plugin, you will coordinate with the package |
author to include your implementation. |
in this way, the original author endorses your |
implementation. |
for example, say you write a foobar_windows |
implementation for the (imaginary) foobar plugin. |
in an endorsed plugin, the original foobar author |
adds your windows implementation as a dependency |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.