dev_print 0.0.1
dev_print: ^0.0.1 copied to clipboard
A utility for improved logging (console output) in Flutter apps with formatted messages and tags.
Dev Print #
A lightweight utility for enhanced logging (console output) in Flutter apps, simplifying debugging by formatting messages and allowing the use of optional tags.
Features #
- Print messages in a readable format during development.
- Supports various data types including
String,Map,List, andbool. - Automatically formats
MapandListobjects as JSON. - Option to add a custom tag for better identification of logs.
- Only logs messages in
kDebugMode, preventing logs from being printed in release builds.
Installation #
Add dev_print to your pubspec.yaml file:
dependencies:
dev_print:
Then, run flutter pub get to install the package.
Usage #
To use the devPrint function in your app, simply import the package and call devPrint with a message:
import 'package:dev_print/dev_print.dart';
void main() {
devPrint('Hello, World!');
devPrint({
'orderId': 12345,
'products': [
{'name': 'Laptop', 'price': 1200},
{'name': 'Phone', 'price': 800}
],
'totalPrice': 2000,
'paid': false
}, tag: 'OrderDetails');
}
Example Output #
For a simple message:
(START)⤵⤵⤵
Hello, World!
(END)⤴⤴⤴
For a Map with a custom tag:
------- OrderDetails -------
(START)⤵⤵⤵
{
"orderId": 12345,
"products": [
{
"name": "Laptop",
"price": 1200
},
{
"name": "Phone",
"price": 800
}
],
"totalPrice": 2000,
"paid": false
}
(END)⤴⤴⤴
Parameters #
message: The message you want to log. It can be of typeString,Map,List,bool, or any other data type. If it’s aMaporList, it will be automatically formatted as JSON.tag: (Optional) A string to label your logs for better traceability. Defaults tonull.
Notes #
- Logs are only printed when
kDebugModeis enabled, so they won't appear in release builds. - If a JSON formatting error occurs, an error message will be printed.
License #
This package is licensed under the MIT License - see the LICENSE file for details.
Changelog #
See CHANGELOG.md for a list of changes.
Contact #
For collaboration, inquiries, or support, feel free to reach out to us via email: italiya.in@gmail.com