5

I just created a flutter project on Windows with

flutter create appname --platforms=windows,macos

Now I can start this Windows app with

flutter run -d windows

and everything works perfectly. But the problem is that I can not start the Windows app in release mode. I tried:

flutter run --release -d windows

but the app window is not showing up. I just see the process running in the task manager. There is no need to show you the code of the project as it is the template project you get with flutter create. No single line was modified.

The release mode works on every other platforms including web and macos. I also tried to start the .exe file manually but that doesn't work either. I also tried changing to the master version of flutter but it also does not work with the latest master version.

flutter doctor -v does not show any errors:

[✓] Flutter (Channel master, 3.9.0-17.0.pre.7, on Microsoft Windows [Version 10.0.22621.1413], locale de-DE)
    • Flutter version 3.9.0-17.0.pre.7 on channel master at C:\Program Files\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 785ea2a4c9 (2 hours ago), 2023-03-24 13:01:07 -0400
    • Engine revision 7b91f9d08f
    • Dart version 3.0.0 (build 3.0.0-365.0.dev)
    • DevTools version 2.22.2

[✓] Windows Version (Installed version of Windows is version 10 or higher)

[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    • Android SDK at C:\Users\User\AppData\Local\Android\sdk
    • Platform android-31, build-tools 31.0.0
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6842174)
    • All Android licenses accepted.

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

[✓] Visual Studio - develop for Windows (Visual Studio Community 2022 17.5.3)
    • Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community
    • Visual Studio Community 2022 version 17.5.33516.290
    • Windows 10 SDK version 10.0.22621.0

[✓] Android Studio (version 4.2)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6842174)

[✓] IntelliJ IDEA Ultimate Edition (version 2021.1)
    • IntelliJ at C:\Program Files\JetBrains\IntelliJ IDEA 2021.1.2
    • Flutter plugin version 58.0.3
    • Dart plugin version 211.7665

[✓] Connected device (3 available)
    • Windows (desktop) • windows • windows-x64    • Microsoft Windows [Version 10.0.22621.1413]
    • Chrome (web)      • chrome  • web-javascript • Google Chrome 111.0.5563.111
    • Edge (web)        • edge    • web-javascript • Microsoft Edge 111.0.1661.51

[✓] Network resources
    • All expected network resources are available.

• No issues found!

4 Answers 4

9

I had the same issue & I was using a package sqflite_common_ffi and because of that, it wasn't showing up, though it was visible in the task manager only, to resolve this issue I just copied sqlite3.dll to build\windows\x64\runner\Release\ dir, & it fixed my issue!

For anyone wondering what exactly to download

  • Open that link sqlite3.dll
  • Then under section Precompiled Binaries for Windows ( I'm using windows)
  • Select either 32 or 64 link depending on your platform, mine was 64
  • Then download and extract files
  • open extracted folder and copy all items inside
  • Go and paste them inside YourProject\build\windows\x64\runner\Release directory

Then it is done!

Sign up to request clarification or add additional context in comments.

2 Comments

This was my issue, thanks. I wouldn't have thought about an extension causing it.
That's what happened to me as well. Thanks!
2

It works if you edit the windows/runner/flutter_window.cpp like mentioned in @Zensonaton's answer. But I fixed it by adding a restorationScopeId in MaterialApp like this:

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      restorationScopeId: "Test", // <-- Add this line
      home: Scaffold(
        body: Container()
      )
    );
  }
}

Comments

1

Looks like this is a bug with Flutter?

Edit the windows/runner/flutter_window.cpp, replace this line:

flutter_controller_->engine()->SetNextFrameCallback([&]() {
    this->Show();
});

with this:

this->Show();

Source.

Comments

-1

I solved a similar problem by running the debugger. There was an error, I fixed it. And secondly, I commented out this line and everything worked. Now not only the process starts, but the Win window itself is displayed. WHY -1 REPUTATION from a BOT??? :(

debugDefaultTargetPlatformOverride = TargetPlatform.fuchsia;  // comment it

1 Comment

As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.