I am trying to understand why the Flutter / Dart HotReload does not work if I reference the appBar: widget as opposed to defining the code inline. Why?
Here is the sample code:
class AppBarWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: appBar,
);
}
}
AppBar appBar = AppBar(
title: new Text("App Title"),
);
Notice appBar: appBar is a reference to the AppBar(...) widget definition.
In this case, if I change the title: property text, it will not hot reload even though both IDE (VSCode or AStudio) says it reloads. I need to rebuild to make it work.
But if I move the AppBar(...) widget definition into appBar: AppBar(...) and change the title, it Hot Reloads.