text
stringlengths
1
474
Select the device on which the Flutter module runs so flutter attach filters for the right start signals.<topic_end>
<topic_start>
Wireless debugging
You can debug your app wirelessly on an iOS or Android device
using flutter attach.<topic_end>
<topic_start>iOS
On iOS, you must follow the steps below:Ensure that your device is wirelessly connected to Xcode
as described in the iOS setup guide.Open Xcode > Product > Scheme > Edit SchemeSelect the Arguments tabAdd either --vm-service-host=0.0.0.0 for IPv4,
or --vm-service-host=::0 for IPv6 as a launch argumentYou can determine if you’re on an IPv6 network by opening your Mac’s
Settings > Wi-Fi > Details (of the network you’re connected to) > TCP/IP
and check to see if there is an IPv6 address section.<topic_end>
<topic_start>Android
Ensure that your device is wirelessly connected to Android Studio
as described in the Android setup guide.
<topic_end>
<topic_start>Multiple Flutter screens or views
<topic_end>
<topic_start>
Scenarios
If you’re integrating Flutter into an existing app,
or gradually migrating an existing app to use Flutter,
you might find yourself wanting to add multiple
Flutter instances to the same project.
In particular, this can be useful in the
following scenarios:The advantage of using multiple Flutter instances is that each
instance is independent and maintains its own internal navigation
stack, UI, and application states. This simplifies the overall application code’s
responsibility for state keeping and improves modularity. More details on the
scenarios motivating the usage of multiple Flutters can be found at
flutter.dev/go/multiple-flutters.Flutter is optimized for this scenario, with a low incremental
memory cost (~180kB) for adding additional Flutter instances. This fixed cost
reduction allows the multiple Flutter instance pattern to be used more liberally
in your add-to-app integration.<topic_end>
<topic_start>
Components
The primary API for adding multiple Flutter instances on both Android and iOS
is based on a new FlutterEngineGroup class (Android API, iOS API)
to construct FlutterEngines, rather than the FlutterEngine
constructors used previously.Whereas the FlutterEngine API was direct and easier to consume, the
FlutterEngine spawned from the same FlutterEngineGroup have the performance
advantage of sharing many of the common, reusable resources such as the GPU
context, font metrics, and isolate group snapshot, leading to a faster initial
rendering latency and lower memory footprint.FlutterEngines spawned from FlutterEngineGroup can be used to
connect to UI classes like FlutterActivity or FlutterViewController
in the same way as normally constructed cached FlutterEngines.The first FlutterEngine spawned from the FlutterEngineGroup doesn’t need
to continue surviving in order for subsequent FlutterEngines to share
resources as long as there’s at least 1 living FlutterEngine at all
times.Creating the very first FlutterEngine from a FlutterEngineGroup has
the same performance characteristics as constructing a
FlutterEngine using the constructors did previously.When all FlutterEngines from a FlutterEngineGroup are destroyed, the next
FlutterEngine created has the same performance characteristics as the very
first engine.The FlutterEngineGroup itself doesn’t need to live beyond all of the spawned
engines. Destroying the FlutterEngineGroup doesn’t affect existing spawned
FlutterEngines but does remove the ability to spawn additional
FlutterEngines that share resources with existing spawned engines.<topic_end>
<topic_start>
Communication
Communication between Flutter instances is handled using platform channels
(or Pigeon) through the host platform. To see our roadmap on communication,
or other planned work on enhancing multiple Flutter instances, check out
Issue 72009.<topic_end>
<topic_start>
Samples
You can find a sample demonstrating how to use FlutterEngineGroup
on both Android and iOS on GitHub.
<topic_end>
<topic_start>Load sequence, performance, and memory
This page describes the breakdown of the steps involved
to show a Flutter UI. Knowing this, you can make better,
more informed decisions about when to pre-warm the Flutter engine,
which operations are possible at which stage,
and the latency and memory costs of those operations.<topic_end>
<topic_start>
Loading Flutter
Android and iOS apps (the two supported platforms for
integrating into existing apps), full Flutter apps,
and add-to-app patterns have a similar sequence of
conceptual loading steps when displaying the Flutter UI.<topic_end>
<topic_start>
Finding the Flutter resources
Flutter’s engine runtime and your application’s compiled
Dart code are both bundled as shared libraries on Android
and iOS. The first step of loading Flutter is to find those
resources in your .apk/.ipa/.app (along with other Flutter
assets such as images, fonts, and JIT code, if applicable).This happens when you construct a FlutterEngine for the
first time on both Android
and iOS APIs.<topic_end>
<topic_start>
Loading the Flutter library
After it’s found, the engine’s shared libraries are memory loaded
once per process.On Android, this also happens when the
FlutterEngine is constructed because the
JNI connectors need to reference the Flutter C++ library.
On iOS, this happens when the
FlutterEngine is first run,
such as by running runWithEntrypoint:.<topic_end>
<topic_start>
Starting the Dart VM
The Dart runtime is responsible for managing Dart memory and
concurrency for your Dart code. In JIT mode,