Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dart inspect() function, doesn't seem to do anything in VS Code

Tags:

flutter

dart

I am using VS Code.

Supposedly there is a function called inspect() in dart that allows you to vardump an object.

my barebones example is as follows:

import 'dart:developer';

class User {
  String name;
  int age;

  User(this.name, this.age);
}

void main() {
  User newUser = User("Steve", 30);
  inspect(newUser);
  print('done');
}

I don't get any errors, but all I see in the Debug Console is "done"

On this page there is am image showing inspect() sample output (4th image from the top) in the Debug Console: Link

Is there something else I need to do to make this command work in VS Code?

like image 261
Norsak Avatar asked Feb 02 '26 10:02

Norsak


1 Answers

If I debug the code from VS Code it works for me, although the Dart-Code extension isn't so fast to succeed before the program ending:

enter image description here

If the program doesn't end immediately - it works:

Future<void> main() async {
  User newUser = User("Steve", 30);
  inspect(newUser);
  print('done');
  await Future.delayed(Duration(seconds: 2));
  print('done');
}

enter image description here

like image 121
Albert221 Avatar answered Feb 04 '26 02:02

Albert221



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!