Flutter 3.41 is live! Check out theFlutter 3.41 blog post!
Add a Flutter View to an Android app
Learn how to perform advanced integrations via Flutter Views.
Integrating via aFlutterView is advanced usage and requires manually creating custom, application specific bindings.
Integrating via aFlutterView requires a bit more work than via FlutterActivity and FlutterFragment previously described.
Fundamentally, the Flutter framework on the Dart side requires access to various activity-level events and lifecycles to function. Since the FlutterView (which is anandroid.view.View) can be added to any activity which is owned by the developer's application and since the FlutterView doesn't have access to activity level events, the developer must bridge those connections manually to theFlutterEngine.
How you choose to feed your application's activities' events to the FlutterView will be specific to your application.
A sample
#
Unlike the guides for FlutterActivity and FlutterFragment, the FlutterView integration could be better demonstrated with a sample project.
A sample project is athttps://github.com/flutter/samples/tree/main/add_to_app/android_view to document a simple FlutterView integration where FlutterViews are used for some of the cells in a RecycleView list of cards as seen in the gif above.
General approach
# The general gist of the FlutterView-level integration is that you must recreate the various interactions between your Activity, theFlutterView and theFlutterEngine present in theFlutterActivityAndFragmentDelegate in your own application's code. The connections made in theFlutterActivityAndFragmentDelegate are done automatically when using aFlutterActivity or aFlutterFragment, but since theFlutterView in this case is being added to anActivity orFragment in your application, you must recreate the connections manually. Otherwise, theFlutterView won't render anything or have other missing functionalities.
A sampleFlutterViewEngine class shows one such possible implementation of an application-specific connection between anActivity, aFlutterView and aFlutterEngine.
APIs to implement
#The absolute minimum implementation needed for Flutter to draw anything at all is to:
- Call
attachToFlutterEnginewhen theFlutterViewis added to a resumedActivity's view hierarchy and is visible; and - Call
appIsResumedon theFlutterEngine'slifecycleChannelfield when theActivityhosting theFlutterViewis visible.
The reversedetachFromFlutterEngine and other lifecycle methods on theLifecycleChannel class must also be called to not leak resources when theFlutterView orActivity is no longer visible.
In addition, see the remaining implementation in theFlutterViewEngine demo class or in theFlutterActivityAndFragmentDelegate to ensure a correct functioning of other features such as clipboards, system UI overlay, plugins, and so on.
Content-sized views
# Usually, aFlutterView needs fixed dimensions either through it's own dimensions or by matching a parent's dimensions. This can be seen in thesample project. However, it's now possible to allowFlutterView to size itself based on its content. By using,content_wrap for either the height or the width aFlutterView can size itself, as shown in thecontent sized sample project.
- Toenable Content-sized view when deploying your app, add the following setting to your project's
AndroidManifest.xmlfile under the<application>tag:
<meta-dataandroid:name="io.flutter.embedding.android.EnableContentSizing"android:value="true" />Restrictions
#Since content-sized Flutter views require your Flutter app to be able to size itself, some widgets are not supported.
- A widget with unbounded size, like a
ListView. - A widget that defers to its child for the size, like
LayoutBuilder.
In practice, this means that quite a few common widgets are not supported, such asScaffoldBuilder,CupertinoTimerPicker, or any widget that internally relies on aLayoutBuilder. When in doubt, you can use anUnconstrainedBox to test the usability of a widget for a content-sized view, as shown in the following example:
import'package:flutter/material.dart';voidmain()=>runApp(MyApp());classMyAppextendsStatelessWidget{@overrideWidgetbuild(BuildContextcontext)=>MaterialApp(home:MyPage());}classMyPageextendsStatelessWidget{@overrideWidgetbuild(BuildContextcontext){returnScaffold(body:UnconstrainedBox(// TODO: Edit this line to check if a widget// can cause problems with content-sized views.child:Text('This works!'),// child: Column(children: [Column(children: [Expanded(child: Text('This blows up!'))])]),// child: ListView(children: [Text('This blows up!')]),));}}Unless stated otherwise, the documentation on this site reflects Flutter 3.38.6. Page last updated on 2026-02-03.View source orreport an issue.