<p dir="auto">Try this:</p>
<ul dir="auto">
<li>create a new app</li>
<li>start an emulator</li>
<li>flutter run your new app</li>
<li>yay, it works!</li>
<li>then, replace your lib/main.dart with the following contents:</li>
</ul>
<div class="highlight highlight-source-dart notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import 'package:flutter/material.dart';

void main() {
  runApp(new MyWidget());
}

class MyWidget extends StatelessWidget {
  
  @override
  Widget build(BuildContext context) {
    return new GestureDetector(
      onTap: () =&gt; print('tapped!')
    );
  }
}"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-s">'package:flutter/material.dart'</span>;

<span class="pl-k">void</span> <span class="pl-en">main</span>() {
  <span class="pl-en">runApp</span>(<span class="pl-k">new</span> <span class="pl-c1">MyWidget</span>());
}

<span class="pl-k">class</span> <span class="pl-c1">MyWidget</span> <span class="pl-k">extends</span> <span class="pl-c1">StatelessWidget</span> {
  
  <span class="pl-k">@override</span>
  <span class="pl-c1">Widget</span> <span class="pl-en">build</span>(<span class="pl-c1">BuildContext</span> context) {
    <span class="pl-k">return</span> <span class="pl-k">new</span> <span class="pl-c1">GestureDetector</span>(
      onTap<span class="pl-k">:</span> () <span class="pl-k">=&gt;</span> <span class="pl-en">print</span>(<span class="pl-s">'tapped!'</span>)
    );
  }
}</pre></div>
<p dir="auto">And then:</p>
<ul dir="auto">
<li>type <code class="notranslate">r</code> in your flutter run console</li>
</ul>
<p dir="auto">Expected: hot reloads and everything is awesome</p>
<p dir="auto">Actual:</p>
<p dir="auto">This error:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Initializing hot reload...
I/flutter ( 3394): ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
I/flutter ( 3394): The following _CompileTimeError was thrown building MyApp(dirty):
I/flutter ( 3394): 'file:///C:/Users/sethladd/Documents/Code/circles/lib/main.dart': malformed type: line 25: cannot
I/flutter ( 3394): resolve class 'MyHomePage' from 'MyApp'
I/flutter ( 3394):         home : new MyHomePage(title : &quot;Flutter Demo Home Page&quot;),
I/flutter ( 3394):                    ^
I/flutter ( 3394):"><pre class="notranslate"><code class="notranslate">Initializing hot reload...
I/flutter ( 3394): ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
I/flutter ( 3394): The following _CompileTimeError was thrown building MyApp(dirty):
I/flutter ( 3394): 'file:///C:/Users/sethladd/Documents/Code/circles/lib/main.dart': malformed type: line 25: cannot
I/flutter ( 3394): resolve class 'MyHomePage' from 'MyApp'
I/flutter ( 3394):         home : new MyHomePage(title : "Flutter Demo Home Page"),
I/flutter ( 3394):                    ^
I/flutter ( 3394):
</code></pre></div>
<p dir="auto">This is a pretty poor user experience:</p>
<ul dir="auto">
<li>There is no more MyHomePage class in my source code, why is Flutter telling me there's an error here?</li>
<li>There is no suggestion or hint that I need to Hot Restart</li>
</ul>
<p dir="auto">Luckily, I then remembered that:</p>
<ul dir="auto">
<li>I can Hot Restart</li>
<li>There is some issue about changing types of widgets and not working well with Hot Reload</li>
</ul>
<p dir="auto">(Neither of which a new user would understand :/)</p>
<p dir="auto">Suggestions:</p>
<ul dir="auto">
<li>Tolerate changing widget types (from stateless to stateful) during Hot Reloads</li>
<li>Detect when a Hot Reload isn't possible, error out earlier than showing me code that no longer exists</li>
<li>Suggest to the user something like "Bummer, that didn't seem to work. Please try Hot Restart with capital R."</li>
</ul>
<p dir="auto">Thanks!</p>
<p dir="auto">Add infrastructure to check for program elements changed in the last reload and not executed. Use this facility in flutter tools to figure out situations where the user makes changes that will not be reflected after a hot reload and warn users about the need to do a hot restart for the changes to take effect.</p>