Flutter Print is an extension created for Visual Studio Code. If you find it useful, please consider supporting it.
Easily insert and remove debugPrint('variable: $variable');
statement.
This extension overrides the shortcut for Select all occurrences of current selection -
Ctrl+Shift+L
on Windows and Linux andCmd+Shift+L
on macOS, however you can still useCtrl+F2
to execute same command.
The Flutter Print extension has only one configuration option called useDebugPrint
which is used to define whether the debugPrint statement will be used instead of the print statement.
With the extension setting useDebugPrint enabled, select the variable or object properties that you want uses debugPrint statement and press Ctrl+Shift+L
on Windows, Linux or macOS.
With the extension setting useDebugPrint disabled, select the variable or object properties that you want uses print statement and press Ctrl+Shift+L
on Windows, Linux or macOS.
To remove all print statements and press Win+Shift+D
on Windows and Linux or Cmd+Shift+D
on macOS.
Create a custom log class.
import 'dart:developer' as developer;
class Log {
Log._();
static void print(String value, {StackTrace? stackTrace}) {
developer.log(value, name: 'LOG', stackTrace: stackTrace);
}
static Object? inspect(Object? object) {
return developer.inspect(object);
}
}
Select the variable or object properties that you want uses a custom Log.print statement and press Win+Ctrl+L
on Windows and Linux or Cmd+Ctrl+L
on macOS.
Select the variable that you want uses a custom Log.inspect statement and press Win+Ctrl+L
on Windows and Linux or Cmd+Ctrl+L
on macOS.
That's all, Enjoy!