I am trying to work on a project that I just started and while editing the app I realized that neither hot reload nor hot restart are working even though I have changed the design multiple times. The only time that I would see a change in the screen is when I uninstall the app and run again,
I am testing the app on an emulator and I am using Android Studio.
I searched for a solution before typing this question and this is what I have tried:
It used to work really well and now it is not, here's an example:
import 'package:gradient_app_bar/gradient_app_bar.dart';
import '../constants.dart';
class PlantScreen extends StatefulWidget {
@override
_PlantScreenState createState() => _PlantScreenState();
}
class _PlantScreenState extends State<PlantScreen> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: GradientAppBar(
centerTitle: true,
title: Text('plant A'),
gradient: LinearGradient(
colors: Constants.primaryGradient,
begin: Alignment.topLeft,
end: Alignment.bottomRight),
),
body: Container(
constraints: BoxConstraints.expand(),
decoration: BoxDecoration(
gradient: LinearGradient(
colors: Constants.primaryVariantGradient,
begin: Alignment.topLeft,
end: Alignment.bottomRight),
),
child: Column(
children: <Widget>[
Card(
child: Column(
children: <Widget>[
],
),
),
],
),
),
);
}
}
Hot Reload allows us to see the reflected change after bug fixes, building User interfaces and even adding certain features to the app without running your application afresh over and over again. Hot restart destroys the preserved State value and set them to their default.
One of Flutter's great features is hot reload. You press r on your keyboard, and moments later the impact of your changes can be seen on the device. In your terminal (or maybe at the bottom of your IDE) you can read something like Reloaded 1 of 553 libraries in 297ms .
I figured the issue was with my import statement
it was :
import 'file:///E:/SelfProjects2/water_my_plants/lib/screens/plantScreen.dart';
I have changed it to
import 'package:water_my_plants/screens/plantScreen.dart';
in my main dart file that had the route to the PlantScreen()
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