angelo
angelo

Reputation: 2961

Flutter app starts in an unusual way after reopening

I would be sounding silly but it is a real problem with me. I started flutter about a month ago and whenever I upload my app on my android device , I have never run it on an emulator ,it seems to remember its state not that state management one. I will explain what I mean.

Suppose I have my flutter with a text and appbar. So I run my app on my device It runs perfectly. Then I added a floating action button and I hot reloaded my app all is fine the floating action button is in my app. So I closed my pc and then I wanted to look at my app again So I opened it from my phone and the floating action button is gone only text and appbar.

I even uninstalled my app and reinstalled it using flutter run but there is still that problem.

Here is the output of flutter doctor

[√] Flutter (Channel beta, 1.19.0-4.1.pre, on Microsoft Windows [Version 6.3.9600], locale en-IN) • Flutter version 1.19.0-4.1.pre at C:\flutt\flutter • Framework revision f994b76974 (6 days ago), 2020-06-09 15:53:13 -0700 • Engine revision 9a28c3bcf4 • Dart version 2.9.0 (build 2.9.0-14.1.beta)

[√] Android toolchain - develop for Android devices (Android SDK version 29.0.2) • Android SDK at C:\Users\Anupam Karn\AppData\Local\Android\sdk • Platform android-29, build-tools 29.0.2 • Java binary at: C:\Program Files\Android\Android Studio2\jre\bin\java • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b04) • All Android licenses accepted.

[√] Chrome - develop for the web • Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe

[√] Android Studio (version 3.6) • Android Studio at C:\Program Files\Android\Android Studio2 • Flutter plugin version 45.1.1 • Dart plugin version 192.8052 • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b04)

[√] VS Code • VS Code at C:\Users\Anupam Karn\AppData\Local\Programs\Microsoft VS Code • Flutter extension version 3.11.0

[√] Connected device (3 available) • SM G600FY • cc07c483 • android-arm • Android 6.0.1 (API 23) • Web Server • web-server • web-javascript • Flutter Tools • Chrome • chrome • web-javascript • Google Chrome 83.0.4103.97

• No issues found!

Please help me sort out this issue it happens with every app I make

Upvotes: 1

Views: 545

Answers (1)

ZeRj
ZeRj

Reputation: 1708

When you hot reload, no new apk is generated. The source code from the changed files is compiled into kernel files and sent to the mobile device’s Dart VM. The installed apk is untouched.

Read more here: https://flutter.dev/docs/development/tools/hot-reload

So if you change something, hot reload, close the app and reopen the app it will be the old app again. If you only do flutter run (without build), you install the same old apk again. You need to run flutter build first to have an updated apk.

Upvotes: 0

Related Questions