text
stringlengths
1
372
if you use xcode to debug most of your code, start with this section.
<topic_end>
<topic_start>
start the xcode debugger
open ios/Runner.xcworkspace from your flutter app directory.
select the correct device using the scheme menu in the toolbar.
if you have no preference, choose iPhone pro 14.
run this runner as a normal app in xcode.
when the run completes, the debug area at the bottom of xcode displays
a message with the dart VM service URI. it resembles the following response:
copy the dart VM service URI.
<topic_end>
<topic_start>
attach to the dart VM in VS code
to open the command palette, go to
view >
command palette…
you can also press cmd + shift + p.
type debug.
click the debug: attach to flutter on device command.
in the paste an VM service URI box, paste the URI you copied
from xcode and press enter.
you can also create a .vscode/launch.json file in your flutter module project.
this enables you to attach using the run > start debugging command or f5:
<topic_end>
<topic_start>
IntelliJ / android studio
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 scheme
select the arguments tab
add either --vm-service-host=0.0.0.0 for IPv4,
or --vm-service-host=::0 for IPv6 as a launch argument
you 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