text
stringlengths 1
372
|
|---|
this option enables a one-step build for both your
|
android project and flutter project. this option is
|
convenient when you work on both parts simultaneously
|
and rapidly iterate, but your team must install the
|
flutter SDK to build the host app.
|
lightbulb tip
|
by default, the host app provides the :app gradle project.
|
to change the name of this project, set
|
flutter.hostAppProjectName in the flutter module’s
|
gradle.properties file.
|
include this project in the host app’s settings.gradle file.
|
include the flutter module as a subproject in the host app’s
|
settings.gradle. this example assumes flutter_module and MyApp
|
exist in the same directory
|
<code_start>
|
// include the host app project.
|
include ':app' // assumed existing content
|
setBinding(new binding([gradle: this])) // new
|
evaluate(new file( // new
|
settingsDir.parentFile, // new
|
'flutter_module/.android/include_flutter.groovy' // new
|
)) // new
|
<code_end>
|
the binding and script evaluation allows the flutter
|
module to include itself (as :flutter) and any
|
flutter plugins used by the module (such as :package_info and :video_player)
|
in the evaluation context of your settings.gradle.
|
introduce an implementation dependency on the flutter
|
module from your app:
|
<code_start>
|
dependencies {
|
implementation project(':flutter')
|
}
|
<code_end>
|
your app now includes the flutter module as a dependency.
|
continue to the adding a flutter screen to an android app guide.
|
<topic_end>
|
<topic_start>
|
add a flutter screen to an android app
|
this guide describes how to add a single flutter screen to an
|
existing android app. a flutter screen can be added as a normal,
|
opaque screen, or as a see-through, translucent screen.
|
both options are described in this guide.
|
<topic_end>
|
<topic_start>
|
add a normal flutter screen
|
<topic_end>
|
<topic_start>
|
step 1: add FlutterActivity to AndroidManifest.xml
|
flutter provides FlutterActivity to display a flutter
|
experience within an android app. like any other activity,
|
FlutterActivity must be registered in your
|
AndroidManifest.xml. add the following XML to your
|
AndroidManifest.xml file under your application tag:
|
the reference to @style/launchtheme can be replaced
|
by any android theme that want to apply to your FlutterActivity.
|
the choice of theme dictates the colors applied to
|
android’s system chrome, like android’s navigation bar, and to
|
the background color of the FlutterActivity just before
|
the flutter UI renders itself for the first time.
|
<topic_end>
|
<topic_start>
|
step 2: launch FlutterActivity
|
with FlutterActivity registered in your manifest file,
|
add code to launch FlutterActivity from whatever point
|
in your app that you’d like. the following example shows
|
FlutterActivity being launched from an OnClickListener.
|
info note
|
make sure to use the following import:
|
<code_start>
|
myButton.setOnClickListener(new OnClickListener() {
|
@override
|
public void onClick(View v) {
|
startActivity(
|
FlutterActivity.createDefaultIntent(currentActivity)
|
);
|
}
|
});
|
<code_end>
|
<code_start>
|
myButton.setOnClickListener {
|
startActivity(
|
FlutterActivity.createDefaultIntent(this)
|
)
|
}
|
<code_end>
|
the previous example assumes that your dart entrypoint
|
is called main(), and your initial flutter route is ‘/’.
|
the dart entrypoint can’t be changed using intent,
|
but the initial route can be changed using intent.
|
the following example demonstrates how to launch a
|
FlutterActivity that initially renders a custom
|
route in flutter.
|
<code_start>
|
myButton.addOnClickListener(new OnClickListener() {
|
@override
|
public void onClick(View v) {
|
startActivity(
|
FlutterActivity
|
.withnewengine()
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.