intellij-ideaconsoledartflutter

How to log data to the Flutter console?


I am a beginner and using IntelliJ IDEA, and I wanted to log data to the console?

I tried print() and printDebug(), but none of my data were showing in the Flutter console.


Solution

  • If you're inside a Flutter Widget, you can use debugPrint, e.g.,

    import 'package:flutter/foundation.dart';
    
    debugPrint('movieTitle: $movieTitle');
    

    Or, use Dart's built in log() function

    import 'dart:developer';
    
    log('data: $data');