The practice of reload / restart of flutter

Time:2021-6-3

Environmental Science:

macos
android studio
Android native project merges with separate flutter project

The debugging steps of hot update of flutter are as follows:

1. First, open the Android emulator, close or uninstall the app to be debugged, and then go to the browser directory (/ users / who / space / browser)_ project)

whodeMacBook-Pro:flutter_project who$ pwd
/Users/who/flutter_project
whodeMacBook-Pro:flutter_project who$flutter attach

Waiting for a connection from Flutter on Android SDK built for x86...

If there are multiple simulators, they can be specified by command

whodeMacBook-Pro:flutter_project who$ adb devices
List of devices attached
emulator-5554   device
whodeMacBook-Pro who$ flutter attach -d 'emulator-5554'

2. Start the Android project in run mode (debug mode is not required). After the project starts, the console will prompt:

whodeMacBook-Pro:flutter_project who$ flutter attach

Waiting for a connection from Flutter on Android SDK built for x86...

**Syncing files to device Android SDK built for x86...                    

9,090ms (!)                                       

?  To hot reload changes while running, press "r". To hot restart (and rebuild state), press "R".

An Observatory debugger and profiler on Android SDK built for x86 is available at: http://127.0.0.1:51053/H2OAWGkKPvI=/

For a more detailed help message, press "h". To detach, press "d"; to quit, press "q".**

3. Change the flitter code to test the hot load / hot restart

To hot reload changes while running, press "r". To hot restart (and rebuild state), press "R".

An Observatory debugger and profiler on Android SDK built for x86 is available at: http://127.0.0.1:51053/H2OAWGkKPvI=/

For a more detailed help message, press "h". To detach, press "d"; to quit, press "q".

//After the code of the flitter is changed, type r here

Initializing hotreload...                                              
Reloaded 2 of 978 libraries in 386ms.

//After the code of the flitter is changed, type r here

Performing hotreload...                                                
Reloaded 0 of 978 libraries in 147ms.

Observe the content of the flitter interface, and the content has changed.