Flutter Hot reloading not working in android studio(mac)

Flutter Documentation says "Hot reload loads code changes into the VM and re-builds the widget tree, preserving the app state; it doesn’t rerun main() or initState()"

So, it looks like if the app logic resides outside the main method, then Hot Reloading works. Try to refactor your app like below and then do Restart (green button). Any subsequent changes you make, will be HOT RELOADED when saved.

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: new Scaffold(
        appBar: new AppBar(
          title: new Text("Demo Project"),
        ),
        body: Center(child: new Text("Hello World!!!")),
      ),
    );
  }
}

UPDATE: Hot Reload will not work if you are adding new assets (like images, or medial files). In those cases you will have to restart the App.


Try This

The solution on GitHub Reloaded 0 of NNN libraries in Xms

Android Studio uses IDEA to import files automatically, Like this

import 'file///F:/flutter_project/lib/home_page.dart';

Change it to

import 'package:flutter_project/home_page.dart';

Wrap your code with a StatefulWidget like shown in the code below. This might be confusing when watching old tutorials because it used to work without it on an earlier Flutter Version.

import 'package:flutter/material.dart';

void main() {
  runApp(new MaterialApp(home: MyApp()));
}

class MyApp extends StatefulWidget {
  MyApp({Key key}) : super(key: key);

  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      appBar: new AppBar(
        title: new Text("Demo Project"),
      ),
      body: Center(child: new Text("Hello World!!!")),
    );
  }
}