{"componentChunkName":"component---src-templates-post-js","path":"/blog/2018/11/16/how-to-fix-vscode-flutter-debug/","result":{"data":{"post":{"html":"<h2 id=\"intro\" style=\"position:relative;\"><a href=\"#intro\" aria-label=\"intro permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Intro</h2>\n<p><a href=\"https://flutter.io\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Flutter</a> is a framework created by <a href=\"https://google.com\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Google</a> which allows you to build beautiful native apps on iOS and Android from a single codebase.</p>\n<!--more-->\n<p>I recently finished my project at my latest client and had it mind to play with, so I set everything up based on their <a href=\"https://flutter.io/docs\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">documentation</a> which to my opinion is the most straight forward doc I’ve ever seen.</p>\n<p>You will need to install a few things:</p>\n<ul>\n<li>Flutter</li>\n<li>Android Studio</li>\n<li>An editor of choice (which mine is <a href=\"https://code.visualstudio.com/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Visual Studio Code</a>)</li>\n</ul>\n<p>Once the setup is done, you will have a hello world app you could make. Flutter uses dart which I find it interesting. It’s similar to <code class=\"language-text\">Java Script</code>, but it supports types like <code class=\"language-text\">Type Script</code> (however it is not a super set of JS like <code class=\"language-text\">Type Script</code>).</p>\n<p>You will also need to install one of the android images since you will need it for running your app if you don’t want to test it on an actual device.</p>\n<p>When you’re ready just hit debug in VS code and the app runs on the simulator. It’s really fascinating since it uses Material Design theme and it almost looks the same in iOS and Android.</p>\n<h2 id=\"problem\" style=\"position:relative;\"><a href=\"#problem\" aria-label=\"problem permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Problem</h2>\n<p>Now all these was to let you know that currently if you run the app once, exit from it and change something or run it again without change, you will get an error:</p>\n<div class=\"custom-block danger\"><div class=\"custom-block-body\"> Program linking failed. “terminating with uncaught exception of type std::bad_alloc: std::bad_alloc” failed</div></div>\n<p>At first I thought I messed something up. So I started stripping my code to see which change has broken the app.</p>\n<h2 id=\"resolution\" style=\"position:relative;\"><a href=\"#resolution\" aria-label=\"resolution permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Resolution</h2>\n<p>Nothing helped, so I started Googling to see if someone else has faced the same issue and <a href=\"https://github.com/flutter/flutter/issues/22568\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">there it was</a>.</p>\n<p>Based on this thread all I need to do was to add a lunch settings to VS Code and specify the <code class=\"language-text\">--enable-software-rendering</code> flag:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"11737953951011780000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`{\r\n  &quot;version&quot;: &quot;0.2.0&quot;,\r\n  &quot;configurations&quot;: [\r\n    {\r\n      &quot;name&quot;: &quot;Flutter&quot;,\r\n      &quot;request&quot;: &quot;launch&quot;,\r\n      &quot;type&quot;: &quot;dart&quot;,\r\n      &quot;args&quot;: [&quot;--enable-software-rendering&quot;]\r\n    }\r\n  ]\r\n}`, `11737953951011780000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"json\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-json line-numbers\"><code class=\"language-json\"><span class=\"token punctuation\">{</span>\r\n  <span class=\"token property\">\"version\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"0.2.0\"</span><span class=\"token punctuation\">,</span>\r\n  <span class=\"token property\">\"configurations\"</span><span class=\"token operator\">:</span> <span class=\"token punctuation\">[</span>\r\n    <span class=\"token punctuation\">{</span>\r\n      <span class=\"token property\">\"name\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"Flutter\"</span><span class=\"token punctuation\">,</span>\r\n      <span class=\"token property\">\"request\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"launch\"</span><span class=\"token punctuation\">,</span>\r\n      <span class=\"token property\">\"type\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"dart\"</span><span class=\"token punctuation\">,</span>\r\n      <span class=\"token property\">\"args\"</span><span class=\"token operator\">:</span> <span class=\"token punctuation\">[</span><span class=\"token string\">\"--enable-software-rendering\"</span><span class=\"token punctuation\">]</span>\r\n    <span class=\"token punctuation\">}</span>\r\n  <span class=\"token punctuation\">]</span>\r\n<span class=\"token punctuation\">}</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></pre></div>\n<p>And that’s it. This will resolve the issue. If you don’t want to use this approach you can also uninstall the app from the simulator and run it again, however, this works sometimes and not always.</p>\n<p>They might fix this issue later but for now that’s the way.</p>\n<p>Hope this helps you explore more into Flutter and create some awesome apps.</p>","timeToRead":1,"frontmatter":{"unformattedDate":"2018-11-16T00:00:00.000Z","date":"November 16, 2018","title":"How to fix debugging Flutter in VS Code","subtitle":null,"id":null,"author":"Yaser Adel Mehraban","gravatar":null,"canonical_url":null,"tags":["vscode","flutter"],"thumbnail":{"childImageSharp":{"gatsbyImageData":{"layout":"constrained","placeholder":{"fallback":"data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAALABQDASIAAhEBAxEB/8QAGAAAAgMAAAAAAAAAAAAAAAAAAAECAwX/xAAVAQEBAAAAAAAAAAAAAAAAAAAAAf/aAAwDAQACEAMQAAABzJVNEAv/xAAZEAEAAgMAAAAAAAAAAAAAAAABEDEAAhH/2gAIAQEAAQUC1vgxWCkf/8QAFBEBAAAAAAAAAAAAAAAAAAAAEP/aAAgBAwEBPwE//8QAFBEBAAAAAAAAAAAAAAAAAAAAEP/aAAgBAgEBPwE//8QAFhAAAwAAAAAAAAAAAAAAAAAAACAh/9oACAEBAAY/AiL/AP/EABoQAQACAwEAAAAAAAAAAAAAAAEAERAxUaH/2gAIAQEAAT8hI0S+Shp7HfYKrGmaRx//2gAMAwEAAgADAAAAEP8AD//EABcRAAMBAAAAAAAAAAAAAAAAAAEQEUH/2gAIAQMBAT8QNxf/xAAXEQADAQAAAAAAAAAAAAAAAAABEBFB/9oACAECAQE/EBNX/8QAHRABAAICAgMAAAAAAAAAAAAAAQARITFBURCBkf/aAAgBAQABPxB/lDDO/UXghu7L0fIAQIOzmXhBySwHB2d+P//Z"},"backgroundColor":"transparent","images":{"fallback":{"src":"/static/23ef23a21dd971b8a65898721195a4ed/d8e56/vscodeflutter.jpg","srcSet":"/static/23ef23a21dd971b8a65898721195a4ed/9e0f0/vscodeflutter.jpg 750w,\n/static/23ef23a21dd971b8a65898721195a4ed/d8e56/vscodeflutter.jpg 800w","sizes":"(min-width: 800px) 800px, 100vw"},"sources":[{"srcSet":"/static/23ef23a21dd971b8a65898721195a4ed/cbeef/vscodeflutter.webp 750w,\n/static/23ef23a21dd971b8a65898721195a4ed/93d42/vscodeflutter.webp 800w","type":"image/webp","sizes":"(min-width: 800px) 800px, 100vw"}]},"width":800,"height":450}}},"cover":{"childImageSharp":{"gatsbyImageData":{"layout":"constrained","placeholder":{"fallback":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAKCAIAAAA7N+mxAAAACXBIWXMAAAsTAAALEwEAmpwYAAAB+UlEQVR42h2M2W6bQBiFeeuqr9DrSq36Br3rRRJVTZM6cWKwGWITUwxmX8aYZRY2w0xw0kmlT0efdP7zS88R3h07O+/35SmoTgkZUjwkZIzxEArQcKhZ1jBIR0jZseGwZjEZoKiKRtJg7ZKXLaSbGBmH2oJkf6A2xO6xtjNqZbWZvHtU9WFeB0cq3CtaNLwl+CQ9plRH7M/Wu5L12dqZre1bzbxZPV/NwcVsOQPG7cr4rehLM5rr9nxj3T+Zy79+MbyFVS/JKQXFsKmYTaaATlE9Je350L9G9TlphE9J95r2r3F7Dttz0p3hu097zHe5GEOq5Sc1pKpP1nFjZr1TDQFmEX2BzZQ2k09efMx9wjzMXMREtUfMQtzIWkn2Ss0nqoNBQEHYaGGzjloj7Zxy9BAXOBW3EbcJtzEXmx3ie8r2hG+zTpKtfB2QjYdAUK88srCLRytf+rUad2rUgqgDcQdgD4pRQ1yruHoYF+5olGLcSopHVo/y5tePJ5/cbZNLeXehmHM715IOCNL/+U4L4Ekn4+UD+/hh+n7P9aqRQFhf3shfPn9V3FJ2imWA1Jgu3BLErZb2WtqJLxrstUMPkn5Tnq637NM3/lMf1YRID0a6sMu7XaG4lSzwkBySpVMoVqbYR2UnMpd9JAdYCbA4WAYVgGgV4rl5/AdwTQ7QBdvQcAAAAABJRU5ErkJggg=="},"backgroundColor":"transparent","images":{"fallback":{"src":"/static/7f5dd1d66c658a06bf0548d308e7ff22/a2195/socialpreview.png","srcSet":"/static/7f5dd1d66c658a06bf0548d308e7ff22/cadb4/socialpreview.png 750w,\n/static/7f5dd1d66c658a06bf0548d308e7ff22/a2195/socialpreview.png 800w","sizes":"(min-width: 800px) 800px, 100vw"},"sources":[{"srcSet":"/static/7f5dd1d66c658a06bf0548d308e7ff22/11ba1/socialpreview.webp 750w,\n/static/7f5dd1d66c658a06bf0548d308e7ff22/5f042/socialpreview.webp 800w","type":"image/webp","sizes":"(min-width: 800px) 800px, 100vw"}]},"width":800,"height":400}}},"img":{"publicURL":"/static/23ef23a21dd971b8a65898721195a4ed/vscodeflutter.jpg"},"socialPreview":{"publicURL":"/static/7f5dd1d66c658a06bf0548d308e7ff22/socialpreview.png"}}}},"pageContext":{"title":"How to fix debugging Flutter in VS Code","postPath":"/blog/2018/11/16/how-to-fix-vscode-flutter-debug","nextPost":"/blog/2018/11/23/web-perf-5","previousPost":"/blog/2018/11/12/web-perf-4"}},"staticQueryHashes":[],"slicesMap":{}}