Use flutter attach to implement code and application process association

When we use flutter run to debug the App, if the data line is in poor contact or disconnected, we may need to execute flutter run again when we want to continue debugging.

But in fact, there is another command called flutter attach. It can achieve the following functions

  • attach to a running app
  • Support specifying device id for attach
  • Support specified port for attach
  • Support setting timeout
  • Supports passing key-value key-value pair settings

It is also very simple to use

 1 
flutter attach

When multiple devices are available

First use flutter devices to view the target device id

 1 2 3 4 5 
 flutter devices 2 connected devices: SM G9730 ( mobile ) • RA2TQ6PN • android-arm64 • Android 11 ( API 30 ) Chrome ( web ) • chrome • web-javascript • Google Chrome 100.0.4896.60

Then execute the device id to execute.

 1 
flutter attach -d RA2TQ6PN --verbose 

droidyue_gzh_green_png.png

This article is reprinted from https://droidyue.com/blog/2022/07/31/flutter-attach-process/
This site is for inclusion only, and the copyright belongs to the original author.

Leave a Comment

Your email address will not be published.