How can I access Dart functions/variables from the Dartium DevTool Console?
Asked Answered
R

1

6

In JavaScript you can access global variables and functions from the DevTool console (e.g. to call a function manually).

I tried to do this in Dartium, but I always get a reference error.

I tried following variations:

testFunc () {
    return "test";
}

var testFunc2 = () {
    return "test";
}

void main() {
    var testFunc3 () {
        return "test";
    }
}

but none can be called via DevTool console of Dartium.

Rogerrogerio answered 30/7, 2014 at 14:5 Comment(0)
G
7

You need to select a Dart context.
When you open devtools > Console tab there is <top frame> selected by default.
You need to switch to a Dart context like dart:core.
As far as I remember it doesn't matter which Dart context is selected, just one of the Dart contexts.

enter image description here

Gallicanism answered 30/7, 2014 at 15:27 Comment(1)
That helped, thank you! Though I have to select the right File as the context if I want to call own functions, otherwise there will be thrown an exception.Rogerrogerio

© 2022 - 2024 — McMap. All rights reserved.