I accidentally press the key "T" in terminal when I reach to "R" to hot reload and always my app's widget tree is printed and it takes minutes to finish so It annoyes me so much. I really need to turn this feature off if it's possible but I don't know how.
TLDR:
comment out line 1285 - 1291 in
flutter/packages/flutter_tools/lib/src/resident_runner.dart
commit changes in your local flutter git repo and 't' will be disabled.
This happens inside
flutter/packages/flutter_tools/lib/src/resident_runner.dart
in
Future<bool> _commonTerminalInputHandler(String character)
method.
It is handled here
case 't':
case 'T':
if (residentRunner.supportsServiceProtocol) {
await residentRunner.debugDumpRenderTree();
return true;
}
return false;
and the only check if in supportsServiceProtocol
getter which returns true if the app is in debug or profile mode.
If that check goes true, the method is called in VirtualMachine
Future<Map<String, dynamic>> flutterDebugDumpRenderTree() {
return invokeFlutterExtensionRpcRaw('ext.flutter.debugDumpRenderTree');
}
and that handles the output. So unfortunately, you cannot disable this without changing the flutter source code.
Fortunately for you, changing the flutter source code is super easy.
Go inside flutter/packages/flutter_tools/lib/src/resident_runner.dart
and comment out the cases that you don't want to trigger.
case 'S':
if (residentRunner.supportsServiceProtocol) {
await residentRunner.debugDumpSemanticsTreeInTraversalOrder();
return true;
}
return false;
// case 't':
// case 'T':
// if (residentRunner.supportsServiceProtocol) {
// await residentRunner.debugDumpRenderTree();
// return true;
// }
// return false;
So you have successfully changed flutter source. Now you need to rebuild flutter tools.
To do that, you can follow developer docs:
If you want to alter and re-test the tool's behavior itself, locally commit your tool change in git and the tool will be rebuilt from Dart sources in
packages/flutter_tools
the next time you run flutter. Alternatively, delete thebin/cache/flutter_tools.snapshot
file. Doing so will force a rebuild of the tool from your local sources the next time you run flutter.
To put it simple, open the terminal in flutter root and commit your changes.
Next time you run the flutter run
you will see message output in terminal:
Building flutter tool...
When you want to upgrade flutter, run git pull --rebase
and your changes will be saved.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With