If you're inside a Flutter Widget, you can use debugPrint, e.g.,
import 'package:flutter/foundation.dart';
debugPrint('movieTitle: $movieTitle');
import 'dart:developer';
log('data: $data');
The Dart print() function outputs to the system console, which you can view using flutter logs (which is basically a wrapper around adb logcat).
If you output too much at once, then Android sometimes discards some log lines. To avoid this, you can use debugPrint().
Found here: https://flutter.io/docs/testing/debugging
log() from 'dart:developer'
It doesn't seem to have a max length limits like print() or debugPrint().
So it comes helpful when you want to log the whole API response.
And also helps in dart dev tools to show formatted logging.
import 'dart:developer'; //(auto import will do this even)
//example for api logging
log("${response?.statusCode} : ${response?.request?.path}",
name: "Response", error: response.data);
To be crystal clear, debugPrint will only work inside a Flutter widget.
I used print() in my code and it prints in the Debug Console.
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