[{"data":1,"prerenderedAt":3270},["ShallowReactive",2],{"navigation_docs_en":3,"-en-flutter-for-jobseekers-debugging-troubleshooting-performance":95,"-en-flutter-for-jobseekers-debugging-troubleshooting-performance-surround":3265},[4,16],{"title":5,"icon":6,"path":7,"stem":8,"children":9,"page":15},"Getting Started","i-lucide-rocket","\u002Fen\u002Fgetting-started","en\u002F1.getting-started",[10],{"title":11,"path":12,"stem":13,"icon":14},"Introduction","\u002Fen\u002Fgetting-started\u002Fintroduction","en\u002F1.getting-started\u002F1.introduction","i-lucide-house",false,{"title":17,"icon":18,"path":19,"stem":20,"children":21,"page":15},"Flutter for Jobseekers","i-lucide-briefcase","\u002Fen\u002Fflutter-for-jobseekers","en\u002F2.flutter-for-jobseekers",[22,27,32,37,42,47,52,57,62,67,72,77,82,86,91],{"title":23,"path":24,"stem":25,"icon":26},"Introduction to Flutter","\u002Fen\u002Fflutter-for-jobseekers\u002Fintroduction-to-flutter","en\u002F2.flutter-for-jobseekers\u002F1.introduction-to-flutter","i-lucide-history",{"title":28,"path":29,"stem":30,"icon":31},"Market Opportunities for Flutter Developers","\u002Fen\u002Fflutter-for-jobseekers\u002Fmarket-opportunities","en\u002F2.flutter-for-jobseekers\u002F2.market-opportunities","i-lucide-trending-up",{"title":33,"path":34,"stem":35,"icon":36},"Installing Flutter and Configuring Your IDE","\u002Fen\u002Fflutter-for-jobseekers\u002Finstalling-flutter","en\u002F2.flutter-for-jobseekers\u002F3.installing-flutter","i-lucide-wrench",{"title":38,"path":39,"stem":40,"icon":41},"Introduction to Widgets","\u002Fen\u002Fflutter-for-jobseekers\u002Fintroduction-to-widgets","en\u002F2.flutter-for-jobseekers\u002F4.introduction-to-widgets","i-lucide-blocks",{"title":43,"path":44,"stem":45,"icon":46},"Handling User Input","\u002Fen\u002Fflutter-for-jobseekers\u002Fhandling-user-input","en\u002F2.flutter-for-jobseekers\u002F5.handling-user-input","i-lucide-text-cursor-input",{"title":48,"path":49,"stem":50,"icon":51},"Using 3rd Party Libraries and External Assets","\u002Fen\u002Fflutter-for-jobseekers\u002Fusing-packages-and-assets","en\u002F2.flutter-for-jobseekers\u002F6.using-packages-and-assets","i-lucide-package",{"title":53,"path":54,"stem":55,"icon":56},"Working with APIs and Asynchronous Operations","\u002Fen\u002Fflutter-for-jobseekers\u002Fworking-with-apis-and-async","en\u002F2.flutter-for-jobseekers\u002F7.working-with-apis-and-async","i-lucide-cloud-download",{"title":58,"path":59,"stem":60,"icon":61},"Navigation and Routing","\u002Fen\u002Fflutter-for-jobseekers\u002Fnavigation-and-routing","en\u002F2.flutter-for-jobseekers\u002F8.navigation-and-routing","i-lucide-route",{"title":63,"path":64,"stem":65,"icon":66},"State Management and the BLoC","\u002Fen\u002Fflutter-for-jobseekers\u002Fstate-management-and-bloc","en\u002F2.flutter-for-jobseekers\u002F9.state-management-and-bloc","i-lucide-boxes",{"title":68,"path":69,"stem":70,"icon":71},"Reactivity and Platform-Specific Considerations","\u002Fen\u002Fflutter-for-jobseekers\u002Freactivity-and-platforms","en\u002F2.flutter-for-jobseekers\u002F910.reactivity-and-platforms","i-lucide-monitor-smartphone",{"title":73,"path":74,"stem":75,"icon":76},"Debugging, Troubleshooting, and Performance Considerations","\u002Fen\u002Fflutter-for-jobseekers\u002Fdebugging-troubleshooting-performance","en\u002F2.flutter-for-jobseekers\u002F911.debugging-troubleshooting-performance","i-lucide-bug",{"title":78,"path":79,"stem":80,"icon":81},"Creating Your First Application","\u002Fen\u002Fflutter-for-jobseekers\u002Fcreating-your-first-application","en\u002F2.flutter-for-jobseekers\u002F912.creating-your-first-application","i-lucide-cloud-sun",{"title":83,"path":84,"stem":85,"icon":18},"Finding Flutter Jobs","\u002Fen\u002Fflutter-for-jobseekers\u002Ffinding-flutter-jobs","en\u002F2.flutter-for-jobseekers\u002F913.finding-flutter-jobs",{"title":87,"path":88,"stem":89,"icon":90},"Preparing for and Succeeding in the Job Interview","\u002Fen\u002Fflutter-for-jobseekers\u002Fpreparing-for-the-job-interview","en\u002F2.flutter-for-jobseekers\u002F914.preparing-for-the-job-interview","i-lucide-messages-square",{"title":92,"path":93,"stem":94,"icon":61},"Your Road Ahead","\u002Fen\u002Fflutter-for-jobseekers\u002Fyour-road-ahead","en\u002F2.flutter-for-jobseekers\u002F915.your-road-ahead",{"id":96,"title":73,"body":97,"description":3258,"extension":3259,"links":3260,"meta":3261,"navigation":3262,"path":74,"seo":3263,"stem":75,"__hash__":3264},"docs_en\u002Fen\u002F2.flutter-for-jobseekers\u002F911.debugging-troubleshooting-performance.md",{"type":98,"value":99,"toc":3217},"minimark",[100,124,128,154,159,212,215,218,232,235,279,282,285,288,358,365,391,402,421,444,455,517,520,523,598,618,621,629,635,638,641,652,659,663,670,675,686,692,696,701,722,744,747,764,784,790,794,797,861,867,885,888,895,905,908,915,967,974,980,984,1009,1088,1095,1102,1108,1112,1129,1133,1150,1156,1160,1164,1186,1224,1231,1237,1241,1248,1251,1268,1271,1274,1291,1295,1298,1344,1350,1354,1357,1361,1395,1406,1439,1445,1449,1453,1478,1484,1488,1505,1520,1552,1555,1558,1565,1568,1580,1584,1587,1605,1609,1614,1622,1632,1638,1642,1653,1659,1663,1670,1673,1680,1686,1690,1693,1713,1717,1727,1733,1737,1747,1752,1758,1762,1773,1779,1783,1790,1797,1803,1807,1811,1818,1821,1833,1847,1858,1875,1881,1885,1889,1892,1921,1928,1956,1962,1966,1969,1975,1979,1983,1986,2009,2012,2034,2040,2044,2052,2069,2086,2092,2096,2109,2112,2115,2127,2130,2139,2142,2146,2155,2253,2260,2270,2276,2280,2284,2315,2396,2403,2410,2432,2438,2442,2446,2473,2487,2502,2514,2518,2530,2549,2555,2648,2655,2679,2695,2701,2705,2722,2726,2732,2738,2742,2756,2771,2777,2781,2797,2803,2807,2822,2825,2828,2835,2855,2867,2870,2874,2881,2884,2891,2894,2900,2904,2908,2911,2916,2923,2930,2934,2937,2940,2946,2953,2957,3020,3024,3045,3049,3070,3074,3213],[101,102,103,107],"u-page-hero",{},[104,105,73],"template",{"v-slot:title":106},"",[104,108,109,110,114,115,118,119,123],{"v-slot:description":106},"It is rare for software to come out the way we expect it to the first time we write our code. Rather than being a linear process of ",[111,112,113],"em",{},"write code"," → ",[111,116,117],{},"have working application",", it is a cycle of ",[120,121,122],"strong",{},"planning, writing, debugging, testing, and iterating",".",[125,126,127],"p",{},"In this chapter, we are going to focus on the debugging, testing, and iterating portions of the cycle, with a focus on learning what to do when our code goes wrong and improving the overall responsiveness of our applications.",[129,130,131,134,135,139,140,143,144,153],"note",{},[120,132,133],{},"Companion code:"," the publisher's repository holds this chapter's code as ",[136,137,138],"code",{},"Example 11.1","–",[136,141,142],{},"Example 11.3"," in the ",[145,146,150],"a",{"href":147,"rel":148},"https:\u002F\u002Fgithub.com\u002Fbpbpublications\u002FFlutter-for-Jobseekers\u002Ftree\u002Fmain\u002FChapter%2011",[149],"nofollow",[136,151,152],{},"Chapter 11"," folder; each code block below is labelled with its example number. Blocks without a label have no counterpart in the repository. The repository has conversion glitches of its own, so the code on this page follows the book (BPB Publications, n.d.).",[155,156,158],"h2",{"id":157},"chapter-overview","Chapter overview",[160,161,162,198,203],"card-group",{},[163,164,167],"card",{"icon":165,"title":166},"i-lucide-list","Structure",[168,169,170,174,177,180,183,186,189,192,195],"ul",{},[171,172,173],"li",{},"Debugging and troubleshooting concepts",[171,175,176],{},"Logging output to the debug console",[171,178,179],{},"Setting breakpoints and exploring runtime variables",[171,181,182],{},"Handling exceptions",[171,184,185],{},"Introduction to Flutter DevTools",[171,187,188],{},"Defining performance issues",[171,190,191],{},"Exploring profile mode",[171,193,194],{},"When a ListView is not a ListView",[171,196,197],{},"Optimizing widgets",[163,199,202],{"icon":200,"title":201},"i-lucide-target","Objectives","After completing this chapter, you will understand how to debug and troubleshoot your code when things are not going as expected. You will learn how to view variables as your code runs and manipulates them, and how to log output to a debug console. You will have learned about some of the different compilation modes for your application and the developer tools that ship with Flutter to take advantage of each of them. Finally, you will learn how to optimize your code to deliver a buttery-smooth experience for your users.",[163,204,207,208,211],{"icon":205,"title":206},"i-lucide-folder-code","Runnable example","The logging, timeout and exception demo and the three scrolling lists are also available as a runnable project with tests in ",[136,209,210],{},"examples\u002Fflutter_for_jobseekers_ch11\u002F",". The code on this page is shown as the book prints it, with conversion glitches fixed.",[155,213,173],{"id":214},"debugging-and-troubleshooting-concepts",[125,216,217],{},"Even the most seasoned developers spend a lot of time debugging and troubleshooting their code. It is a rare occurrence when your code works flawlessly the first time, so learning how to solve the problems you will come across is very important. Let us first start by defining what debugging and troubleshooting are.",[160,219,220,226],{},[163,221,223,225],{"icon":36,"title":222},"Troubleshooting",[111,224,222],{}," is solving a problem. You can think of troubleshooting as identifying and resolving a problem by fixing whatever issues prevented things from working correctly in the first place.",[163,227,229,231],{"icon":76,"title":228},"Debugging",[111,230,228],{}," is the process of going step by step through a problem to identify and resolve any errors.",[125,233,234],{},"Every problem to be solved by debugging can be broken down into five steps:",[236,237,239,244,247,251,254,258,265,269,272,276],"steps",{"level":238},"4",[240,241,243],"h4",{"id":242},"reproduce-it","Reproduce it",[125,245,246],{},"Ensure the error is reproduceable. If the error is intermittent, you have not properly identified the error.",[240,248,250],{"id":249},"confirm-it-is-the-right-problem","Confirm it is the right problem",[125,252,253],{},"Be certain that the problem you are debugging is the problem you need to be solving.",[240,255,257],{"id":256},"check-the-obvious","Check the obvious",[125,259,260,261,264],{},"Check all the obvious error sources. It is easy to waste time by debugging a ",[111,262,263],{},"complex"," problem that turns out to have a very simple and obvious solution.",[240,266,268],{"id":267},"debug-the-problem","Debug the problem",[125,270,271],{},"Isolate the problem by dividing it into working versus non-working components. Think like a computer: step through the instructions one at a time to find where the operation fails.",[240,273,275],{"id":274},"reassess","Reassess",[125,277,278],{},"If you are unable to identify the root cause of the problem, reassess the situation: what assumptions have you made that might be incorrect? Walk through the process again, taking notes and using knowledge learned from the last time.",[125,280,281],{},"Although these steps are seemingly quite simple, building the mindset and toolkit to approach and debug any problem takes time and practice. In each section of this chapter, we will discuss some of the different tools you can employ to help debug your Flutter project.",[155,283,176],{"id":284},"logging-output-to-the-debug-console",[125,286,287],{},"Sometimes it is useful to print some messages to the console while we debug a problem. Let us look at some pseudo-code (a code-like representation, often non-functional, which is used to illustrate a solution or mock out a problem):",[289,290,294],"pre",{"className":291,"code":292,"language":293,"meta":106,"style":106},"language-dart shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","Future\u003CMyObject?> getMyObject() async {\n  Map\u003CString, dynamic> result = await getResult();\n  MyObject object = MyObject.fromJson(result);\n\n  if (object.name.isEmpty) {\n    return null;\n  }\n\n  return object;\n}\n","dart",[136,295,296,304,310,316,323,329,335,341,346,352],{"__ignoreMap":106},[297,298,301],"span",{"class":299,"line":300},"line",1,[297,302,303],{},"Future\u003CMyObject?> getMyObject() async {\n",[297,305,307],{"class":299,"line":306},2,[297,308,309],{},"  Map\u003CString, dynamic> result = await getResult();\n",[297,311,313],{"class":299,"line":312},3,[297,314,315],{},"  MyObject object = MyObject.fromJson(result);\n",[297,317,319],{"class":299,"line":318},4,[297,320,322],{"emptyLinePlaceholder":321},true,"\n",[297,324,326],{"class":299,"line":325},5,[297,327,328],{},"  if (object.name.isEmpty) {\n",[297,330,332],{"class":299,"line":331},6,[297,333,334],{},"    return null;\n",[297,336,338],{"class":299,"line":337},7,[297,339,340],{},"  }\n",[297,342,344],{"class":299,"line":343},8,[297,345,322],{"emptyLinePlaceholder":321},[297,347,349],{"class":299,"line":348},9,[297,350,351],{},"  return object;\n",[297,353,355],{"class":299,"line":354},10,[297,356,357],{},"}\n",[125,359,360,361,364],{},"Our code will await a future result, build an object from it, check if the object's name property is null, and either returns a null object or the full object, respectively. What you might find is a situation in which this method ",[111,362,363],{},"always"," returns null, even when you are certain the object has a name.",[129,366,367,370,371,374,375,378,379,382,383,386,387,390],{},[120,368,369],{},"Corrected:"," the code checks whether the name is ",[111,372,373],{},"empty"," (",[136,376,377],{},"object.name.isEmpty","), not whether it is ",[136,380,381],{},"null","; ",[136,384,385],{},"name"," is a non-nullable ",[136,388,389],{},"String"," here.",[125,392,393,394,397,398,401],{},"The first and most obvious thing to do would be to ask Flutter to print out the name of the object, but how and where should we do that? First, we will need to import the ",[136,395,396],{},"dart:developer"," package to gain access to the ",[136,399,400],{},"log()"," method.",[403,404,405,406,409,410,412,413,416,417,420],"warning",{},"If you have imported the ",[136,407,408],{},"dart:math"," package, ",[136,411,400],{}," will already be defined as a method! In that case, do not fret, as you can use ",[136,414,415],{},"import 'dart:developer' as dev;"," to scope the package to a namespace. Then, use ",[136,418,419],{},"dev.log()"," to access the function.",[129,422,423,425,426,428,429,431,432,435,436,439,440,443],{},[120,424,369],{}," ",[136,427,396],{}," and ",[136,430,408],{}," are not packages but Dart core libraries; you import them with ",[136,433,434],{},"import 'dart:developer';"," and add nothing to ",[136,437,438],{},"pubspec.yaml"," (see the same note on ",[136,441,442],{},"dart:io"," in Chapter 10).",[125,445,446,447,450,451,454],{},"Do not worry about following along in your editor, since we have not defined ",[136,448,449],{},"MyObject"," or ",[136,452,453],{},"getResult()",". Instead, use this as a thought experiment:",[289,456,458],{"className":291,"code":457,"language":293,"meta":106,"style":106},"import 'dart:developer';\n\nFuture\u003CMyObject?> getMyObject() async {\n  Map\u003CString, dynamic> result = await getResult();\n  MyObject object = MyObject.fromJson(result);\n\n  log(\"The object's name is '${object.name}'\");\n  if (object.name.isEmpty) {\n    return null;\n  }\n\n  return object;\n}\n",[136,459,460,465,469,473,477,481,485,490,494,498,502,507,512],{"__ignoreMap":106},[297,461,462],{"class":299,"line":300},[297,463,464],{},"import 'dart:developer';\n",[297,466,467],{"class":299,"line":306},[297,468,322],{"emptyLinePlaceholder":321},[297,470,471],{"class":299,"line":312},[297,472,303],{},[297,474,475],{"class":299,"line":318},[297,476,309],{},[297,478,479],{"class":299,"line":325},[297,480,315],{},[297,482,483],{"class":299,"line":331},[297,484,322],{"emptyLinePlaceholder":321},[297,486,487],{"class":299,"line":337},[297,488,489],{},"  log(\"The object's name is '${object.name}'\");\n",[297,491,492],{"class":299,"line":343},[297,493,328],{},[297,495,496],{"class":299,"line":348},[297,497,334],{},[297,499,500],{"class":299,"line":354},[297,501,340],{},[297,503,505],{"class":299,"line":504},11,[297,506,322],{"emptyLinePlaceholder":321},[297,508,510],{"class":299,"line":509},12,[297,511,351],{},[297,513,515],{"class":299,"line":514},13,[297,516,357],{},[125,518,519],{},"On Line 7, we have our log message. The rules for accessing variables in a log message are the same as printing them in a string: use a dollar sign to denote the variable and wrap the variable in curly braces if you need to access a property of the variable.",[125,521,522],{},"Now, imagine we ran the code again and checked the log message. Unfortunately, the log message never shows up. What is going on here? Let us add some more logging to see if we can figure out where things are breaking:",[289,524,526],{"className":291,"code":525,"language":293,"meta":106,"style":106},"import 'dart:developer';\n\nFuture\u003CMyObject?> getMyObject() async {\n  log('About to run getResult()');\n  Map\u003CString, dynamic> result = await getResult();\n  log('The result is $result. Using it to create MyObject.');\n  MyObject object = MyObject.fromJson(result);\n  log('MyObject was created: $object');\n\n  log(\"The object's name is '${object.name}'\");\n  if (object.name.isEmpty) {\n    return null;\n  }\n\n  return object;\n}\n",[136,527,528,532,536,540,545,549,554,558,563,567,571,575,579,583,588,593],{"__ignoreMap":106},[297,529,530],{"class":299,"line":300},[297,531,464],{},[297,533,534],{"class":299,"line":306},[297,535,322],{"emptyLinePlaceholder":321},[297,537,538],{"class":299,"line":312},[297,539,303],{},[297,541,542],{"class":299,"line":318},[297,543,544],{},"  log('About to run getResult()');\n",[297,546,547],{"class":299,"line":325},[297,548,309],{},[297,550,551],{"class":299,"line":331},[297,552,553],{},"  log('The result is $result. Using it to create MyObject.');\n",[297,555,556],{"class":299,"line":337},[297,557,315],{},[297,559,560],{"class":299,"line":343},[297,561,562],{},"  log('MyObject was created: $object');\n",[297,564,565],{"class":299,"line":348},[297,566,322],{"emptyLinePlaceholder":321},[297,568,569],{"class":299,"line":354},[297,570,489],{},[297,572,573],{"class":299,"line":504},[297,574,328],{},[297,576,577],{"class":299,"line":509},[297,578,334],{},[297,580,581],{"class":299,"line":514},[297,582,340],{},[297,584,586],{"class":299,"line":585},14,[297,587,322],{"emptyLinePlaceholder":321},[297,589,591],{"class":299,"line":590},15,[297,592,351],{},[297,594,596],{"class":299,"line":595},16,[297,597,357],{},[125,599,600,425,603,606,607,609,610,613,614,617],{},[111,601,602],{},"Runnable copy:",[136,604,605],{},"examples\u002Fflutter_for_jobseekers_ch11\u002Flib\u002Fdebugging\u002Flogging.dart"," (with an assembled ",[136,608,449],{}," in ",[136,611,612],{},"lib\u002Fdebugging\u002Fmy_object.dart",", whose ",[136,615,616],{},"fromJson"," throws for an empty map)",[125,619,620],{},"Now if we run the code, here is what we might see:",[289,622,627],{"className":623,"code":625,"language":626,"meta":106},[624],"language-text","[log] About to run getResult()\n[log] The result is {}. Using it to create MyObject.\n","text",[136,628,625],{"__ignoreMap":106},[125,630,631,632,634],{},"It looks like we have isolated the problem using logging. Something about the ",[136,633,453],{}," method does not seem to be working. We will have to continue the troubleshooting with a different method, so let us head over to that method and figure out what is going on.",[155,636,179],{"id":637},"setting-breakpoints-and-exploring-runtime-variables",[125,639,640],{},"There are quicker and easier ways to debug than by inserting logging lines everywhere. Since you are unlikely to want to keep those lines in your code when you ship it, you will likely go back and delete them once you have fixed the problem. One way we can sidestep the whole process of writing and deleting code is by leveraging the tools of our Integrated Development Environment (IDE). In this case, our IDE is Visual Studio Code. Any decent and\u002For modern IDE will have similar functionality. While the details of how to use the tool changes from IDE to IDE, the concept is usually the same.",[129,642,643,644,647,648,651],{},"The concept we will be looking at is called the ",[120,645,646],{},"breakpoint",". A breakpoint is a point at which you intentionally stop or pause code execution at a specific point to assist in debugging. By setting a breakpoint, we tell the IDE to run the code normally until it reaches the line of code we have set a breakpoint for. Then, the program will pause and display information about the current state of the application. You will have the ability to ",[111,649,650],{},"step"," through lines of code to look at what is happening in a much slower way than normal.",[125,653,654,655,658],{},"Let us take our code from before and add a breakpoint (",[111,656,657],{},"Figure 11.1","). Once the breakpoint has been set, you will see a red dot next to the line number, indicating a breakpoint exists for that line of code. If the dot is grey instead of red, you will need to stop and restart your code. You will also see the breakpoint is added to the IDE's breakpoints list, including the filename and path of the file with a breakpoint, along with the line number.",[660,661,662],"tip",{},"Breakpoints can be toggled on and off by clicking the red dot next to the line number and temporarily disabled by unchecking the box next to the breakpoint in the list. A temporarily disabled breakpoint will not pause the execution of the program but can be re-enabled easily later by checking the box.",[125,664,665],{},[666,667],"img",{"alt":668,"src":669},"Figure 11.1: Setting a breakpoint in Visual Studio Code","\u002Fimages\u002Fflutter-for-jobseekers\u002Ffigure-11-1.png",[671,672,673],"blockquote",{},[125,674,668],{},[125,676,677,678,681,682,685],{},"Running our code with one or more breakpoints set will cause the program to pause once it hits the line(s) with the breakpoint(s). Once a line with a breakpoint has been reached, the debugger in the IDE will present us with some useful information. The current line that was being processed when a breakpoint was reached, will be highlighted. Additionally, the call stack will be populated with information about what code is currently being processed at the time the breakpoint has been reached. Each line (called a ",[120,679,680],{},"stack frame",") shows what function was running when the previous line was invoked. Refer to ",[111,683,684],{},"Figure 11.2"," for a visual of what happens when you reach a breakpoint.",[125,687,688],{},[666,689],{"alt":690,"src":691},"Figure 11.2: A breakpoint has been reached.","\u002Fimages\u002Fflutter-for-jobseekers\u002Ffigure-11-2.png",[671,693,694],{},[125,695,690],{},[697,698,700],"h3",{"id":699},"the-debugger-toolbar","The debugger toolbar",[125,702,703,704,715,716,721],{},"You may have noticed when running your code before that there are several little arrows in the same bar where you can stop or restart your code. Typically, the first icon would be a pause icon (",[666,705],{"alt":706,"src":707,":zoom":708,"className":709,"height":713,"width":714},"Pause icon","\u002Fimages\u002Fflutter-for-jobseekers\u002Ficon-debug-pause.png","false",[710,711,712],"inline","m-0","align-text-bottom",18,20,"); however, when the debug point is reached, it changes to a resume icon (",[666,717],{"alt":718,"src":719,":zoom":708,"className":720,"height":713,"width":714},"Resume icon","\u002Fimages\u002Fflutter-for-jobseekers\u002Ficon-debug-resume.png",[710,711,712],"). Let us talk about what each of the blue icons does, starting with the pause\u002Fresume icon.",[160,723,724,729,734,739],{},[163,725,728],{"icon":726,"title":727},"i-lucide-pause","Pause \u002F Resume","The most straightforward of the bunch. If your code is running as normal without triggering a breakpoint or pausing during an exception, you can press the button to pause processing and show all the same information that you would normally get from hitting a breakpoint. The resume icon resumes processing, regardless of how you entered a paused state.",[163,730,733],{"icon":731,"title":732},"i-lucide-redo","Step over","The second icon in the debugger toolbar. Pressing this button will run the next function in its entirety before pausing at the next function.",[163,735,738],{"icon":736,"title":737},"i-lucide-arrow-down-to-line","Step into","Runs the next line of code. This allows you to see the stack trace for each line of code, but also helps to isolate when a given line of code generates an error or other issue.",[163,740,743],{"icon":741,"title":742},"i-lucide-arrow-up-from-line","Step out","Runs the previous line of code.",[125,745,746],{},"The next three icons (step over, step into and step out) are only available while code execution has been paused.",[129,748,749,751,752,755,756,759,760,763],{},[120,750,369],{}," step into and step out do not run the \"next or previous\" line. Visual Studio Code's documentation describes them as: ",[120,753,754],{},"Step Over"," — \"Run the current line without stepping into function calls on that line\"; ",[120,757,758],{},"Step Into"," — \"Step into the function called on the current line\"; ",[120,761,762],{},"Step Out"," — \"Finish the current function and pause in the calling function\" (Microsoft, n.d.). The debugger never runs code backwards.",[125,765,766,767,770,771,774,775,777,778,781,782,123],{},"By using the step into and step out buttons, we can process the lines of code one-by-one until we come to the root of our problem. In ",[111,768,769],{},"Figure 11.3",", we see that the ",[136,772,773],{},"getResult"," method only returns an object with a ",[136,776,385],{}," if the ",[136,779,780],{},"future"," is not ",[136,783,708],{},[125,785,786],{},[666,787],{"alt":788,"src":789},"Figure 11.3: Using the step into and step out buttons, we can identify which line of code causes our problem.","\u002Fimages\u002Fflutter-for-jobseekers\u002Ffigure-11-3.png",[671,791,792],{},[125,793,788],{},[125,795,796],{},"Let us examine this code more closely:",[289,798,800],{"className":291,"code":799,"language":293,"meta":106,"style":106},"Future\u003CMap\u003CString, dynamic>> getResult() async {\n  bool? future = await Future.delayed(\n    const Duration(seconds: 5),\n  ).timeout(\n    const Duration(seconds: 1),\n    onTimeout: () {\n      return false;\n    },\n  );\n  if (future != false) return {'name': 'my object'};\n  return {};\n}\n",[136,801,802,807,812,817,822,827,832,837,842,847,852,857],{"__ignoreMap":106},[297,803,804],{"class":299,"line":300},[297,805,806],{},"Future\u003CMap\u003CString, dynamic>> getResult() async {\n",[297,808,809],{"class":299,"line":306},[297,810,811],{},"  bool? future = await Future.delayed(\n",[297,813,814],{"class":299,"line":312},[297,815,816],{},"    const Duration(seconds: 5),\n",[297,818,819],{"class":299,"line":318},[297,820,821],{},"  ).timeout(\n",[297,823,824],{"class":299,"line":325},[297,825,826],{},"    const Duration(seconds: 1),\n",[297,828,829],{"class":299,"line":331},[297,830,831],{},"    onTimeout: () {\n",[297,833,834],{"class":299,"line":337},[297,835,836],{},"      return false;\n",[297,838,839],{"class":299,"line":343},[297,840,841],{},"    },\n",[297,843,844],{"class":299,"line":348},[297,845,846],{},"  );\n",[297,848,849],{"class":299,"line":354},[297,850,851],{},"  if (future != false) return {'name': 'my object'};\n",[297,853,854],{"class":299,"line":504},[297,855,856],{},"  return {};\n",[297,858,859],{"class":299,"line":509},[297,860,357],{},[125,862,863,425,865],{},[111,864,602],{},[136,866,605],{},[125,868,869,870,872,873,875,876,878,879,425,882,884],{},"Here, we can see that the debugger tells us ",[136,871,780],{}," is equal to ",[136,874,708],{},". Looking at the line of code which checks the value of the future, we confirm that a valid object will only be returned if ",[136,877,780],{}," is equal to anything ",[111,880,881],{},"other than",[136,883,708],{},". Looking at the preceding lines, we see that the future waits several seconds, but times out before it completes. When it times out, false is returned. By using the debugging tools, we have isolated the area of code where the problem exists.",[660,886,887],{},"Although our example is a bit silly and not something you would be likely to find in production code, it helps to illustrate some of the concepts you will need to use when debugging your code. In a more realistic scenario, imagine an API call with a timeout to prevent long-running network requests from causing issues, such as blocking widgets from showing a proper error state. Learning how to use the debug tools in your IDE is key to helping you solve any problem you come across.",[125,889,890,891,123],{},"You can read more about Visual Studio Code's debugger on their website, ",[145,892,893],{"href":893,"rel":894},"https:\u002F\u002Fcode.visualstudio.com\u002Fdocs\u002Feditor\u002Fdebugging",[149],[129,896,897,899,900,904],{},[120,898,369],{}," that link now redirects to ",[145,901,902],{"href":902,"rel":903},"https:\u002F\u002Fcode.visualstudio.com\u002Fdocs\u002Fdebugtest\u002Fdebugging",[149]," (checked on 2026-11-16).",[155,906,182],{"id":907},"handling-exceptions",[125,909,910,911,914],{},"An exception occurs when something has gone wrong in our code and processing is unable to continue; otherwise, the program will crash. We can tell our code to ",[136,912,913],{},"throw"," exceptions when processing goes wrong, such as in this updated example from before:",[289,916,918],{"className":291,"code":917,"language":293,"meta":106,"style":106},"Future\u003CMap\u003CString, dynamic>> getResult() async {\n  await Future.delayed(\n    const Duration(seconds: 5),\n  ).timeout(\n    const Duration(seconds: 1),\n    onTimeout: () {\n      throw Exception('Operation timed out.');\n    },\n  );\n  return {'name': 'my object'};\n}\n",[136,919,920,924,929,933,937,941,945,950,954,958,963],{"__ignoreMap":106},[297,921,922],{"class":299,"line":300},[297,923,806],{},[297,925,926],{"class":299,"line":306},[297,927,928],{},"  await Future.delayed(\n",[297,930,931],{"class":299,"line":312},[297,932,816],{},[297,934,935],{"class":299,"line":318},[297,936,821],{},[297,938,939],{"class":299,"line":325},[297,940,826],{},[297,942,943],{"class":299,"line":331},[297,944,831],{},[297,946,947],{"class":299,"line":337},[297,948,949],{},"      throw Exception('Operation timed out.');\n",[297,951,952],{"class":299,"line":343},[297,953,841],{},[297,955,956],{"class":299,"line":348},[297,957,846],{},[297,959,960],{"class":299,"line":354},[297,961,962],{},"  return {'name': 'my object'};\n",[297,964,965],{"class":299,"line":504},[297,966,357],{},[125,968,969,970,973],{},"Here, instead of setting the future to a boolean value, we assume it will complete successfully and do not even bother checking the condition before returning a value from the function. Instead, we tell the future to throw an exception if the code times out. See ",[111,971,972],{},"Figure 11.4"," for how it looks when this happens:",[125,975,976],{},[666,977],{"alt":978,"src":979},"Figure 11.4: An exception has been thrown.","\u002Fimages\u002Fflutter-for-jobseekers\u002Ffigure-11-4.png",[671,981,982],{},[125,983,978],{},[125,985,986,987,990,991,994,995,997,998,1000,1001,1003,1004,990,1006,1008],{},"Now that we have an exception, we need to learn how to deal with them. One way we can deal with exceptions in our code is by using a ",[136,988,989],{},"try","\u002F",[136,992,993],{},"catch"," block. The code within the ",[136,996,989],{}," portion will run until an exception is thrown. In the case an exception is thrown, the code within the ",[136,999,993],{}," portion will run. Otherwise, the ",[136,1002,993],{}," code will be skipped. In this example, we have wrapped the function call in a ",[136,1005,989],{},[136,1007,993],{}," block:",[289,1010,1012],{"className":291,"code":1011,"language":293,"meta":106,"style":106},"Future\u003CMyObject?> getMyObject() async {\n  late Map\u003CString, dynamic> result;\n  try {\n    result = await getResult();\n  } catch (e) {\n    log('An exception occurred while running `getResult`: $e');\n    return null;\n  }\n\n  MyObject object = MyObject.fromJson(result);\n\n  if (object.name.isEmpty) {\n    return null;\n  }\n\n  return object;\n}\n",[136,1013,1014,1018,1023,1028,1033,1038,1043,1047,1051,1055,1059,1063,1067,1071,1075,1079,1083],{"__ignoreMap":106},[297,1015,1016],{"class":299,"line":300},[297,1017,303],{},[297,1019,1020],{"class":299,"line":306},[297,1021,1022],{},"  late Map\u003CString, dynamic> result;\n",[297,1024,1025],{"class":299,"line":312},[297,1026,1027],{},"  try {\n",[297,1029,1030],{"class":299,"line":318},[297,1031,1032],{},"    result = await getResult();\n",[297,1034,1035],{"class":299,"line":325},[297,1036,1037],{},"  } catch (e) {\n",[297,1039,1040],{"class":299,"line":331},[297,1041,1042],{},"    log('An exception occurred while running `getResult`: $e');\n",[297,1044,1045],{"class":299,"line":337},[297,1046,334],{},[297,1048,1049],{"class":299,"line":343},[297,1050,340],{},[297,1052,1053],{"class":299,"line":348},[297,1054,322],{"emptyLinePlaceholder":321},[297,1056,1057],{"class":299,"line":354},[297,1058,315],{},[297,1060,1061],{"class":299,"line":504},[297,1062,322],{"emptyLinePlaceholder":321},[297,1064,1065],{"class":299,"line":509},[297,1066,328],{},[297,1068,1069],{"class":299,"line":514},[297,1070,334],{},[297,1072,1073],{"class":299,"line":585},[297,1074,340],{},[297,1076,1077],{"class":299,"line":590},[297,1078,322],{"emptyLinePlaceholder":321},[297,1080,1081],{"class":299,"line":595},[297,1082,351],{},[297,1084,1086],{"class":299,"line":1085},17,[297,1087,357],{},[125,1089,1090,425,1092],{},[111,1091,602],{},[136,1093,1094],{},"examples\u002Fflutter_for_jobseekers_ch11\u002Flib\u002Fdebugging\u002Fexceptions.dart",[125,1096,1097,1098,1101],{},"Now, when we run our code, a log message is produced, but the exception does not stop the rest of our code from running (",[111,1099,1100],{},"Figure 11.5","):",[125,1103,1104],{},[666,1105],{"alt":1106,"src":1107},"Figure 11.5: The exception has been handled, allowing our code to continue running.","\u002Fimages\u002Fflutter-for-jobseekers\u002Ffigure-11-5.png",[671,1109,1110],{},[125,1111,1106],{},[403,1113,1114,1115,990,1117,1119,1120,1123,1124,990,1126,1128],{},"Sometimes, however, using a ",[136,1116,989],{},[136,1118,993],{}," can ",[120,1121,1122],{},"obfuscate problems entirely",", leading to frustration while debugging. In this case, we included a log message which logs the actual exception. If we had not done that, we would have no idea that an exception occurred. For this reason, you should consider using ",[136,1125,989],{},[136,1127,993],{}," blocks sparingly. Instead, writing more robust code should prevent many exceptions from happening in the first place, being sure to run appropriate checks on variables throughout the process and handling any error states that could occur.",[155,1130,1132],{"id":1131},"introduction-to-flutters-devtools","Introduction to Flutter's DevTools",[125,1134,1135,1136,1139,1140,1145,1146,1149],{},"Outside of your IDE's debugger, Flutter comes with a robust set of tools called ",[120,1137,1138],{},"DevTools",". DevTools comes with many different components, from a visual widget tree, layout explorer, and widget details tree to tools that help you visualize when a widget is rebuilt, a network inspector, and the ability to tap on any widget to jump straight to it in the code and within DevTools. By default, opening the DevTools by pressing the icon (",[666,1141],{"alt":1142,"src":1143,":zoom":708,"className":1144,"height":713,"width":713},"DevTools icon","\u002Fimages\u002Fflutter-for-jobseekers\u002Ficon-devtools.png",[710,711,712],") in the toolbar will drop you into the Widget Inspector, side-by-side with your code. See ",[111,1147,1148],{},"Figure 11.6"," for an example of the DevTools, after having been moved to its own tab:",[125,1151,1152],{},[666,1153],{"alt":1154,"src":1155},"Figure 11.6: Flutter's DevTools","\u002Fimages\u002Fflutter-for-jobseekers\u002Ffigure-11-6.png",[671,1157,1158],{},[125,1159,1154],{},[697,1161,1163],{"id":1162},"the-widget-inspector","The Widget Inspector",[125,1165,1166,1167,1170,1171,1174,1175,450,1178,1181,1182,1185],{},"There are far too many tools available in DevTools for us to cover here, so let us look at some of the most common tools, starting with the layout explorer. Selecting a widget from the widget tree will jump to the code where that widget is defined in the editor tab, then display information about the widget in the layout explorer. The layout explorer will give information about the ",[136,1168,1169],{},"RenderBox"," that your selected widget is contained within, as well as information about the constraints and sizing. If your widget is of a ",[136,1172,1173],{},"Flexible"," type, such as a ",[136,1176,1177],{},"Row",[136,1179,1180],{},"Column",", you will also be able to temporarily change the ",[136,1183,1184],{},"flex"," property to instantly see the changes in your app, all without having to write code.",[129,1187,1188,425,1190,428,1192,1194,1195,1198,1199,1201,1202,1204,1205,1207,1208,1211,1212,1215,1216,450,1218,1220,1221,1223],{},[120,1189,369],{},[136,1191,1177],{},[136,1193,1180],{}," are ",[136,1196,1197],{},"Flex"," widgets (both extend ",[136,1200,1197],{}," in the Flutter SDK), not ",[136,1203,1173],{}," ones. ",[136,1206,1173],{}," (and its subclass ",[136,1209,1210],{},"Expanded",") is the widget you wrap a ",[111,1213,1214],{},"child"," of a ",[136,1217,1177],{},[136,1219,1180],{}," in, and its ",[136,1222,1184],{}," property is the one you can change (flutter\u002Fflutter, n.d.).",[125,1225,1226,1227,1230],{},"Many applications will not have such a simple layout where it is quick and easy to find the exact widget you are looking for in the widget tree. If you have a particularly complex layout, you can search for a widget using the magnifying glass icon in the widget tree header (see ",[111,1228,1229],{},"Figure 11.7","). Using the search, you can search by things such as the widget type and properties:",[125,1232,1233],{},[666,1234],{"alt":1235,"src":1236},"Figure 11.7: Searching for a Widget","\u002Fimages\u002Fflutter-for-jobseekers\u002Ffigure-11-7.png",[671,1238,1239],{},[125,1240,1235],{},[125,1242,1243,1244,1247],{},"Another useful tool to find widgets in your widget tree is the ",[120,1245,1246],{},"Select widget mode",". Located to the top-left of the Widget Inspector panel is a button with a mouse cursor and, depending on the size of your window, a text label. Clicking this button will the ability for you to click or tap on any widget from directly within your application to focus on it in the layout explorer and widget tree, as well as within the code itself.",[125,1249,1250],{},"Once you have selected a widget in DevTools, additional details can be found in two tabs:",[160,1252,1253,1263],{},[163,1254,1257,1258,450,1260,1262],{"icon":1255,"title":1256},"i-lucide-layout-dashboard","Layout Explorer","Provides information about the widget's parent as well as its constraints and size. On some widgets, such as widgets that are the child of a ",[136,1259,1177],{},[136,1261,1180],{},", additional information about the widget's flex, fit, and alignment is available. Each of these values can be manipulated in DevTools to see how a corresponding change in the code would impact the application's layout, in real-time.",[163,1264,1267],{"icon":1265,"title":1266},"i-lucide-list-tree","Widget Details Tree","Lists all the properties a widget has, including all the properties that you have assigned to it. Furthermore, there is information about the render object and any associated state.",[125,1269,1270],{},"These tools are invaluable when tracking down issues in your application, as they help to shed light on precisely how the widget is composed.",[125,1272,1273],{},"The DevTools Widget Inspector also includes a host of other useful tools. The button toggles for each of these tools resides at the top of the Widget Inspector pane:",[168,1275,1276,1279,1282,1285,1288],{},[171,1277,1278],{},"options to slow down animations,",[171,1280,1281],{},"highlight widgets each time they repaint,",[171,1283,1284],{},"display an overlay consisting of widget boundaries and other layout information,",[171,1286,1287],{},"an option to show text baselines (to ensure text is aligned properly across widgets),",[171,1289,1290],{},"and to highlight images which are oversized and using too much memory.",[697,1292,1294],{"id":1293},"opening-the-other-devtools-panels","Opening the other DevTools panels",[125,1296,1297],{},"Flutter's DevTools are not limited to inspecting widgets. Although not immediately obvious at first, there are several other panes of useful tools.",[236,1299,1300,1304,1318,1322,1333,1337],{"level":238},[240,1301,1303],{"id":1302},"hover-over-the-language-status","Hover over the language status",[125,1305,1306,1307,1310,1311,1314,1315,1317],{},"Hover your cursor over the ",[120,1308,1309],{},"Editor Language Status"," field (which looks like ",[136,1312,1313],{},"{}",") at the bottom-left of Visual Studio Code, in the status bar. If the status item is not present, first check that your editor is focused on a Dart file (rather than, say, the Widget Inspector), and if all else fails, right click the status bar to ensure the ",[120,1316,1309],{}," option is checked.",[240,1319,1321],{"id":1320},"launch-dart-devtools","Launch Dart DevTools",[125,1323,1324,1325,1328,1329,1332],{},"On the line which says ",[120,1326,1327],{},"Dart DevTools",", click the ",[120,1330,1331],{},"Launch"," link.",[240,1334,1336],{"id":1335},"choose-a-panel","Choose a panel",[125,1338,1339,1340,1343],{},"A popup will appear asking you which part of DevTools you would like to open. See ",[111,1341,1342],{},"Figure 11.8"," for a visual reference.",[125,1345,1346],{},[666,1347],{"alt":1348,"src":1349},"Figure 11.8: The process of launching different parts of DevTools requires you to hover over an item in the status bar then click launch before choosing which panel to open","\u002Fimages\u002Fflutter-for-jobseekers\u002Ffigure-11-8.png",[671,1351,1352],{},[125,1353,1348],{},[125,1355,1356],{},"The various panels available to us are the Widget Inspector, which we have already discussed at length; the CPU Profiler, Memory, and Performance panels, which we will look at later in this chapter; the Network panel, Logging panel; and the option to launch DevTools in your Web browser. Let us look at the Logging and Network panels.",[697,1358,1360],{"id":1359},"the-logging-panel","The Logging panel",[125,1362,1363,1364,1367,1368,1371,1372,1374,1375,1378,1379,1382,1383,428,1385,1387,1388,1391,1392,123],{},"The ",[120,1365,1366],{},"Logging"," panel (see ",[111,1369,1370],{},"Figure 11.9",") includes a timeline of messages logged by your code and the Flutter framework throughout the lifecycle of your application. Each line in the timeline can be clicked to view the contents of the message. When using the ",[136,1373,396],{}," package, the ",[136,1376,1377],{},"print()"," function, or the ",[136,1380,1381],{},"debugPrint()"," function to log messages, you can find the output in the Logging panel. This is especially useful if your debug console is flooded with output while your app runs, as you can easily find the logged message by using the search feature or scrolling through the list. Take note that the ",[136,1384,1377],{},[136,1386,1381],{}," functions write to the ",[111,1389,1390],{},"standard output"," and will therefore be labelled with the kind ",[136,1393,1394],{},"stdout",[403,1396,1397,1398,428,1400,1402,1403,1405],{},"Additionally, do bear in mind that the ",[136,1399,1377],{},[136,1401,1381],{}," functions will only print the first 12,288 characters in a message. This can be especially frustrating if you are trying to log a large JSON response from an API, for example. If you find yourself frequently logging large pieces of data and not being able to see all of it in the Logging panel, switch to the ",[136,1404,400],{}," function and your woes will soon be gone.",[129,1407,1408,1410,1411,1414,1415,1418,1419,1422,1423,1426,1427,1429,1430,1432,1433,1435,1436,1438],{},[120,1409,369],{}," 12,288 is ",[136,1412,1413],{},"12 * 1024",", the ",[136,1416,1417],{},"_kDebugPrintCapacity"," of ",[136,1420,1421],{},"debugPrint","'s default implementation, ",[136,1424,1425],{},"debugPrintThrottled",". It is not a cut-off: once that many characters have been printed, ",[136,1428,1421],{}," pauses for a second and then prints the remaining lines, \"to avoid data loss on Android\" (flutter\u002Fflutter, n.d.). Plain ",[136,1431,1377],{}," does not go through this throttle. The 12,288 figure therefore says nothing about lost output; it only means that long ",[136,1434,1421],{}," output can arrive with a delay, and out of order with ",[136,1437,1377],{}," calls.",[125,1440,1441],{},[666,1442],{"alt":1443,"src":1444},"Figure 11.9: The logging tool, part of Flutter's DevTools","\u002Fimages\u002Fflutter-for-jobseekers\u002Ffigure-11-9.png",[671,1446,1447],{},[125,1448,1443],{},[697,1450,1452],{"id":1451},"the-network-panel","The Network panel",[125,1454,1455,1456,1459,1460,1463,1464,1467,1468,1467,1471,1474,1475,1477],{},"Now, let us look at the ",[120,1457,1458],{},"Network"," panel (",[111,1461,1462],{},"Figure 11.10","). This is where you can find some (but not all — more on that in a minute) network requests made by your application. You will find information about the location of the request (often, the URL), the method of the request (whether it is a ",[136,1465,1466],{},"GET",", ",[136,1469,1470],{},"PUT",[136,1472,1473],{},"POST",", and so on), the status, port number, content type, number of bytes read and written, and other useful information which can be used to gain insight into network connections. If you were to make a request to an API, for example, you could find the API's response in the detailed view on the ",[120,1476,1458],{}," panel.",[125,1479,1480],{},[666,1481],{"alt":1482,"src":1483},"Figure 11.10: The Network panel of Flutter's DevTools showing some activity","\u002Fimages\u002Fflutter-for-jobseekers\u002Ffigure-11-10.png",[671,1485,1486],{},[125,1487,1482],{},[403,1489,1490,1491,1494,1495,1499,1500,1504],{},"There are some limitations to be aware of with the Network panel, however. At the time of writing, only traffic generated using an ",[136,1492,1493],{},"HttpClient"," are visible (see the bug being tracked for this issue at ",[145,1496,1497],{"href":1497,"rel":1498},"https:\u002F\u002Fgithub.com\u002Fflutter\u002Fdevtools\u002Fissues\u002F4829",[149],"). There also appears to be an issue when developing in certain environments, such as within a Hyper-V Virtual Machine (see the bug filed here: ",[145,1501,1502],{"href":1502,"rel":1503},"https:\u002F\u002Fgithub.com\u002Fflutter\u002Fdevtools\u002Fissues\u002F4997",[149],"), but this should impact relatively few people. Still, it may be something worth considering if you are developing in such an environment.",[125,1506,1507,1508,1511,1512,1515,1516,1519],{},"Given the limitations of the Network panel in Flutter's DevTools, it may be wise to ",[111,1509,1510],{},"trust but verify"," when it comes to the data presented in it. ",[111,1513,1514],{},"If"," the network requests are present, you can be assured that they are valid and correct. However, for the time being, do not trust that ",[111,1517,1518],{},"all"," network requests will be present here. Until the team has had more time to flesh out this component of the DevTools, you may want to find other ways to inspect the network traffic of your application, if possible.",[129,1521,1522,1524,1525,1467,1528,428,1531,1534,1535,1538,1539,1541,1542,1544,1545,1548,1549,1551],{},[120,1523,369],{}," (checked on 2026-11-16) both issues are closed. #4829 was closed as completed on 2025-03-19: the ",[136,1526,1527],{},"cupertino_http",[136,1529,1530],{},"cronet_http",[136,1532,1533],{},"ok_http"," packages report their requests to DevTools through the ",[136,1536,1537],{},"http_profile"," package (flutter\u002Fdevtools, 2025a). Flutter's Network view documentation now says that all traffic from ",[136,1540,442],{}," (such as ",[136,1543,1493],{},", including the ",[136,1546,1547],{},"dio"," package) is logged, as is traffic logged with ",[136,1550,1537],{}," (Flutter, n.d.-c). #4997 (Hyper-V) was closed as not reproducible on 2025-07-07 (flutter\u002Fdevtools, 2025b).",[155,1553,188],{"id":1554},"defining-performance-issues",[125,1556,1557],{},"Before we dive into what tools Flutter gives us to analyze the performance of our applications, we should define a few key terms and ideas. First, it is relevant to reiterate the fact that Flutter was always designed to be 60 frames-per-second (fps) from the very start, and each release of Flutter and the underlying Dart programming language often finds new ways to increase performance without requiring changes to your code. Flutter is very good at rendering large numbers of widgets on the screen, even animating them every frame without slowdowns.",[660,1559,1560,1561,1564],{},"For this reason, it is important ",[120,1562,1563],{},"not to prematurely optimize your code",": it likely is not necessary! However, if you are noticing some of the issues we are about to define and discuss, it is a great time to consider optimizing your code.",[125,1566,1567],{},"The performance of an application can be broadly split into two categories:",[160,1569,1570,1575],{},[163,1571,1574],{"icon":1572,"title":1573},"i-lucide-hard-drive","Space","Issues where your app may be using too much memory, or the application package is too large. Flutter's DevTools have a tool to evaluate an app's package size, which can help you determine what is taking up so much space. There are also tools to help you determine what is taking up memory, which we will talk about in a little bit.",[163,1576,1579],{"icon":1577,"title":1578},"i-lucide-timer","Time","Time-related issues are a bit more complex, so let us talk about that.",[697,1581,1583],{"id":1582},"frames-and-vsync","Frames and vsync",[125,1585,1586],{},"Every device with a display will update that display at a fixed (or sometimes variable) refresh rate. For many devices these days, that is 60fps (which happens to be the target framerate of Flutter.) However, newer displays are capable of 100, 120, or even 240+ fps. That means the contents of the display are redrawn every 1\u002Fx seconds. For a 60fps display, the contents are redrawn every 1\u002F60th of a second.",[125,1588,1589,1590,1593,1594,1597,1598,1601,1602,1604],{},"Ok, but how does this relate to ",[111,1591,1592],{},"performance","? Simply put, this means Flutter has 1\u002F60th of a second to build and lay out all the widgets on the screen (called a ",[111,1595,1596],{},"frame",") before the next screen refresh interval, called the ",[136,1599,1600],{},"vsync",". Vsync is used to synchronize the refresh rate and the frame rate of the monitor to prevent tearing or when the screen displays information from multiple frames in a single screen draw. Tearing appears as a horizontal line across the screen where the image being displayed is split across one or more parts of the image. If a frame fails to build within ",[136,1603,1600],{}," period, it will not be rendered until it is completed building.",[697,1606,1608],{"id":1607},"jank","Jank",[125,1610,1611,1612,123],{},"Consider a spinning widget, rotating smoothly at 60fps. Suddenly, the widget appears to stop rotating, then a couple of frames later, snaps into the position it would have been in had it continued rotating smoothly. This phenomenon is called ",[111,1613,1607],{},[403,1615,1616,1618,1619,1621],{},[120,1617,1608],{}," occurs when a frame takes longer than the ",[136,1620,1600],{}," period to build. If the frame has not been built yet, it cannot be displayed.",[125,1623,1624,1625,1628,1629,1631],{},"In the following illustration (",[111,1626,1627],{},"Figure 11.11","), the ",[136,1630,1600],{}," period is marked by the dashed line, whereas the frame build time is denoted by rectangles:",[125,1633,1634],{},[666,1635],{"alt":1636,"src":1637},"Figure 11.11: A visual representation of jank","\u002Fimages\u002Fflutter-for-jobseekers\u002Ffigure-11-11.png",[671,1639,1640],{},[125,1641,1636],{},[125,1643,1644,1645,1648,1649,1652],{},"However, even if you manage to avoid jank by ensuring your frames are built within the vsync period, you are not completely out of the water yet. If your frames take the ",[111,1646,1647],{},"entire"," vsync period to build, your app will consume a lot more energy. This will lead to shorter battery life on mobile devices, and generally contributes to global warming. We ought to strive to avoid this scenario. ",[111,1650,1651],{},"Figure 11.12"," represents what it might look like if we do not have jank but are taking too long to build our frames:",[125,1654,1655],{},[666,1656],{"alt":1657,"src":1658},"Figure 11.12: When a frame takes too long to build but still finishes within the vsync period, it will consume more energy.","\u002Fimages\u002Fflutter-for-jobseekers\u002Ffigure-11-12.png",[671,1660,1661],{},[125,1662,1657],{},[125,1664,1665,1666,1669],{},"So, if we can ",[111,1667,1668],{},"see"," that there is jank in our app, how do we verify it and identify the widget(s) causing the problem? Likewise, how do we identify whether our app is using too much memory and fix it? To do that, we will need to explore profile mode.",[155,1671,191],{"id":1672},"exploring-profile-mode",[125,1674,1675,1676,1679],{},"Flutter can build your application in three different modes: debug mode, profile mode, and release mode (",[111,1677,1678],{},"Figure 11.13","). Up to this point, we have been focused on debug mode, as it is the default for development and the most common mode you will be using while writing applications.",[125,1681,1682],{},[666,1683],{"alt":1684,"src":1685},"Figure 11.13: Flutter's three modes of building an application","\u002Fimages\u002Fflutter-for-jobseekers\u002Ffigure-11-13.png",[671,1687,1688],{},[125,1689,1684],{},[125,1691,1692],{},"To run your application in profile mode, either choose the profile mode option from the dropdown in Visual Studio Code, or use the following command:",[289,1694,1698],{"className":1695,"code":1696,"language":1697,"meta":106,"style":106},"language-bash shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","flutter run --profile\n","bash",[136,1699,1700],{"__ignoreMap":106},[297,1701,1702,1706,1710],{"class":299,"line":300},[297,1703,1705],{"class":1704},"sBMFI","flutter",[297,1707,1709],{"class":1708},"sfazB"," run",[297,1711,1712],{"class":1708}," --profile\n",[697,1714,1716],{"id":1715},"the-performance-panel","The Performance panel",[125,1718,1719,1720,1723,1724,1101],{},"Once you are in profile mode, go ahead and open the ",[120,1721,1722],{},"Performance"," panel by pressing the leftmost button in the toolbar, next to the stop button (",[111,1725,1726],{},"Figure 11.14",[125,1728,1729],{},[666,1730],{"alt":1731,"src":1732},"Figure 11.14: The Performance panel in Flutter's DevTools is available only when running in profile mode","\u002Fimages\u002Fflutter-for-jobseekers\u002Ffigure-11-14.png",[671,1734,1735],{},[125,1736,1731],{},[125,1738,1739,1740,1742,1743,1746],{},"On the top of this panel is a graph, where the X-axis is the frame number, and the Y-axis is a measure of time. The bars are color-coded to correspond to different aspects of the frame compilation process. Bars in orange and red are jank and shader compilation, respectively, and are generally not something we want to see. Additionally, there is a horizontal line in the middle of the graph, marking the point at which a frame needs to be finished to avoid jank. In ",[111,1741,1726],{},", frame 59 comes in just below that line. In ",[111,1744,1745],{},"Figure 11.15",", frames 54 and 56 exceed it:",[129,1748,1749,1751],{},[120,1750,369],{}," Flutter's Performance view documentation marks janky frames in red (\"Selecting a janky frame (slow, colored in red)\") and shader compilation in dark red (\"Frames that perform shader compilation are marked in dark red\") (Flutter, n.d.-a), not orange and red.",[125,1753,1754],{},[666,1755],{"alt":1756,"src":1757},"Figure 11.15: The performance graph","\u002Fimages\u002Fflutter-for-jobseekers\u002Ffigure-11-15.png",[671,1759,1760],{},[125,1761,1756],{},[125,1763,1764,1765,1768,1769,1772],{},"Tapping on a frame will display details in the panel below (",[111,1766,1767],{},"Figure 11.16",") of what processes comprise a given frame compilation. Tapping on any event in the details view will give you even more details of that event, including precisely how many microseconds it took to run. By exploring the different processes that your widgets run, you can discover what operations are ",[111,1770,1771],{},"expensive"," (that is, they take a long time) and either avoid them entirely or use them sparingly.",[125,1774,1775],{},[666,1776],{"alt":1777,"src":1778},"Figure 11.16: Details of a timeline event","\u002Fimages\u002Fflutter-for-jobseekers\u002Ffigure-11-16.png",[671,1780,1781],{},[125,1782,1777],{},[125,1784,1785,1786,1789],{},"By default, it may be difficult to determine exactly which widget(s) are taking a long time to build. We can remedy this by enabling a more expensive (and thereby slower) option to track widget builds (",[111,1787,1788],{},"Figure 11.17","). By enabling this option, specific widgets will appear in the timeline event details panel, thereby making it far easier to track precisely which widgets are causing your application to have performance issues.",[403,1791,1792,1793,1796],{},"This operation will ",[120,1794,1795],{},"increase the frame build times",", so bear that in mind as you're evaluating performance when the option is toggled on.",[125,1798,1799],{},[666,1800],{"alt":1801,"src":1802},"Figure 11.17: Enabling the option to track widget builds","\u002Fimages\u002Fflutter-for-jobseekers\u002Ffigure-11-17.png",[671,1804,1805],{},[125,1806,1801],{},[697,1808,1810],{"id":1809},"the-performance-overlay","The performance overlay",[125,1812,1813,1814,1817],{},"Finally, there is a button to the left of the one we just pressed to enable tracking widget builds which will toggle a performance overlay directly on your application (",[111,1815,1816],{},"Figure 11.18","). This can provide more immediate feedback while using the application to identify which touches, drags, taps, and other actions cause slowdowns and jank. It may be easier to visualize these slowdowns with the performance overlay on the application, so your focus is not divided between interacting with the application and the tools in your IDE.",[125,1819,1820],{},"There are two graphs that will appear:",[160,1822,1823,1828],{},[163,1824,1827],{"icon":1825,"title":1826},"i-lucide-cpu","UI graph (bottom)","Measures everything your code does, including the Flutter framework itself. This is code that runs inside the Dart virtual machine. When your application runs code here, a layer tree is generated, which contains the commands needed to paint the UI to the screen.",[163,1829,1832],{"icon":1830,"title":1831},"i-lucide-monitor","Raster graph (top)","The layer tree is sent over to the raster thread, which is where Skia (or Impeller) is running. The raster thread will convert the layer tree into GPU commands to draw the UI on the device display.",[403,1834,1835,1836,1839,1840,1843,1844,123],{},"If the raster thread is busier than the UI thread, chances are high that you have built widgets that contain some ",[120,1837,1838],{},"expensive GPU commands",". This could be things like having overlapping elements with different opacities, widgets that have a clipping pattern applied (such as with the ",[136,1841,1842],{},"ClipRRect"," widget), shadows, or by using one of Flutter's most expensive operations, ",[136,1845,1846],{},"SaveLayer",[125,1848,1849,1850,1852,1853,1857],{},"For more information regarding ",[136,1851,1846],{},", the documentation found at ",[145,1854,1855],{"href":1855,"rel":1856},"https:\u002F\u002Fapi.flutter.dev\u002Fflutter\u002Fdart-ui\u002FCanvas\u002FsaveLayer.html",[149]," is an excellent resource.",[129,1859,1860,1862,1863,1866,1867,1870,1871,1874],{},[120,1861,369],{}," the method is ",[136,1864,1865],{},"saveLayer"," (lowercase ",[111,1868,1869],{},"s","), a method of ",[136,1872,1873],{},"Canvas","; its documentation says that \"Generally speaking, saveLayer is relatively expensive\" (Flutter, n.d.-d).",[125,1876,1877],{},[666,1878],{"alt":1879,"src":1880},"Figure 11.18: A performance overlay has been toggled on the running application","\u002Fimages\u002Fflutter-for-jobseekers\u002Ffigure-11-18.png",[671,1882,1883],{},[125,1884,1879],{},[697,1886,1888],{"id":1887},"the-cpu-profiler","The CPU Profiler",[125,1890,1891],{},"Next, we are going to be looking at the CPU Profiler, which will list all the various processes which occur during a recorded timeframe. To launch the CPU Profiler, you will use the same method we used before to launch the network and logging panels.",[236,1893,1894,1898,1904,1908,1911,1915],{"level":238},[240,1895,1897],{"id":1896},"record","Record",[125,1899,1900,1901,1903],{},"The CPU Profiler is an expensive process to run, so by default it will be empty. To get started, press the circle ",[120,1902,1897],{}," button at the top.",[240,1905,1907],{"id":1906},"interact","Interact",[125,1909,1910],{},"Perform one or more actions within your application.",[240,1912,1914],{"id":1913},"stop","Stop",[125,1916,1917,1918,1920],{},"Press the square ",[120,1919,1914],{}," button. Depending on how long you recorded for, it could take a while to process the results.",[125,1922,1923,1924,1927],{},"Once the results have been processed, you will see a tree view of each method called by your application, many of which you have not explicitly called yourself, but are called by widgets and methods you have used (see ",[111,1925,1926],{},"Figure 11.19","). Each item is an expandable list, where you can continue to drill down into the subsequent methods that have been called by the previous method. By examining this tree, you will be able to identify the most expensive operations which your application has performed.",[1929,1930,1931,1940,1947],"tabs",{},[1932,1933,1936,1937,123],"tabs-item",{"icon":1934,"label":1935},"i-lucide-arrow-up","Bottom Up","The default tab, which lists the method calls in reverse order from how they were performed. So, expanding a particular method call will show which method called it, the ",[111,1938,1939],{},"callers",[1932,1941,1943,1944,123],{"icon":1265,"label":1942},"Call Tree","If you would rather view a top-down view of method calls, switch to this tab, where the methods calls will expand into the list of methods they have called, the ",[111,1945,1946],{},"callees",[1932,1948,1951,1952,1955],{"icon":1949,"label":1950},"i-lucide-flame","CPU Flame Chart","The final tab (",[111,1953,1954],{},"Figure 11.20","). Much like the details displayed in the performance view, this shows a top-down call stack. In this instance, rather than being for a single frame, it is for the entire period which was recorded. The longer the line, the more CPU time the process took to complete.",[125,1957,1958],{},[666,1959],{"alt":1960,"src":1961},"Figure 11.19: A sampling recorded by the CPU Profiler","\u002Fimages\u002Fflutter-for-jobseekers\u002Ffigure-11-19.png",[671,1963,1964],{},[125,1965,1960],{},[125,1967,1968],{},"The flame chart can be interpreted as a top-down stack frame, much like the call tree. Rather than having an expandable list, however, the information is presented more visually. This view is an excellent tool for quickly identifying expensive operations, due to the correlation between the length of the bar and the amount of CPU time taken to perform that operation. At a glance, it is easy to pick out widgets and operations which should be investigated for performance improvements.",[125,1970,1971],{},[666,1972],{"alt":1973,"src":1974},"Figure 11.20: The CPU Flame Chart tab of the CPU Profiler","\u002Fimages\u002Fflutter-for-jobseekers\u002Ffigure-11-20.png",[671,1976,1977],{},[125,1978,1973],{},[697,1980,1982],{"id":1981},"the-memory-tool","The Memory tool",[125,1984,1985],{},"Lastly comes the memory tool. This tool can help you to identify which aspects of your application are taking up precious system memory.",[160,1987,1988,2001],{},[163,1989,1992,1993,1996,1997,2000],{"icon":1990,"title":1991},"i-lucide-memory-stick","Memory (RAM)","All computers have a finite amount of memory, also called ",[120,1994,1995],{},"random access memory (RAM)",". Memory is much more limited in quantity and ",[111,1998,1999],{},"volatile",", meaning anything stored in system memory is erased when the device is shut down or rebooted.",[163,2002,2004,2005,2008],{"icon":1572,"title":2003},"Storage","System storage is ",[111,2006,2007],{},"different",": it is used for the long-term storage of files, folders, and documents that persist even when the device is shut down or rebooted.",[125,2010,2011],{},"Due to the nature of memory, it is one of the most precious resources on a computing device. Any action you want the CPU to take will require loading information into the RAM before it can be processed. This means that when you want to read a file off the disk and display it on the screen, the contents of the file are loaded into RAM before being processed by the CPU and drawn to the display. Modern computing devices and programming languages have all sorts of tricks up their sleeve to optimize memory utilization, and Flutter is no different in this regard.",[125,2013,2014,2015,1418,2018,2021,2022,2025,2026,2029,2030,2033],{},"If, for example, you want to display a ",[136,2016,2017],{},"ListView",[136,2019,2020],{},"ListTile","s with ",[136,2023,2024],{},"Text"," widgets containing an incrementing list of numbers, the list of numbers will need to be stored in memory (as well as everything else Flutter needs to perform the computation and layout.) In ",[111,2027,2028],{},"Figure 11.21",", we have opened the memory tool and found the ",[136,2031,2032],{},"Paragraph"," class, where we are able to see that there are 2,000 instances consuming a total of 93.8 KB of memory.",[125,2035,2036],{},[666,2037],{"alt":2038,"src":2039},"Figure 11.21: The Memory view of DevTools in Profile mode","\u002Fimages\u002Fflutter-for-jobseekers\u002Ffigure-11-21.png",[671,2041,2042],{},[125,2043,2038],{},[125,2045,2046,2047,2051],{},"Due to a bug in DevTools (",[145,2048,2049],{"href":2049,"rel":2050},"https:\u002F\u002Fgithub.com\u002Fflutter\u002Fdevtools\u002Fissues\u002F5174",[149],"), we will need to temporarily switch back to debug mode for the next task. This bug may be resolved by the time you are reading this, so check the status of the bug before switching to debug mode.",[129,2053,2054,2056,2057,2060,2061,2064,2065,2068],{},[120,2055,369],{}," (checked on 2026-11-16) issue #5174 (",[111,2058,2059],{},"Memory: enable allocation tracing for profile mode.",") was closed as completed on 2024-01-19, by pull request #7058 (flutter\u002Fdevtools, 2024). The tab the book calls ",[120,2062,2063],{},"Trace"," is named ",[120,2066,2067],{},"Trace Instances"," in Flutter's Memory view documentation (Flutter, n.d.-b).",[125,2070,2071,2072,2074,2075,2078,2079,2081,2082,2085],{},"Continuing along, if we switch to the ",[120,2073,2063],{}," tab, we will get a list of all the objects used by the framework to build the screen. We can then track these objects by checking the box(es), interacting with the application, then pressing the ",[120,2076,2077],{},"Refresh"," button on the ",[120,2080,2063],{}," tab, which will then place a dot in the graph when that object is created (",[111,2083,2084],{},"Figure 11.22","). By selectively choosing potentially memory consuming widgets to track, you can get a sense of how many of these widgets are being created and whether it matches your expectations. More on this in a bit.",[125,2087,2088],{},[666,2089],{"alt":2090,"src":2091},"Figure 11.22: Tracking Text widget creation","\u002Fimages\u002Fflutter-for-jobseekers\u002Ffigure-11-22.png",[671,2093,2094],{},[125,2095,2090],{},[129,2097,2098,2099,1467,2102,2105,2106,2108],{},"It's unlikely that you will spend much time in performance mode or using the ",[120,2100,2101],{},"CPU Profiler",[120,2103,2104],{},"Memory",", and ",[120,2107,1722],{}," tabs while you are early in your Flutter career. These tools are often used by senior Flutter developers to analyze the application and determine which steps they and their team should take to improve the application. However, this very brief overview will familiarize you with what tools are available and how some of them can be used, hopefully planting a seed of curiosity, and giving you the tools necessary to answer questions in the future.",[125,2110,2111],{},"Some of these tools can feel overwhelming to use. There is a lot of information being thrown at you by them, and not all of it will make sense. Thankfully, as we covered at the beginning of this chapter, Flutter does a great job of optimizing layouts right out of the box. The tools listed here are useful when you notice jank, high memory usage by your application, and other unexplained slowdowns. For the most part, unless your task is to explicitly find performance improvements to optimize your application, you likely will not be using these tools very often. However, the fact that they exist and knowing what they do is valuable information in and of itself.",[155,2113,194],{"id":2114},"when-a-listview-is-not-a-listview",[125,2116,2117,2118,2120,2121,2123,2124,2126],{},"Now that we have explored the various profiling tools available to us, let us put them to use. First, let us consider the section's title: When a ",[136,2119,2017],{}," is not a ",[136,2122,2017],{},". To understand that we must first understand what a ",[136,2125,2017],{}," is and why you would want to use it.",[125,2128,2129],{},"Using our earlier example of a list of integers, let us say we want to display them in a vertically scrolling list of widgets. First, let us generate a list of integers:",[289,2131,2133],{"className":291,"code":2132,"language":293,"meta":106,"style":106},"final List\u003Cint> integerList = List\u003Cint>.generate(2000, (index) => index);\n",[136,2134,2135],{"__ignoreMap":106},[297,2136,2137],{"class":299,"line":300},[297,2138,2132],{},[125,2140,2141],{},"This gives us a list of integers from 0 to 1,999, with a total of 2,000 integers.",[697,2143,2145],{"id":2144},"a-scrollable-column","A scrollable Column",[125,2147,2148,2149,2151,2152,2154],{},"Next, let us try creating a series of ",[136,2150,2024],{}," widgets in a ",[136,2153,1180],{}," that we have made scrollable. Here is what that would look like:",[289,2156,2159],{"className":291,"code":2157,"filename":2158,"language":293,"meta":106,"style":106},"class MyScrollingList extends StatelessWidget {\n  const MyScrollingList({super.key});\n\n  @override\n  Widget build(BuildContext context) {\n    final List\u003Cint> integerList = List\u003Cint>.generate(2000, (index) => index);\n\n    return SingleChildScrollView(\n      child: Column(\n        children: \u003CWidget>[\n          for (final int i in integerList)\n          ListTile(\n            title: Text('$i'),\n          ),\n        ],\n      ),\n    );\n  }\n}\n","Example 11.1 · Example 11.1.dart",[136,2160,2161,2166,2171,2175,2180,2185,2190,2194,2199,2204,2209,2214,2219,2224,2229,2234,2239,2244,2248],{"__ignoreMap":106},[297,2162,2163],{"class":299,"line":300},[297,2164,2165],{},"class MyScrollingList extends StatelessWidget {\n",[297,2167,2168],{"class":299,"line":306},[297,2169,2170],{},"  const MyScrollingList({super.key});\n",[297,2172,2173],{"class":299,"line":312},[297,2174,322],{"emptyLinePlaceholder":321},[297,2176,2177],{"class":299,"line":318},[297,2178,2179],{},"  @override\n",[297,2181,2182],{"class":299,"line":325},[297,2183,2184],{},"  Widget build(BuildContext context) {\n",[297,2186,2187],{"class":299,"line":331},[297,2188,2189],{},"    final List\u003Cint> integerList = List\u003Cint>.generate(2000, (index) => index);\n",[297,2191,2192],{"class":299,"line":337},[297,2193,322],{"emptyLinePlaceholder":321},[297,2195,2196],{"class":299,"line":343},[297,2197,2198],{},"    return SingleChildScrollView(\n",[297,2200,2201],{"class":299,"line":348},[297,2202,2203],{},"      child: Column(\n",[297,2205,2206],{"class":299,"line":354},[297,2207,2208],{},"        children: \u003CWidget>[\n",[297,2210,2211],{"class":299,"line":504},[297,2212,2213],{},"          for (final int i in integerList)\n",[297,2215,2216],{"class":299,"line":509},[297,2217,2218],{},"          ListTile(\n",[297,2220,2221],{"class":299,"line":514},[297,2222,2223],{},"            title: Text('$i'),\n",[297,2225,2226],{"class":299,"line":585},[297,2227,2228],{},"          ),\n",[297,2230,2231],{"class":299,"line":590},[297,2232,2233],{},"        ],\n",[297,2235,2236],{"class":299,"line":595},[297,2237,2238],{},"      ),\n",[297,2240,2241],{"class":299,"line":1085},[297,2242,2243],{},"    );\n",[297,2245,2246],{"class":299,"line":713},[297,2247,340],{},[297,2249,2251],{"class":299,"line":2250},19,[297,2252,357],{},[125,2254,2255,425,2257],{},[111,2256,602],{},[136,2258,2259],{},"examples\u002Fflutter_for_jobseekers_ch11\u002Flib\u002Fscrolling\u002Fcolumn_list.dart",[125,2261,2262,2263,2266,2267,2269],{},"Let us run this in profile mode and scroll the list a bit to see what the performance looks like. As you can see in ",[111,2264,2265],{},"Figure 11.23",", there is a lot of jank when scrolling this list. Even though our app is incredibly simple, consisting only of a column of 2,000 ",[136,2268,2020],{}," widgets, each displaying a single integer, scrolling the list causes jank. Running the same code on a less powerful machine than a high-end computer, such as a smart phone, would certainly result in even more jank.",[125,2271,2272],{},[666,2273],{"alt":2274,"src":2275},"Figure 11.23: There's a lot of jank when scrolling","\u002Fimages\u002Fflutter-for-jobseekers\u002Ffigure-11-23.png",[671,2277,2278],{},[125,2279,2274],{},[697,2281,2283],{"id":2282},"listviewbuilder","ListView.builder",[125,2285,2286,2287,2289,2290,2293,2294,2296,2297,2300,2301,2303,2304,2307,2308,2311,2312,2314],{},"Now, let us rewrite this to use a ",[136,2288,2017],{}," widget. In this example, we have removed the ",[136,2291,2292],{},"SingleChildScrollView"," and the ",[136,2295,1180],{},", replacing both with the ",[136,2298,2299],{},"ListView.builder()",". We tell the ",[136,2302,2017],{}," how many items there will be in the list using the ",[136,2305,2306],{},"itemCount"," parameter, then use the ",[136,2309,2310],{},"itemBuilder"," to build the ",[136,2313,2020],{}," widgets. Note that there is no longer a for-loop in this code, as the builder takes care of this for us:",[289,2316,2319],{"className":291,"code":2317,"filename":2318,"language":293,"meta":106,"style":106},"class MyScrollingList extends StatelessWidget {\n  const MyScrollingList({super.key});\n\n  @override\n  Widget build(BuildContext context) {\n    final List\u003Cint> integerList = List\u003Cint>.generate(2000, (index) => index);\n\n    return ListView.builder(\n      itemCount: integerList.length,\n      itemBuilder: (BuildContext context, int i) {\n        return ListTile(\n          title: Text('$i'),\n        );\n      },\n    );\n  }\n}\n","Example 11.2 · Example 11.2.dart",[136,2320,2321,2325,2329,2333,2337,2341,2345,2349,2354,2359,2364,2369,2374,2379,2384,2388,2392],{"__ignoreMap":106},[297,2322,2323],{"class":299,"line":300},[297,2324,2165],{},[297,2326,2327],{"class":299,"line":306},[297,2328,2170],{},[297,2330,2331],{"class":299,"line":312},[297,2332,322],{"emptyLinePlaceholder":321},[297,2334,2335],{"class":299,"line":318},[297,2336,2179],{},[297,2338,2339],{"class":299,"line":325},[297,2340,2184],{},[297,2342,2343],{"class":299,"line":331},[297,2344,2189],{},[297,2346,2347],{"class":299,"line":337},[297,2348,322],{"emptyLinePlaceholder":321},[297,2350,2351],{"class":299,"line":343},[297,2352,2353],{},"    return ListView.builder(\n",[297,2355,2356],{"class":299,"line":348},[297,2357,2358],{},"      itemCount: integerList.length,\n",[297,2360,2361],{"class":299,"line":354},[297,2362,2363],{},"      itemBuilder: (BuildContext context, int i) {\n",[297,2365,2366],{"class":299,"line":504},[297,2367,2368],{},"        return ListTile(\n",[297,2370,2371],{"class":299,"line":509},[297,2372,2373],{},"          title: Text('$i'),\n",[297,2375,2376],{"class":299,"line":514},[297,2377,2378],{},"        );\n",[297,2380,2381],{"class":299,"line":585},[297,2382,2383],{},"      },\n",[297,2385,2386],{"class":299,"line":590},[297,2387,2243],{},[297,2389,2390],{"class":299,"line":595},[297,2391,340],{},[297,2393,2394],{"class":299,"line":1085},[297,2395,357],{},[125,2397,2398,425,2400],{},[111,2399,602],{},[136,2401,2402],{},"examples\u002Fflutter_for_jobseekers_ch11\u002Flib\u002Fmain.dart",[125,2404,2405,2406,2409],{},"Now that we have updated our code, let us run the same test: scroll the list of integers and see what the performance looks like (",[111,2407,2408],{},"Figure 11.24","). What we are looking for here is a performance improvement, ideally in the form of frames being rendered in less time and with no jank present.",[660,2411,2412,2413,2416,2417,2420,2421,2424,2425,2427,2428,2431],{},"Extraordinarily, there is absolutely ",[120,2414,2415],{},"no jank"," and frame times have been reduced to just a few ",[111,2418,2419],{},"microseconds",", when compared to the tens of ",[111,2422,2423],{},"milliseconds"," that the previous solution offered. It is clear by this test that the ",[136,2426,2017],{}," is far more efficient, but ",[111,2429,2430],{},"why","?",[125,2433,2434],{},[666,2435],{"alt":2436,"src":2437},"Figure 11.24: Scrolling performance of a ListView","\u002Fimages\u002Fflutter-for-jobseekers\u002Ffigure-11-24.png",[671,2439,2440],{},[125,2441,2436],{},[697,2443,2445],{"id":2444},"why-the-listview-is-faster","Why the ListView is faster",[160,2447,2448,2462],{},[163,2449,2451,2452,2454,2455,2457,2458,2461],{"icon":2450,"title":1180},"i-lucide-rows-4","When a ",[136,2453,1180],{}," is created, all its children are built each frame. When we have 2,000 ",[136,2456,2020],{}," widgets being built each frame, that is a lot of work for the CPU to handle, especially when we start scrolling. If we are not scrolling, Flutter is smart enough not to perform any unnecessary widget rebuilds because it knows that there is no animation happening, no state changes, and performing a rebuild of the widget would give us the ",[111,2459,2460],{},"same"," widget we started with. Thus, when no action is taken, the build process never happens.",[163,2463,2465,2466,2468,2469,2472],{"icon":2464,"title":2017},"i-lucide-scroll-text","A ",[136,2467,2017],{}," will build ",[111,2470,2471],{},"only the widgets displayed on screen"," (plus a couple on either end, if applicable) at any given time. If the constraints of our list are such that only three items can fit on the screen at any given time, only about 5-10 or so widgets will be built. (That is the three that are on screen, and a couple each on the above and below.) When the list is scrolled, widgets falling outside of the possible range where they are either shown on screen or could immediately be shown on screen are removed from the widget tree, freeing memory in the process.",[125,2474,2475,2476,2479,2480,2482,2483,2486],{},"In that instance, it does not matter how many widgets we have built… or does it? It ",[111,2477,2478],{},"does",", in fact, matter. Each widget consumes memory. If, instead of displaying an integer, we had a list of images, the memory size would balloon out of control as all 2,000 images were being loaded into memory when the ",[136,2481,1180],{}," was initially built, and then ",[111,2484,2485],{},"every frame"," as we scroll.",[129,2488,2489,2491,2492,2495,2496,2498,2499,2501],{},[120,2490,369],{}," scrolling does not ",[111,2493,2494],{},"rebuild"," the ",[136,2497,1180],{},"'s children each frame. The runnable copy's tests count builds and paints per item while scrolling a test-only copy of this list: none of the 2,000 items is rebuilt, but all 2,000 are painted again, because a ",[136,2500,1180],{}," paints every child whether or not it is on screen. Since nothing is rebuilt, images would not be loaded again every frame either; the memory problem is that all 2,000 stay in memory.",[125,2503,2504,2505,2507,2508,2510,2511,2513],{},"This is precisely why the ",[136,2506,2017],{}," is so much more performant than a ",[136,2509,1180],{}," when dealing with a large list of children. That is not to say a ",[136,2512,1180],{}," does not have its place — it absolutely does — but knowing the difference between the two can mean the difference between an application with jank and an application with smooth scrolling.",[697,2515,2517],{"id":2516},"the-shrink-wrapped-listview","The shrink-wrapped ListView",[125,2519,2520,2521,2524,2525,2527,2528,2431],{},"So, back to the original question: when ",[111,2522,2523],{},"is"," a ",[136,2526,2017],{}," not a ",[136,2529,2017],{},[2531,2532,2533,2534,2495,2537,2539,2540,2542,2543,2546,2547,123],"caution",{},"The answer is: when we ",[120,2535,2536],{},"shrinkwrap",[136,2538,2017],{},". Normally, the ",[136,2541,2017],{}," will fill its constraints, culling off-screen widgets in the process. However, if we specify the ",[136,2544,2545],{},"shrinkWrap: true"," property, the entire widget will act more like a ",[136,2548,1180],{},[125,2550,2551,2552,2554],{},"This could be useful if you needed a small number of widgets in a list, each being built using a builder rather than composed independently and inserted into a ",[136,2553,1180],{},". It is not an impossible situation to imagine. However, not understanding the implications of setting the property on a much larger list can lead to problems. Let us look at an example:",[289,2556,2559],{"className":291,"code":2557,"filename":2558,"language":293,"meta":106,"style":106},"class MyScrollingList extends StatelessWidget {\n  const MyScrollingList({super.key});\n\n  @override\n  Widget build(BuildContext context) {\n    final List\u003Cint> integerList = List\u003Cint>.generate(2000, (index) => index);\n\n    return SingleChildScrollView(\n      child: ListView.builder(\n        shrinkWrap: true,\n        itemCount: integerList.length,\n        itemBuilder: (BuildContext context, int i) {\n          return ListTile(\n            title: Text('$i'),\n          );\n        },\n      ),\n    );\n  }\n}\n","Example 11.3 · Example 11.3.dart",[136,2560,2561,2565,2569,2573,2577,2581,2585,2589,2593,2598,2603,2608,2613,2618,2622,2627,2632,2636,2640,2644],{"__ignoreMap":106},[297,2562,2563],{"class":299,"line":300},[297,2564,2165],{},[297,2566,2567],{"class":299,"line":306},[297,2568,2170],{},[297,2570,2571],{"class":299,"line":312},[297,2572,322],{"emptyLinePlaceholder":321},[297,2574,2575],{"class":299,"line":318},[297,2576,2179],{},[297,2578,2579],{"class":299,"line":325},[297,2580,2184],{},[297,2582,2583],{"class":299,"line":331},[297,2584,2189],{},[297,2586,2587],{"class":299,"line":337},[297,2588,322],{"emptyLinePlaceholder":321},[297,2590,2591],{"class":299,"line":343},[297,2592,2198],{},[297,2594,2595],{"class":299,"line":348},[297,2596,2597],{},"      child: ListView.builder(\n",[297,2599,2600],{"class":299,"line":354},[297,2601,2602],{},"        shrinkWrap: true,\n",[297,2604,2605],{"class":299,"line":504},[297,2606,2607],{},"        itemCount: integerList.length,\n",[297,2609,2610],{"class":299,"line":509},[297,2611,2612],{},"        itemBuilder: (BuildContext context, int i) {\n",[297,2614,2615],{"class":299,"line":514},[297,2616,2617],{},"          return ListTile(\n",[297,2619,2620],{"class":299,"line":585},[297,2621,2223],{},[297,2623,2624],{"class":299,"line":590},[297,2625,2626],{},"          );\n",[297,2628,2629],{"class":299,"line":595},[297,2630,2631],{},"        },\n",[297,2633,2634],{"class":299,"line":1085},[297,2635,2238],{},[297,2637,2638],{"class":299,"line":713},[297,2639,2243],{},[297,2641,2642],{"class":299,"line":2250},[297,2643,340],{},[297,2645,2646],{"class":299,"line":714},[297,2647,357],{},[125,2649,2650,425,2652],{},[111,2651,602],{},[136,2653,2654],{},"examples\u002Fflutter_for_jobseekers_ch11\u002Flib\u002Fscrolling\u002Fshrink_wrap_list.dart",[129,2656,2657,2659,2660,2662,2663,2665,2666,2669,2670,2672,2673,2675,2676,2678],{},[120,2658,369],{}," as printed, this list does not scroll with a touch drag: the inner ",[136,2661,2017],{}," has its own scrollable, takes the drag, and has nowhere to scroll, so the ",[136,2664,2292],{}," never moves (a mouse wheel, as on the book's desktop, still scrolls it). The runnable copy adds ",[136,2667,2668],{},"physics: const NeverScrollableScrollPhysics()"," to the ",[136,2671,2017],{},", which hands the drag to the ",[136,2674,2292],{},"; its tests check both behaviors. It still builds all 2,000 ",[136,2677,2020],{},"s.",[125,2680,2681,2682,2684,2685,2687,2688,2690,2691,2694],{},"Here, we have taken our highly performant ",[136,2683,2017],{}," and added the ",[136,2686,2545],{}," property, then wrapped the whole thing in a ",[136,2689,2292],{},". We will perform the same scrolling performance test as before, with the results as shown in ",[111,2692,2693],{},"Figure 11.25",":",[125,2696,2697],{},[666,2698],{"alt":2699,"src":2700},"Figure 11.25: Jank introduced by treating a ListView like a Column","\u002Fimages\u002Fflutter-for-jobseekers\u002Ffigure-11-25.png",[671,2702,2703],{},[125,2704,2699],{},[125,2706,2707,2708,2711,2712,2714,2715,2717,2718,2721],{},"Without a doubt, there is a lot of jank, and the frame times are ",[111,2709,2710],{},"way"," up. As you can see, even though we are using the much more performant ",[136,2713,2299],{}," rather than a ",[136,2716,1180],{},", we have similar or worse performance. Understanding ",[111,2719,2720],{},"how"," widgets work and which to use in each scenario is key to building a highly performant application.",[697,2723,2725],{"id":2724},"finding-the-problem-with-the-tools","Finding the problem with the tools",[125,2727,2728,2729,1101],{},"However, this example was tailored specifically to showcase this single widget. How can we identify the problem in our own applications using these tools? Let us start by selecting one of the janky frames, then start examining the event details (",[111,2730,2731],{},"Figure 11.26",[125,2733,2734],{},[666,2735],{"alt":2736,"src":2737},"Figure 11.26: Zooming into the timeline details of one of our janky frames","\u002Fimages\u002Fflutter-for-jobseekers\u002Ffigure-11-26.png",[671,2739,2740],{},[125,2741,2736],{},[125,2743,2744,2745,2748,2749,2752,2753,1101],{},"By zooming in, we can see that there are probably about 2,000 ",[120,2746,2747],{},"DisplayList"," events ",[111,2750,2751],{},"each frame",". Remember that you can also toggle on tracking widget builds to make things even more clear. Using this information, we can tell that our list is rebuilding every item in the list, every frame. With that knowledge, we should have enough information to start tracking down the problem. If we rerun the application in debug mode to gain access to the widget inspector, we can very quickly identify the problem (",[111,2754,2755],{},"Figure 11.27",[129,2757,2758,2760,2761,2763,2764,2767,2768,2770],{},[120,2759,369],{}," the runnable copy's tests find no rebuilds while scrolling the shrink-wrapped list either. ",[136,2762,2017],{}," wraps each item in a ",[136,2765,2766],{},"RepaintBoundary",", and the tests find that scrolling repaints none of the 2,000 items; where the frame time goes instead, the tests do not show. What they do confirm is the next figure: all 2,000 ",[136,2769,2020],{},"s are live.",[125,2772,2773],{},[666,2774],{"alt":2775,"src":2776},"Figure 11.27: Our Widget Tree has 2,000 ListTiles in it with 2,000 live children.","\u002Fimages\u002Fflutter-for-jobseekers\u002Ffigure-11-27.png",[671,2778,2779],{},[125,2780,2775],{},[125,2782,2783,2784,2787,2788,2790,2791,2793,2794,1101],{},"The render object for our list will tell us precisely how many children are currently ",[111,2785,2786],{},"live",", or actively being built. Note the estimated child count a couple of lines above, which states the estimated total child count. In contrast, if we look at our optimized ",[136,2789,2017],{}," example without the ",[136,2792,2545],{}," property being set, we can see there are still an estimated 2,000 children, but only 20 of them are currently live (",[111,2795,2796],{},"Figure 11.28",[125,2798,2799],{},[666,2800],{"alt":2801,"src":2802},"Figure 11.28: Our widget tree has only 20 ListTiles with 20 live children.","\u002Fimages\u002Fflutter-for-jobseekers\u002Ffigure-11-28.png",[671,2804,2805],{},[125,2806,2801],{},[660,2808,2809,2810,2812,2813,2815,2816,2818,2819,2821],{},"The runnable copy's tests count the ",[136,2811,2020],{},"s in the tree: 2,000 for the ",[136,2814,1180],{}," and for the shrink-wrapped ",[136,2817,2017],{},", fewer than 30 for ",[136,2820,2283],{}," (also after scrolling).",[125,2823,2824],{},"Here, we have looked at just one example of a built-in widget which can go awry if we are not careful. There are many other widgets which can have similar problems if we are not careful, but at least we have the tools to identify these issues when something goes wrong. But what are some best practices to keep in mind so that we do not put ourselves in this place to begin with?",[155,2826,197],{"id":2827},"optimizing-widgets",[125,2829,2830,2831,2834],{},"As we know, the ",[136,2832,2833],{},"build()"," method of a widget is run each time the widget is rebuilt, which could be upwards of 60-120 times each second. If our aim is to make sure that we avoid jank, we need these rebuilds to happen as efficiently as possible. Thankfully, there are several things we can do to ensure that rebuilds are doing as little work as possible.",[160,2836,2837,2846],{},[163,2838,2841,2842,2845],{"icon":2839,"title":2840},"i-lucide-function-square","Avoid functions in build()","You should avoid defining and running unnecessary functions within your build method. If you have a camel-case string that you want to split apart into individual words, then convert to lowercase, you ",[111,2843,2844],{},"could"," create a function in the build method which takes the string you want to convert in and returns the text in the format you want. Then, you can call that function whenever you need to display that text. This would cause the method you have created to be run repeatedly each time the widget is rebuilt, though. Since the output should always be the same, would it not make much more sense to pass that value into the widget before it is built, perhaps as an argument?",[163,2847,2850,2851,2854],{"icon":2848,"title":2849},"i-lucide-database","Cache","Let us say you want to display a user's profile picture on a navigation drawer's header whenever the drawer is opened. The image is stored online, so you will need to fetch that image from the internet to display it. Since the drawer header is rebuilt every time the drawer is opened, the image will be fetched from the internet every time the drawer is opened. Rather than constantly re-fetching the image, you could use a widget such as the ",[136,2852,2853],{},"CachedNetworkImage"," widget, which will store the image in the application's local cache upon fetching it for the first time. The next time the widget is rebuilt, the cache will be checked first and the image there will be used if it exists; otherwise, the image will be fetched from the internet.",[129,2856,2857,2859,2860,2863,2864],{},[136,2858,2853],{}," is not part of Flutter; it comes from the ",[136,2861,2862],{},"cached_network_image"," package on pub.dev. ",[111,2865,2866],{},"(added, not in the book)",[125,2868,2869],{},"Caching can be used in all sorts of ways, not just with images. It may be possible to cache some API calls, at least for a period, before invalidating the cache due to some sort of timeout. This means that a widget calling an API does not need to make dozens of calls each second, saving network bandwidth and speeding up the widget build.",[697,2871,2873],{"id":2872},"smaller-widgets","Smaller widgets",[660,2875,2876,2877,2880],{},"One of the biggest things you can do to increase performance is to simply have ",[120,2878,2879],{},"smaller widgets",". Instead of building a screen in a single widget tree, consider logically segmenting different parts of the screen into smaller widgets. Your screen has a header? Make a header widget. Then, optimize the smaller widgets.",[125,2882,2883],{},"Not only will this give you more re-usable code, but it will help prevent unnecessary widget rebuilds. If you have broken your header off into its own widget, it is far less likely to be rebuilt unnecessarily when part of the application's main content calls for a rebuild.",[125,2885,2886,2887,2890],{},"Your IDE likely has a line running down it by default, marking the 80-character line (",[111,2888,2889],{},"Figure 11.29","). If the code for your widget tree is regularly bumping up to this line or even running past it, that should be a clue to you that your widgets might be nested too deeply, and it is time to refactor your code.",[125,2892,2893],{},"Not only will your code be more readable and easier to debug when the widgets are smaller, but you will be forced to think more deliberately about how you compose your widgets. The performance improvements will come as Flutter will only rebuild widgets which require a rebuild, allowing it to keep widgets that do not. If your entire application is a single widget, that widget will always be rebuilt in its entirety.",[125,2895,2896],{},[666,2897],{"alt":2898,"src":2899},"Figure 11.29: Highlighting the 80-character line in Visual Studio Code","\u002Fimages\u002Fflutter-for-jobseekers\u002Ffigure-11-29.png",[671,2901,2902],{},[125,2903,2898],{},[697,2905,2907],{"id":2906},"pass-only-what-the-widget-needs","Pass only what the widget needs",[125,2909,2910],{},"Finally, be conscientious about the parameters you are passing into your widgets. It may be convenient to pass in a large object to pull out multiple values for the widget you are building, but that might mean making a copy of that object in memory and will require more CPU time to process each time the widget is built than if you had simply passed in the variables you needed in the first place.",[129,2912,2913,2915],{},[120,2914,369],{}," passing an object to a widget does not copy it. Dart's documentation states that \"Variables store references\" (Dart, n.d.); a constructor parameter receives a reference to the same object. Passing only the values a widget needs is still good advice, for the readability reasons below.",[125,2917,2918,2919,2922],{},"If you are using BLoC, it is tempting to pass the BLoC state from a ",[136,2920,2921],{},"BlocBuilder"," into several of the child widgets being built. However, that is unlikely to be an efficient way to build the widgets. Instead, pull out the variables you need from the state and pass them directly in as parameters. The resulting widgets will even be easier to read and debug, since you will know ahead of time if the parameters you are passing in are properly set, rather than doing checks inside that widget's build method.",[125,2924,2925,2926,123],{},"These are only a few suggestions to keep in mind when building widgets optimally, and it is by no means an exhaustive list. It will take practice and experience to learn what causes jank, balloons memory usage, and contributes to an application that is underperforming your expectations. There are more suggestions in Flutter's online documentation concerning optimizing performance, which you can view here: ",[145,2927,2928],{"href":2928,"rel":2929},"https:\u002F\u002Fdocs.flutter.dev\u002Fperf",[149],[155,2931,2933],{"id":2932},"conclusion","Conclusion",[125,2935,2936],{},"Learning to use Flutter to build applications is not something you can do only by reading a book. It requires experimentation, failure, analysis, and eventual understanding. Fortunately, Flutter ships with a robust set of tools, DevTools, which give you everything you need to build your understanding. Even the most seasoned Flutter developers will use these tools constantly, having integrated them into part of their everyday workflow.",[125,2938,2939],{},"Flutter was designed from the very beginning to be highly performant, and while premature optimization of your widgets is not recommended, sometimes it is necessary to dig deep into your application to understand why it is not buttery smooth. When that happens, you have got the tools available to analyze and dig into precisely what is happening, thanks to Flutter's profile mode.",[660,2941,2942,2943,123],{},"While these tools may seem daunting at first, you will soon find that they have become a part of your everyday toolkit when building applications. In the end, you will realize that you certainly would not want to write code without them! All it takes is ",[120,2944,2945],{},"practice and patience",[125,2947,2948,2949,2952],{},"Up to this point in the book, we have been learning a lot about different ",[111,2950,2951],{},"concepts"," when it comes to developing applications using Flutter. In the upcoming chapter, we are going to take all these concepts and put them to use. We will explore what it might be like to have a client with a set of ideas, business needs, and a design — then turn all of it into a fully-functioning application. This is what we have been building up to, and you have everything you need to be successful. So, let us go build an application!",[155,2954,2956],{"id":2955},"questions","Questions",[2958,2959,2960,2963,2966,2969,2972,2975,2978,2986,2989,2992,2995,2998,3001,3004,3007,3014,3017],"ol",{},[171,2961,2962],{},"What is the difference between debugging and troubleshooting?",[171,2964,2965],{},"What are the five steps involved in debugging?",[171,2967,2968],{},"What methods can you use to log information to the debug console?",[171,2970,2971],{},"What is a breakpoint, and how do you create one?",[171,2973,2974],{},"What is a stack trace? What is a stack frame?",[171,2976,2977],{},"What is an exception?",[171,2979,2980,2981,990,2983,2985],{},"What risks do you run by using a ",[136,2982,989],{},[136,2984,993],{}," block?",[171,2987,2988],{},"How do you access Flutter's DevTools?",[171,2990,2991],{},"What are the different tools available in Flutter's DevTools?",[171,2993,2994],{},"What are the two different categories of performance issues your application may encounter?",[171,2996,2997],{},"What is vsync and how does it relate to your application's performance?",[171,2999,3000],{},"What is jank?",[171,3002,3003],{},"What three compilation modes are available for Flutter applications? How do they differ?",[171,3005,3006],{},"What is the difference between storage and memory?",[171,3008,3009,3010,2527,3012,2431],{},"When is a ",[136,3011,2017],{},[136,3013,2017],{},[171,3015,3016],{},"When should you consider optimizing your application?",[171,3018,3019],{},"What are some steps you can take to optimize your application?",[155,3021,3023],{"id":3022},"key-terms","Key terms",[3025,3026,3027,3032,3035,3038,3042],"field-group",{},[3028,3029,3031],"field",{"name":3030},"Breakpoint","Intentionally stopping or pausing code from running at a specific point to assist in debugging.",[3028,3033,3034],{"name":228},"The process of going step by step through a problem to identify and resolve any errors.",[3028,3036,3037],{"name":1608},"A stuttering effect produced by one or more frames taking too long to complete.",[3028,3039,3041],{"name":3040},"Pseudo-code","A code-like representation, often non-functional, which is used to illustrate a solution or mock out a problem.",[3028,3043,3044],{"name":222},"The process of solving a problem.",[155,3046,3048],{"id":3047},"further-reading","Further reading",[160,3050,3051,3057,3065],{},[163,3052,3056],{"icon":3053,"title":3054,"target":3055,"to":902},"i-lucide-bug-play","Debugging in Visual Studio Code","_blank","Read more about Visual Studio Code's debugger.",[163,3058,3061,3062,3064],{"icon":3059,"title":3060,"target":3055,"to":1855},"i-lucide-layers","Canvas.saveLayer","Why ",[136,3063,1865],{}," is one of Flutter's most expensive operations.",[163,3066,3069],{"icon":3067,"title":3068,"target":3055,"to":2928},"i-lucide-gauge","Flutter performance","More suggestions in Flutter's online documentation concerning optimizing performance.",[155,3071,3073],{"id":3072},"references","References",[168,3075,3076,3088,3101,3114,3126,3138,3150,3161,3173,3185,3201],{},[171,3077,3078,3079,3081,3082,425,3086],{},"BPB Publications. (n.d.). ",[111,3080,17],{}," (companion code repository). Retrieved from GitHub: ",[145,3083,3084],{"href":3084,"rel":3085},"https:\u002F\u002Fgithub.com\u002Fbpbpublications\u002FFlutter-for-Jobseekers",[149],[111,3087,2866],{},[171,3089,3090,3091,3094,3095,425,3099],{},"Dart. (n.d.). ",[111,3092,3093],{},"Variables",". Retrieved from Dart: ",[145,3096,3097],{"href":3097,"rel":3098},"https:\u002F\u002Fdart.dev\u002Flanguage\u002Fvariables",[149],[111,3100,2866],{},[171,3102,3103,3104,3107,3108,425,3112],{},"Flutter. (n.d.-a). ",[111,3105,3106],{},"Use the Performance view",". Retrieved from Flutter: ",[145,3109,3110],{"href":3110,"rel":3111},"https:\u002F\u002Fdocs.flutter.dev\u002Ftools\u002Fdevtools\u002Fperformance",[149],[111,3113,2866],{},[171,3115,3116,3117,3107,3120,425,3124],{},"Flutter. (n.d.-b). ",[111,3118,3119],{},"Use the Memory view",[145,3121,3122],{"href":3122,"rel":3123},"https:\u002F\u002Fdocs.flutter.dev\u002Ftools\u002Fdevtools\u002Fmemory",[149],[111,3125,2866],{},[171,3127,3128,3129,3107,3132,425,3136],{},"Flutter. (n.d.-c). ",[111,3130,3131],{},"Use the Network view",[145,3133,3134],{"href":3134,"rel":3135},"https:\u002F\u002Fdocs.flutter.dev\u002Ftools\u002Fdevtools\u002Fnetwork",[149],[111,3137,2866],{},[171,3139,3140,3141,3144,3145,425,3148],{},"Flutter. (n.d.-d). ",[111,3142,3143],{},"saveLayer method",". Retrieved from Flutter API: ",[145,3146,1855],{"href":1855,"rel":3147},[149],[111,3149,2866],{},[171,3151,3152,3153,3155,3156,425,3159],{},"flutter\u002Fdevtools. (2024). ",[111,3154,2059],{}," (issue #5174). Retrieved from GitHub: ",[145,3157,2049],{"href":2049,"rel":3158},[149],[111,3160,2866],{},[171,3162,3163,3164,3167,3168,425,3171],{},"flutter\u002Fdevtools. (2025a). ",[111,3165,3166],{},"The \"Network\" tab should provide visibility into non-HttpClient HTTP traffic"," (issue #4829). Retrieved from GitHub: ",[145,3169,1497],{"href":1497,"rel":3170},[149],[111,3172,2866],{},[171,3174,3175,3176,3179,3180,425,3183],{},"flutter\u002Fdevtools. (2025b). ",[111,3177,3178],{},"Network page does not show requests when running on Hyper-V"," (issue #4997). Retrieved from GitHub: ",[145,3181,1502],{"href":1502,"rel":3182},[149],[111,3184,2866],{},[171,3186,3187,3188,428,3191,3194,3195,425,3199],{},"flutter\u002Fflutter. (n.d.). ",[111,3189,3190],{},"print.dart",[111,3192,3193],{},"basic.dart"," (Flutter 3.29.0 source). Retrieved from GitHub: ",[145,3196,3197],{"href":3197,"rel":3198},"https:\u002F\u002Fgithub.com\u002Fflutter\u002Fflutter\u002Fblob\u002F3.29.0\u002Fpackages\u002Fflutter\u002Flib\u002Fsrc\u002Ffoundation\u002Fprint.dart",[149],[111,3200,2866],{},[171,3202,3203,3204,3207,3208,425,3211],{},"Microsoft. (n.d.). ",[111,3205,3206],{},"Debug code with Visual Studio Code",". Retrieved from Visual Studio Code: ",[145,3209,902],{"href":902,"rel":3210},[149],[111,3212,2866],{},[3214,3215,3216],"style",{},"html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .sBMFI, html code.shiki .sBMFI{--shiki-light:#E2931D;--shiki-default:#FFCB6B;--shiki-dark:#FFCB6B}html pre.shiki code .sfazB, html code.shiki .sfazB{--shiki-light:#91B859;--shiki-default:#C3E88D;--shiki-dark:#C3E88D}",{"title":106,"searchDepth":306,"depth":306,"links":3218},[3219,3220,3221,3222,3225,3226,3232,3236,3242,3249,3253,3254,3255,3256,3257],{"id":157,"depth":306,"text":158},{"id":214,"depth":306,"text":173},{"id":284,"depth":306,"text":176},{"id":637,"depth":306,"text":179,"children":3223},[3224],{"id":699,"depth":312,"text":700},{"id":907,"depth":306,"text":182},{"id":1131,"depth":306,"text":1132,"children":3227},[3228,3229,3230,3231],{"id":1162,"depth":312,"text":1163},{"id":1293,"depth":312,"text":1294},{"id":1359,"depth":312,"text":1360},{"id":1451,"depth":312,"text":1452},{"id":1554,"depth":306,"text":188,"children":3233},[3234,3235],{"id":1582,"depth":312,"text":1583},{"id":1607,"depth":312,"text":1608},{"id":1672,"depth":306,"text":191,"children":3237},[3238,3239,3240,3241],{"id":1715,"depth":312,"text":1716},{"id":1809,"depth":312,"text":1810},{"id":1887,"depth":312,"text":1888},{"id":1981,"depth":312,"text":1982},{"id":2114,"depth":306,"text":194,"children":3243},[3244,3245,3246,3247,3248],{"id":2144,"depth":312,"text":2145},{"id":2282,"depth":312,"text":2283},{"id":2444,"depth":312,"text":2445},{"id":2516,"depth":312,"text":2517},{"id":2724,"depth":312,"text":2725},{"id":2827,"depth":306,"text":197,"children":3250},[3251,3252],{"id":2872,"depth":312,"text":2873},{"id":2906,"depth":312,"text":2907},{"id":2932,"depth":306,"text":2933},{"id":2955,"depth":306,"text":2956},{"id":3022,"depth":306,"text":3023},{"id":3047,"depth":306,"text":3048},{"id":3072,"depth":306,"text":3073},"Logging, breakpoints and exceptions, Flutter DevTools, jank and profile mode, ListView vs Column, and how to keep widget rebuilds cheap.","md",null,{},{"icon":76},{"title":73,"description":3258},"9wVrTfAnrz9u6rqzDACyJPxiYoOOqpoPwerZb5ls74Y",[3266,3268],{"title":68,"path":69,"stem":70,"description":3267,"icon":71,"children":-1},"Responsive layouts with LayoutBuilder, dart:io and its limits, app icons and splash screens, platform styles and navigation, and flutter_platform_widgets.",{"title":78,"path":79,"stem":80,"description":3269,"icon":81,"children":-1},"Turning a weather-app design and requirements into a plan, organizing project files, enums and Freezed code generation, and building the API layer.",1795696850893]