Description
I recently implemented something called "log points" in Dart Code where we let the user provide an expression and we wrap it in print()
and send it to the debugger via evaluateInFrame
. At some point in the past, I'm certain this worked fine:
However today, this seems completely broken. I've tried various versions of Flutter and Dart Code and can't make the example in the screenshot work at all (I even went back several beta versions). However, the same thing seems to work fine in Dart VM scripts.
Here's what I get back from the VM in Flutter when trying to use print
:
{
"id": "400",
"method": "evaluateInFrame",
"params": {
"expression": "print(\"\"\"_counter\"\"\")",
"frameIndex": 0,
"isolateId": "isolates/909101337"
}
},
{
"jsonrpc": "2.0",
"result": {
"type": "@Error",
"_vmType": "UnhandledException",
"kind": "UnhandledException",
"id": "objects\/1",
"message":"Unhandled exception:\nNoSuchMethodError: Class '_MyHomePageState' has no instance method 'print'.\nReceiver: Instance of '_MyHomePageState'\nTried calling: print(\"_counter\")\n..."
}
}
And here's what happens if I try to use a class name like DateTime
:
Unhandled exception:\n'file:\/\/\/Users\/dantup\/Dev\/Dart-Code\/test\/test_projects\/flutter_hello_world\/lib\/main.dart':
malformed type: line 1 pos 9: cannot resolve class 'DateTime' from 'MyHomePage'
As well as affecting log points, this happens from the Debug Console, so if the user types (new DateTime.now()).year
into the Debug Console for a Dart CLI script it works fine, but in Flutter it fails. Using the Flutter version of the SDK for both tests.