'Flutter App Keeps going back to intial route when I save changes

I am building a flutter app for Android and iOS. The challenge I am facing is that whenever I make any changes to the code and save, the app falls back to the initial route. It doesn't matter whether I use stateless or stateful widgets. My flutter version:

Flutter 2.9.0-1.0.pre.465 • channel master • https://github.com/flutter/flutter.git
Framework • revision 2104a6d97f (3 hours ago) • 2022-01-24 05:05:21 -0500
Engine • revision 8204850dbe
Tools • Dart 2.17.0 (build 2.17.0-49.0.dev) • DevTools 2.9.2

My Doctor:

Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel master, 2.9.0-1.0.pre.465, on Microsoft Windows [Version 10.0.22000.466], locale en-US)
[√] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
[√] Chrome - develop for the web
[√] Android Studio (version 4.1)
[√] IntelliJ IDEA Community Edition (version 2020.3)
[√] VS Code (version 1.63.2)
[√] Connected device (3 available)
[√] HTTP Host Availability

• No issues found!

My Main:

void main() async {
  if (Platform.isAndroid) {
    runApp(const AndroidApp());
  } else if (Platform.isIOS) {
    runApp(const IosApp());
  }
}

Everything else works well but I have several pages in my application and I have to navigate to each page I am working on each time I make a change. This also affects my input fields.

Please help.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source