How to see the variable values in flutter debug - flutter

I have a variable inside a Provider which I want to see its value (because its value is cleaning and I don't know why) in debug, but I don't know how to see it.
How can I debug seeing this variable value while I'm navigating in the app??

Place breakpoint
Run in Debug mode (F5 is the shortcut for VSCode)
Open the window 'Debug Console' (Found in the 'View' menu in VS code)
Type in the variable name in the command prompt
The variable representation is printed on the console. You can click, browse and navigate the data structure as well.

I suggest create setter for that variable and use it everywhere in your code (where this variable is changed).
Then place brakepoint to this setter. This way you will be able to track whenever variable is changed.

put debug point where the value of provider is used,
or you can use flutter devtools in browser, there will be tab called provider which will show all active providers and its data

Related

How to get VS Code to list methods of object when multiple extensions are competing for tab complete

In VS Code, when writing the name of a method on an object, it seems to take a while for the method menu to pop up. I also am using github copilot, which is great, but it's suggestions often show first and I don't see the menu for the methods until I type some more letters.
Example, let's say I have the following line of code:
my_json = My_Class(id=5).
and I want to type the name of the method that returns some json. Gitlab copilot might suggest something like the following, where the 'get_json' portion is in grey and available for tab complete.
my_json = My_Class(id=5).get_json()
But, let's say the correct name for the method is 'get_object_json', I would have to type the following before the object method/attribute menu pops up
my_json = My_Class(id=5).get_o
Is there a way to manually open the object method/attribute menu? A keyboard shortcut? So that I can open it right after I have typed the period?
Similarly, sometimes I DO want the GitHub suggestion but, right as I hit tab, Pylance IntelliSense replaces the tab complete with the name of some variable or library, or global (i.e. some built-in exception class).
It would be great if there was a way to assign a specific key combo for tab complete of GitHub copilot. Like tab-option, or something, that will only complete the github copilot suggestion, if there is one.

How to custom VSCode call stack dialog?

I am using VSCode to debug C++ project with cmake: debug
So, when program stop at a breakpoint, the CALL STACK dialog can show call stack. But the function name which be called attaching with its parameters are always too long, so the source file name will be hide unless one enlarge this dialog by mouse.
In my case, I care more about source file name than function parameters. So I hope function parameters can be hidden, and the source file name can show.
How to make this? Thank you!

How to call function on js object from chrome dev tools?

Say I want to look at an object and so I log it to the console:
console.log(theNoticeObj);
Then using Chrome Dev Tools, I inspect it in the console and change its property theNoticeObj.bounceHeight to 10px
Now if I want to trigger theNoticeObj.bounce() on that object immediately to locate it, is there an easy way to do that from the console?
Thanks
EDIT:
Breakpoints where suggested below, but this freezes execution.
In face what I want is the command line API to work with javascript objects, not just DOM elements. If that were possible I'm sure I would be able to find it. I might go and see if there are any feature requests to that end for chrome.
https://developers.google.com/chrome-developer-tools/docs/console#using_the_command_line_api
Try adding window.tno = theNoticeObject under the console.log statement. Reload the page and see if you can execute tno.bounce() from the console. If theNoticeObject is still in scope, this should work.
You can navigate to the Sources tab and open your javascript file containing the piece of code you want to play with, in this case let us assume it is
console.log(theNoticeObj);
Once you find this line, you can set a breakpoint at this point and when your program execution comes to this line it will halt.
You can then use the Console tab to do operations on all the javascript objects in current local scope, window scope. You can simply call:
theNoticeObj.bounce();
It executes in the current context reflecting changes on the screen.
Hope this helps.
Now you can right click any object in the console and use "Store as global variable".
A new console line appears with the name of a new global variable holding reference to the selected object.

Tracking variable or memory change in Xcode?

Is there any way to track variable changes or memory changes in Xcode? I'm looking for functionality like Visual Studio's data breakpoint.
I want to know where my object's view frame is being changed. I want to set a breakpoint at a member variable and run it. Then I could determine where it's changed.
Xcode uses gdb (or lldb, but that's another story) to implement its debugging functionality. gdb has the ability to set hardware watchpoints and hence so does Xcode.
This is a useful page for generic debugging of memory errors. Xcode's debugging console window is really just a gdb shell, you can type in commands as you please. The ever-helpful Quinn Taylor explains how to do so in this related post.
If you'd rather avoid interacting with gdb directly, you can right-click a variable in Xcode's debugging window and select "Watch Variable". Xcode will then alert you whenever your variable's value has been changed.
You can use hardware watchpoints.
You have to get the address of the variable you want to track (type p &my_var in gdb prompt).
It will print somehting like 0x12345678.
With gdb: type watch *(int *)0x12345678.
With lldb: watch set expression (int *)0x12345678 (or w s e (int *)0x12345678)
This assumes your variable is an int. It will create an hardware watchpoint on this address.
Hope this helps.
Yes.
Under the Run menu there is "Debugger" which provides a visual frontend to gdb.
Also, there is a breakpoint button next to the Build and Run button. You can click that and manage your breakpoints under Run > Manage Breakpoints.
I know this post is old but in case you are still wondering I posted a detailed answer here: In XCode 6 how can you set a watchpoint without stopping execution?

Xcode: finding a variable value while setting a breakpoint

I am a seasoned Visual Studio programmer, and when I set a breakpoint, I can open an intermediate window and type ?variableName to view the current value of the variable.
In Xcode however, I can't seem to find an equivalent. I can hover over the variable name when stepping through the code, but long strings are truncated in the view.
Is there an Xcode equivalent to the intermediate window of Visual Studio? If not, how can I set a breakpoint and watch the value (the full value in the case of longer strings)?
Many thanks,
Brett
Use the console window (under the Run menu - choose "Show console") and then it's a gdb debugger. Then you can issue:
po variableName
Another way is to hover over the variable, right-click (or [Ctrl]+[left-click]) and choose "Print Description". The output will be sent to the gdb console.
There is a debugger GUI you can open by clicking the little spray bottle next to the step commands (or through Run > Debugger). It has a GUI window with pretty much all the objects in the frame you're looking at and the current call stack.