I am trying to change the text and it's color in hot reload
void main() {
runApp(new getMyView();
}
Center getMyView() {
return Center(
child: Text("Nepali",
style: TextStyle(color: Colors.amber),
textDirection: TextDirection.ltr),
);
}
But when I change "Nepali
" to "Nepal
" or I change Colors.amber
to Colors.white
and hot reload, it does not get reflected in the emulator.
I have to "Full Restart" the app to see the changes
Problem : As @JonahWilliams described main()
is executed only once in the whole app session.
Solution : Do the UI change inside Widget
void main() {
runApp(MyView());
}
class MyView extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new Center(
child: Text("Nepali",
style: TextStyle(color: Colors.white),
textDirection: TextDirection.ltr),
);
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With