text
stringlengths 1
372
|
|---|
<code_end>
|
<code_start>
|
// with a new FlutterEngine.
|
val flutterFragment = FlutterFragment.withNewEngine()
|
.rendermode(flutterview.rendermode.texture)
|
.build()
|
// with a cached FlutterEngine.
|
val flutterFragment = FlutterFragment.withCachedEngine("my_engine_id")
|
.rendermode(flutterview.rendermode.texture)
|
.build()
|
<code_end>
|
using the configuration shown, the resulting FlutterFragment
|
renders its UI to a TextureView.
|
<topic_end>
|
<topic_start>
|
display a FlutterFragment with transparency
|
by default, FlutterFragment renders with an opaque background,
|
using a SurfaceView. (see “control FlutterFragment’s render
|
mode.”) that background is black for any pixels that aren’t
|
painted by flutter. rendering with an opaque background is
|
the preferred rendering mode for performance reasons.
|
flutter rendering with transparency on android negatively
|
affects performance. however, there are many designs that
|
require transparent pixels in the flutter experience that
|
show through to the underlying android UI. for this reason,
|
flutter supports translucency in a FlutterFragment.
|
info note
|
both SurfaceView and TextureView support transparency.
|
however, when a SurfaceView is instructed to render with
|
transparency, it positions itself at a higher z-index than
|
all other android views, which means it appears
|
above all other views. this is a limitation of SurfaceView.
|
if it’s acceptable to render your flutter experience on top
|
of all other content, then FlutterFragment’s default
|
RenderMode of surface is the RenderMode that you
|
should use. however, if you need to display android views both
|
above and below your flutter experience, then you must specify a
|
RenderMode of texture.
|
see “control FlutterFragment’s render mode”
|
for information about controlling the RenderMode.
|
to enable transparency for a FlutterFragment,
|
build it with the following configuration:
|
<code_start>
|
// using a new FlutterEngine.
|
FlutterFragment flutterFragment = FlutterFragment.withNewEngine()
|
.transparencymode(flutterview.transparencymode.transparent)
|
.build();
|
// using a cached FlutterEngine.
|
FlutterFragment flutterFragment = FlutterFragment.withCachedEngine("my_engine_id")
|
.transparencymode(flutterview.transparencymode.transparent)
|
.build();
|
<code_end>
|
<code_start>
|
// using a new FlutterEngine.
|
val flutterFragment = FlutterFragment.withNewEngine()
|
.transparencymode(flutterview.transparencymode.transparent)
|
.build()
|
// using a cached FlutterEngine.
|
val flutterFragment = FlutterFragment.withCachedEngine("my_engine_id")
|
.transparencymode(flutterview.transparencymode.transparent)
|
.build()
|
<code_end>
|
<topic_end>
|
<topic_start>
|
the relationship between FlutterFragment and its activity
|
some apps choose to use fragments as entire android screens.
|
in these apps, it would be reasonable for a fragment to
|
control system chrome like android’s status bar,
|
navigation bar, and orientation.
|
in other apps, fragments are used to represent only
|
a portion of a UI. a FlutterFragment might be used to
|
implement the inside of a drawer, a video player,
|
or a single card. in these situations, it would be
|
inappropriate for the FlutterFragment to affect
|
android’s system chrome because there are other UI
|
pieces within the same window.
|
FlutterFragment comes with a concept that helps
|
differentiate between the case when a FlutterFragment
|
should be able to control its host activity, and the
|
cases when a FlutterFragment should only affect its
|
own behavior. to prevent a FlutterFragment from
|
exposing its activity to flutter plugins, and to
|
prevent flutter from controlling the activity’s system UI,
|
use the shouldAttachEngineToActivity() method in
|
FlutterFragment’s builder, as shown:
|
<code_start>
|
// using a new FlutterEngine.
|
FlutterFragment flutterFragment = FlutterFragment.withNewEngine()
|
.shouldattachenginetoactivity(false)
|
.build();
|
// using a cached FlutterEngine.
|
FlutterFragment flutterFragment = FlutterFragment.withCachedEngine("my_engine_id")
|
.shouldattachenginetoactivity(false)
|
.build();
|
<code_end>
|
<code_start>
|
// using a new FlutterEngine.
|
val flutterFragment = FlutterFragment.withNewEngine()
|
.shouldattachenginetoactivity(false)
|
.build()
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.