4

I wanted to print a log statement onto any LogCat console (Verbose, Debug, etc) but I can't seem to find a way to do it.

The print() or debugPrint() doesn't seem to work, or better yet should I say I don't know where they are printing.

Also, for some reason, the LogCat console is saying "No connected devices" and "No debuggable process" even though I have the emulator running in background and the files are executing on the emulator perfectly.

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
Jack621311
  • 107
  • 2
  • 11

1 Answers1

8

Based on Flutter Doc, the logging view displays events from the Dart runtime, application frameworks (like Flutter), and application-level logging events.By default, the logging view shows:

  • Garbage collection events from the Dart runtime
  • Flutter framework events, like frame creation events
  • stdout and stderr from applications
  • Custom logging events from applications

Refer the Debugging Flutter Applications Programmatically Doc. You can use:

stderr.writeln('print me');

Or

import 'dart:developer' as developer;

void main() {
  developer.log('log me', name: 'my.app.category');

  developer.log('log me 1', name: 'my.other.category');
  developer.log('log me 2', name: 'my.other.category');
}

Or

import 'dart:convert';
import 'dart:developer' as developer;

void main() {
  var myCustomObject = ...;

  developer.log(
    'log me',
    name: 'my.app.category',
    error: jsonEncode(myCustomObject),
  );
}

to log from your app.

Sampath
  • 1,144
  • 1
  • 21
  • 38