debug_console

Creator: coderz1093

Last updated:

0 purchases

debug_console Image
debug_console Images

Languages

Categories

Add to Cart

Description:

debug console

Debug Console #
A console for debugging Flutter apps, and displaying console messages on the widget.
Check the console for prints and errors, while you're testing it, all within your app. Make your own logging or watch for console prints.
Features #

Log your messages
Display console messages and errors
Use different levels for better emphasis
Filter the logs
Add extra actions to execute from the Debug Console menu
Check StackTrace of errors

Getting started #
Install it using pub:
flutter pub add debug_console
copied to clipboard
And import the package:
import 'package:debug_console/debug_console.dart';
copied to clipboard
Usage #
A console can be created using the widget DebugConsole.
Each log message displays a timestamp, level, and stack trace, if available.
You can control the consoles using a DebugConsoleController, you can create your own to isolate a console from the others, or you can use the root, DebugConsole.instance.
final controller = DebugConsoleController();

controller.log('Hello World', level: DebugConsoleLevel.info);
print(controller.logs); // List<DebugControllerLog>
controller.clear();

DebugConsole.log('Hello World', level: DebugConsoleLevel.info);
DebugConsole.clear();

DebugConsole.info('Info message');
// Also: warning, error, fatal, debug
copied to clipboard
Log a message with a StackTrace, doesn't need to be an error, it works with any level.
DebugConsole.error('Error message', stackTrace: StackTrace.current);
copied to clipboard
Listen for Prints and Errors #
To catch all messages in your app, you need to use DebugConsole.listen to listen for prints and errors.
Everything inside that function will be automatically logged.
DebugConsole.listen(() {
runApp(const MyApp());
});
copied to clipboard

A controller can be given, instead of logging to the root.

Debug Console Popup #
Run your app along with the Debug Console using the popup. Click the floating debug icon to open the console.
MaterialApp(
home: DebugConsolePopup(
showButton: true,
child: ...
);
);
copied to clipboard
Save logs to a file #
In case you need the save the logs, when setting the savePath argument, it will automatically save all the logs to that file.
DebugConsole(
savePath: 'debug_console.log',
);
copied to clipboard
For some platforms, using files can be a little bit more tricky:


When debugging on a desktop, like Windows, simple paths can be used to create a log file in the project folder.


When debugging on a mobile device, like Android and iOS, you need to use a storage/temporary path, the log files will stay on the device.


The Debug Console can automatically load the logs, using DebugConsole.loadPath, which should be set before using DebugConsole.instance. You can also manually load the logs when creating a controller.
Menu Actions #
Actions can be added to the Debug Console to execute whenever needed from the menu.
DebutConsole(
actions: [
PopupMenuItem(
onTap: () => print('test'),
child: const Text('Print test'),
),
]
);
copied to clipboard

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.