If you’ve stumbled upon this blog post, chances are you’ve encountered a frustrating error message on your PC related to flutter_windows.dll. This dynamic link library file is a crucial component of the Flutter framework, which is used to develop high-performance mobile, web, and desktop applications. Unfortunately, like many DLL files, flutter_windows.dll can sometimes become corrupted or go missing, resulting in error messages that prevent you from using your favorite apps.
Scan Your PC for Issues Now
Before we dive into how to fix the flutter_windows.dll error, it’s important to note that downloading DLL files from third-party websites or using third-party tools to fix DLL issues is not recommended. These files can often be outdated, infected with malware, or simply incompatible with your system. Instead, we recommend using a trusted PC cleaner and registry cleaner like SpyZooka to fix any DLL issues you may be experiencing.
Now, back to the flutter_windows.dll error. This error is typically caused by a program that has installed an incompatible or outdated version of the DLL file on your system. If you’re unsure which program is causing the error, you can use a tool like Dependency Walker to identify the program that is calling the DLL file. Once you’ve identified the program, you can try updating or reinstalling it to see if that resolves the error.
What is flutter_windows.dll
If you’re a developer working with Flutter on Windows, you’ve probably heard of flutter_windows.dll
. But what is it exactly?
flutter_windows.dll
is a dynamic link library file that is part of the Flutter framework. It contains code that is used to interact with the Windows operating system, allowing Flutter apps to run on Windows.
Common Error Messages
If you’ve worked with Flutter on Windows, you may have encountered error messages related to flutter_windows.dll
. Some common error messages include:
- “The code execution cannot proceed because flutter_windows.dll was not found.”
- “Cannot find flutter_windows.dll.”
- “Failed to load flutter_windows.dll.”
What causes a flutter_windows.dll error message?
There are several reasons why you might see an error message related to flutter_windows.dll
. One common cause is that the file is missing or has been deleted. Another possibility is that the file is corrupted or damaged. In some cases, a virus or malware infection can also cause issues with flutter_windows.dll
.
Is flutter_windows.dll safe or harmful?
flutter_windows.dll
is a legitimate file that is part of the Flutter framework. It is not a virus or malware, and is generally safe to use. However, as with any file, it is possible for it to become corrupted or infected with malware. If you encounter issues with flutter_windows.dll
, it is recommended that you take steps to ensure your system is secure, such as running a virus scan.
How to Solve flutter_windows.dll Error Messages
If you are experiencing error messages related to the flutter_windows.dll
file, there are several steps you can take to resolve the issue. Follow the steps below to troubleshoot and fix the DLL error messages.
1. Download SpyZooka
SpyZooka is a free tool that can help you fix DLL errors and other issues on your PC. It includes a registry cleaner that will clean up outdated registry entries causing issues on your computer. Additionally, SpyZooka’s Malware AI will display both known and unknown spyware and doesn’t rely on a traditional malware database which never includes all malware due to the vast amounts of new malware being released daily. Downloading SpyZooka is free and there is no cost to fix all the issues found by SpyZooka.
2. Restart Your PC
Sometimes, simply restarting your PC can help solve a lot of issues, including error messages related to DLL files. Restart your computer and check if the error message still appears.
3. Run a Full Antivirus Scan
Malware or viruses can display fake DLL error messages on your computer to trick you into clicking them or buying something to fix them. Running a full antivirus scan can remove these threats and fix the DLL error messages.
4. Run Windows System File Checker and DISM
System File Checker and DISM are built-in tools from Windows that can help solve DLL errors in the Windows operating system. To run these tools, open a command prompt as an administrator and type sfc /scannow
and DISM /Online /Cleanup-Image /RestoreHealth
. These tools will scan your system files and repair any corrupted files.
5. Update Your Drivers
Outdated drivers can sometimes be related to a DLL error. Check that all your drivers are up to date with SpyZooka or by manually checking for updates through the Device Manager.
6. Reinstall the Program
If all else fails, you may need to uninstall and reinstall the program to reinstall the correct DLL and solve the DLL error messages. Make sure to download the latest version of the program from the official website.
By following these steps, you should be able to troubleshoot and fix DLL error messages related to the flutter_windows.dll
file.
Tim Jones is a dedicated full time writer at Cyberlab, equipped with a resume filled to the brim of computer technology certifications, including CompTIA A+, Security+, and Network+. His profound interest in computers ignited over a decade ago when he delved into the world of video games, exploring ways to optimize their performance. Driven by a relentless pursuit of knowledge, Tim embarked on a formal education in Computer Technology, ultimately leading him to Cyberlab, where he continues to thrive and contribute to the ever evolving tech landscape.
This page discusses considerations unique to building Windows apps with Flutter, including shell integration and distribution of Windows apps through the Microsoft Store on Windows.
Integrating with Windows
#
The Windows programming interface combines traditional Win32 APIs, COM interfaces and more modern Windows Runtime libraries. As all these provide a C-based ABI, you can call into the services provided by the operating system using Dart’s Foreign Function Interface library (dart:ffi
). FFI is designed to enable Dart programs to efficiently call into C libraries. It provides Flutter apps with the ability to allocate native memory with malloc
or calloc
, support for pointers, structs and callbacks, and ABI types like long
and size_t
.
For more information about calling C libraries from Flutter, see C interop using dart:ffi
.
In practice, while it is relatively straightforward to call basic Win32 APIs from Dart in this way, it is easier to use a wrapper library that abstracts the intricacies of the COM programming model. The win32 package provides a library for accessing thousands of common Windows APIs, using metadata provided by Microsoft for consistency and correctness. The package also includes examples of a variety of common use cases, such as WMI, disk management, shell integration, and system dialogs.
A number of other packages build on this foundation, providing idiomatic Dart access for the Windows registry, gamepad support, biometric storage, taskbar integration, and serial port access, to name a few.
More generally, many other packages support Windows, including common packages such as url_launcher
, shared_preferences
, file_selector
, and path_provider
.
Supporting Windows UI guidelines
#
While you can use any visual style or theme you choose, including Material, some app authors might wish to build an app that matches the conventions of Microsoft’s Fluent design system. The fluent_ui package, a Flutter Favorite, provides support for visuals and common controls that are commonly found in modern Windows apps, including navigation views, content dialogs, flyouts, date pickers, and tree view widgets.
In addition, Microsoft offers fluentui_system_icons, a package that provides easy access to thousands of Fluent icons for use in your Flutter app.
Lastly, the bitsdojo_window package provides support for «owner draw» title bars, allowing you to replace the standard Windows title bar with a custom one that matches the rest of your app.
Customizing the Windows host application
#
When you create a Windows app, Flutter generates a small C++ application that hosts Flutter. This «runner app» is responsible for creating and sizing a traditional Win32 window, initializing the Flutter engine and any native plugins, and running the Windows message loop (passing relevant messages on to Flutter for further processing).
You can, of course, make changes to this code to suit your needs, including modifying the app name and icon, and setting the window’s initial size and location. The relevant code is in main.cpp, where you will find code similar to the following:
cpp
Win32Window::Point origin(10, 10);
Win32Window::Size size(1280, 720);
if (!window.CreateAndShow(L"myapp", origin, size))
{
return EXIT_FAILURE;
}
Replace myapp
with the title you would like displayed in the Windows caption bar, as well as optionally adjusting the dimensions for size and the window coordinates.
To change the Windows application icon, replace the app_icon.ico
file in the windows\runner\resources
directory with an icon of your preference.
The generated Windows executable filename can be changed by editing the BINARY_NAME
variable in windows/CMakeLists.txt
:
cmake
cmake_minimum_required(VERSION 3.14)
project(windows_desktop_app LANGUAGES CXX)
# The name of the executable created for the application.
# Change this to change the on-disk name of your application.
set(BINARY_NAME "YourNewApp")
cmake_policy(SET CMP0063 NEW)
When you run flutter build windows
, the executable file generated in the build\windows\runner\Release
directory will match the newly given name.
Finally, further properties for the app executable itself can be found in the Runner.rc
file in the windows\runner
directory. Here you can change the copyright information and application version that is embedded in the Windows app, which is displayed in the Windows Explorer properties dialog box. To change the version number, edit the VERSION_AS_NUMBER
and VERSION_AS_STRING
properties; other information can be edited in the StringFileInfo
block.
Compiling with Visual Studio
#
For most apps, it’s sufficient to allow Flutter to handle the compilation process using the flutter run
and flutter build
commands. If you are making significant changes to the runner app or integrating Flutter into an existing app, you might want to load or compile the Flutter app in Visual Studio itself.
Follow these steps:
-
Run
flutter build windows
to create thebuild\
directory. -
Open the Visual Studio solution file for the Windows runner, which can now be found in the
build\windows
directory, named according to the parent Flutter app. -
In Solution Explorer, you will see a number of projects. Right-click the one that has the same name as the Flutter app, and choose Set as Startup Project.
-
To generate the necessary dependencies, run Build > Build Solution
You can also press/ Ctrl + Shift + B.
To run the Windows app from Visual Studio, go to Debug > Start Debugging.
You can also press F5.
-
Use the toolbar to switch between Debug and Release configurations as appropriate.
Distributing Windows apps
#
There are various approaches you can use for distributing your Windows application. Here are some options:
- Use tooling to construct an MSIX installer (described in the next section) for your application and distribute it through the Microsoft Windows App Store. You don’t need to manually create a signing certificate for this option as it is handled for you.
- Construct an MSIX installer and distribute it through your own website. For this option, you need to give your application a digital signature in the form of a
.pfx
certificate. - Collect all of the necessary pieces and build your own zip file.
MSIX packaging
#
MSIX, the new Windows application package format, provides a modern packaging format and installer. This format can either be used to ship applications to the Microsoft Store on Windows, or you can distribute app installers directly.
The easiest way to create an MSIX distribution for a Flutter project is to use the msix
pub package. For an example of using the msix
package from a Flutter desktop app, see the Desktop Photo Search sample.
Create a self-signed .pfx certificate for local testing
#
For private deployment and testing with the help of the MSIX installer, you need to give your application a digital signature in the form of a .pfx
certificate.
For deployment through the Windows Store, generating a .pfx
certificate is not required. The Windows Store handles creation and management of certificates for applications distributed through its store.
Distributing your application by self hosting it on a website requires a certificate signed by a Certificate Authority known to Windows.
Use the following instructions to generate a self-signed .pfx
certificate.
- If you haven’t already, download the OpenSSL toolkit to generate your certificates.
- Go to where you installed OpenSSL, for example,
C:\Program Files\OpenSSL-Win64\bin
. - Set an environment variable so that you can access
OpenSSL
from anywhere:
"C:\Program Files\OpenSSL-Win64\bin"
- Generate a private key as follows:
openssl genrsa -out mykeyname.key 2048
- Generate a certificate signing request (CSR) file using the private key:
openssl req -new -key mykeyname.key -out mycsrname.csr
- Generate the signed certificate (CRT) file using the private key and CSR file:
openssl x509 -in mycsrname.csr -out mycrtname.crt -req -signkey mykeyname.key -days 10000
- Generate the
.pfx
file using the private key and CRT file:
openssl pkcs12 -export -out CERTIFICATE.pfx -inkey mykeyname.key -in mycrtname.crt
- Install the
.pfx
certificate first on the local machine inCertificate store
asTrusted Root Certification Authorities
before installing the app.
Building your own zip file for Windows
#
The Flutter executable, .exe
, can be found in your project under build\windows\runner\<build mode>\
. In addition to that executable, you need the following:
-
From the same directory:
- all the
.dll
files - the
data
directory
- all the
-
The Visual C++ redistributables. You can use any of the methods shown in the deployment example walkthroughs on the Microsoft site to ensure that end users have the C++ redistributables. If you use the
application-local
option, you need to copy:msvcp140.dll
vcruntime140.dll
vcruntime140_1.dll
Place the DLL files in the directory next to the executable and the other DLLs, and bundle them together in a zip file. The resulting structure looks something like this:
Release │ flutter_windows.dll │ msvcp140.dll │ my_app.exe │ vcruntime140.dll │ vcruntime140_1.dll │ └───data │ │ app.so │ │ icudtl.dat ...
At this point if desired it would be relatively simple to add this folder to a Windows installer such as Inno Setup, WiX, etc.
Additional resources
#
To learn how to build an .exe
using Inno Setup to distribute your Flutter desktop app for Windows, check out the step-by-step Windows packaging guide.
Was this page’s content helpful?
Thank you for your feedback! Please let us know what we can do to improve.
Provide details
Unless stated otherwise, the documentation on this site reflects the latest stable version of Flutter. Page last updated on 2024-04-12. View source or report an issue.
??0PlatformMethods@angle@@QEAA@XZ ??4PlatformMethods@angle@@QEAAAEAU01@1564480QEAU01@@Z ??4PlatformMethods@angle@@QEAAAEAU01@AEBU01@@Z ANGLEGetDisplayPlatform ANGLEResetDisplayPlatform FlutterDesktopCreateViewController FlutterDesktopCreateViewControllerLegacy FlutterDesktopDestroyViewController FlutterDesktopGetDpiForHWND FlutterDesktopGetDpiForMonitor FlutterDesktopGetPluginRegistrar FlutterDesktopGetView FlutterDesktopMessengerSend FlutterDesktopMessengerSendResponse FlutterDesktopMessengerSendWithReply FlutterDesktopMessengerSetCallback FlutterDesktopProcessMessages FlutterDesktopRegistrarEnableInputBlocking FlutterDesktopRegistrarGetMessenger FlutterDesktopRegistrarGetView FlutterDesktopRegistrarSetDestructionHandler FlutterDesktopResyncOutputStreams FlutterDesktopRunEngine FlutterDesktopShutDownEngine FlutterDesktopViewGetHWND FlutterEngineCollectAOTData FlutterEngineCreateAOTData FlutterEngineDeinitialize FlutterEngineDispatchSemanticsAction FlutterEngineGetCurrentTime FlutterEngineInitialize FlutterEngineMarkExternalTextureFrameAvailable FlutterEngineNotifyLowMemoryWarning FlutterEngineOnVsync FlutterEnginePostCallbackOnAllNativeThreads FlutterEnginePostDartObject FlutterEnginePostRenderThreadTask FlutterEngineRegisterExternalTexture FlutterEngineReloadSystemFonts FlutterEngineRun FlutterEngineRunInitialized FlutterEngineRunTask FlutterEngineRunsAOTCompiledDartCode FlutterEngineSendPlatformMessage FlutterEngineSendPlatformMessageResponse FlutterEngineSendPointerEvent FlutterEngineSendWindowMetricsEvent FlutterEngineShutdown FlutterEngineTraceEventDurationBegin FlutterEngineTraceEventDurationEnd FlutterEngineTraceEventInstant FlutterEngineUnregisterExternalTexture FlutterEngineUpdateAccessibilityFeatures FlutterEngineUpdateLocales FlutterEngineUpdateSemanticsEnabled FlutterPlatformMessageCreateResponseHandle FlutterPlatformMessageReleaseResponseHandle __FlutterEngineFlushPendingTasksNow kFlutterSemanticsCustomActionIdBatchEnd kFlutterSemanticsNodeIdBatchEnd
// Clip the start previous dash to the start of the circle // The start of the dash we're considering may be clipped by the start of the angleFromStart = mod(angleFromStart, 6.28318530718) half angleFromStart = half(atan(circleEdge.y, circleEdge.x) - dashParams.z) if (angleFromStart - x + dashParams.y > = 6.28318530718) { if (angleFromStart - x - dashParams.y < -0.01) { #define MAX_LINEARIZATION_ERROR 0.25 // 1/4 pixel #error No %s expects argument 'handle' to be an error handle. Did you forget to check Dart_IsError first? ' due to the error ' < Received error while converting exception to string> < Received error while converting stack trace to string> (Error Code: %X + idx: %lld ) ANGLE Display::initialize error ASN1Time error %d Cannot get error message Cluster %zu (start %zu) out of bounds of count %zu Could not start worker thread: result = %d. Decompression error in IDAT Define Restart Interval %u Divide by zero error during constant folding Dynamic recompilation error log: Enable Dart profiling. Profiling information can be viewed from the observatory. Enable an endless trace buffer. The default is a ring buffer. This is useful when very old events need to viewed. For example, during application launch. Memory usage will continue to grow indefinitely however. Enable bare instructions mode. Enable checked mode. Enable deterministic mode. Enable dispatch table based calls. Enable interpreting kernel bytecode. Enable isolate group support. Enable magical pragmas for testing purposes. Use at your own risk! Enable multiple entrypoints per-function and related optimizations. Enable rendering using the Skia software backend. This is useful when testing Flutter on emulators. By default, Flutter will attempt to either use OpenGL or Vulkan. Enable sharing of slow-path code. Enable specializing megamorphic calls from unoptimized code. Enable specializing monomorphic calls from unoptimized code. Error X3504: Error X3531: Error X4014: Error allocating BlendState Error allocating Buffer Error allocating ComputeShader Error allocating DepthStencilState Error allocating DepthStencilView Error allocating GeometryShader Error allocating InputLayout Error allocating PixelShader Error allocating Query Error allocating RasterizerState Error allocating RenderTargetView Error allocating SamplerState Error allocating ShaderResourceView Error allocating Texture2D Error allocating Texture3D Error allocating UnorderedAccessView Error allocating VertexShader Error compiling dynamic compute executable Error compiling dynamic compute executable: Error compiling dynamic geometry executable Error compiling dynamic geometry executable: Error compiling dynamic geometry executable: Error compiling dynamic pixel executable Error compiling dynamic pixel executable: Error compiling dynamic pixel executable: Error compiling dynamic vertex executable Error compiling dynamic vertex executable: Error compiling dynamic vertex executable: Error during layout qualifier parsing. Error finding D3DCompile entry point. Error in user chunk Error querying driver version from DXGI Adapter. Error reading swap chain description, Error releasing tex image from texture Error resizing swap chain buffers, Error while initializing the Dart VM: Error while setting Dart VM flags: Error writing ancillary chunked compressed data Error: Unable to read ' FB fetch requires enable per sample Failed to get the error message for ' Failed to start Flutter engine: error Failed to start accept Failed to start event handler thread %d Failed to start read file thread %d Failed to start write file thread %d Fatal error - scanner input buffer overflow Fatal error in Array::New: invalid len %lld Fatal error in Context::New: invalid num_variables %lld Fatal error in ContextScope::New: invalid num_variables %lld Fatal error in ExternalTypedData::New: invalid len %lld Fatal error in OneByteString::New: invalid len %lld Fatal error in SharedClassTable::Register: invalid index %lld Fatal error in TwoByteString::New: invalid len %lld Fatal error in TypeArguments::New: invalid len %lld Fatal error in TypedData::New: invalid len %lld Fatal error in Utils::VSNPrint with format '%s' Fatal error in dart:async: %s Format error in CRL's lastUpdate field Format error in CRL's nextUpdate field Format error in certificate's notAfter field Format error in certificate's notBefore field FormatMessage failed for error code %d (error %d) Handshake error in client Handshake error in server ICC profile tag start not a multiple of 4 Internal error checking chromaticities Internal error handling cHRM coefficients Internal error handling cHRM-> XYZ Internal error while attempting to post tasks to all threads. It is an error to use gl_WorkGroupSize before declaring the local group size JPEG error with no jmp_buf set. OS error message was a not a utf8 string. Output file write error --- out of disk space? ResolveDynamic error '%s': %s. ResolveStatic error '%s': %s. Screenshot: unable to create snapshot surface Screenshot: unable to make image screenshot Screenshot: unable to make raster image Screenshot: unable to obtain bitmap pixels Show names of internal classes (e.g. OneByteString) in error messages instead of showing the corresponding interface names (e.g. String). Also show legacy nullability in type names. Some users rely on a lost context notification if a GL_OUT_OF_MEMORY error occurs Start Of Frame 0x%02x: width=%u, height=%u, components=%d Start Of Scan: %d components Start chain subtable %d Start lookup %d Start of Image Start of group Start punctuation Start the application paused in the Dart debugger. Static const uint imageIndexStart = Static const uint readonlyImageIndexStart = Throw API error on invalid member access throuh native API. See entry_point_pragma.md Unable to Enter Isolate : Multiple mutators entering an isolate / Dart VM is shutting down Unable to acquire global lock: Unable to allocate global memory: Unable to allocate memory Unable to canonicalize uri '%s': %s Unable to canonicalize uri '%s': library tag handler returned wrong type Unable to canonicalize uri '%s': no library tag handler found. Unable to construct method call from message on channel Unable to create the shared context. Unable to decode issuer public key Unable to decode reply to method invocation on channel Unable to decrypt CRL's signature Unable to decrypt certificate's signature Unable to find device for layer. Unable to find executable location to resolve resource paths. Unable to find library '%s'. Unable to get CRL issuer certificate Unable to get certificate CRL Unable to get clipboard data Unable to get issuer certificate Unable to get local issuer certificate Unable to initialize Winsock: %d Unable to initialize the ICU context from a mapping. Unable to open clipboard Unable to parse JSON message: Unable to release global lock: Unable to resolve class '%s' in library '%s'. Unable to resolve function '%s' in library '%s'. Unable to resolve function '%s' in script '%s'. Unable to resolve static method '%s.%s' in library '%s'. Unable to resolve symbols: Unable to set clipboard data Unable to start engine without AOT data. Unable to un-merge the raster and platform threads. Unable to verify the first certificate Unknown error encoding image. Unknown error occured during Isolate spawning. VirtualFree failed: Error code %d WGL_ARB_create_context_robustness exists but unable to create a context with robustness.
Let’s say your app is misbehaving because of a Flutter engine bug. Let’s debug that!
Use Visual Studio to run your app
Let’s open your app using Visual Studio:
-
Run
flutter build windows
to ensure Flutter has generated a Visual Studio project for your app. -
Open
./build/windows/ALL_BUILD.vcxproj
in Visual Studio. This project builds the native entry point for your Flutter app. -
In the
Solution Explorer
, right click on the project whose name matches your app, and selectSet as Startup Project
.In the screenshot above, my app is called
debug_example
. Your app will likely have a different name! -
Now run your app by pressing
F5
orDEBUG
>Start Debugging
. This should start your app with Visual Studio’s debugger attached.
Configure Visual Studio’s debugger
We need to provide Visual Studio with both the Flutter engine’s source code and the engine’s symbols
(which maps the compiled native code back to source code).
Find your Flutter SDK path
You can find your Flutter SDK path using the terminal: where.exe flutter
Let’s say I have the following output:
PS C:\> where.exe flutter
C:\Code\f\flutter\bin\flutter
C:\Code\f\flutter\bin\flutter.bat
My Flutter SDK path is C:\Code\f\flutter
.
Get the Flutter engine’s source code
In the terminal, use Git to download the Flutter engine source code: git clone https://github.com/flutter/engine
.
Enter the Flutter engine’s directory using cd engine
. This is your Flutter engine path.
Now, switch to your Flutter SDK’s version of the engine:
- Find your Flutter SDK’s engine version by opening
<Flutter SDK path>/bin/internal/engine.version
in a code editor.
This contains the engine commit ID. - Switch to the desired Flutter engine version:
git checkout <engine commit ID>
Note
⚠️ The Flutter SDK’s engine version changes whenever youflutter upgrade
or change channels usingflutter channel
.
You will need to repeat the steps above whenever the SDK’s engine version changes.
Load the engine’s symbols
Let’s tell Visual Studio where it can find the engine’s symbols:
-
Open the Debugging options using
DEBUG
>Options...
. -
Make sure that
Enable Just My Code
is unchecked:This allows the Visual Studio debugger to step into external code, like the Flutter engine.
-
Navigate to the
Symbols
pane and use the+
button to add<Flutter SDK path>/bin/cache/artifacts/engine/windows-x64
as a symbol location: -
Close the
Options
window
Now, let’s actually load the engine’s symbols:
-
Open the
Modules
window usingDEBUG
>Windows
>Modules
(orCtrl+Alt+U
): -
In the
Modules
window, right click theflutter_windows.dll
item and selectLoad Symbols
: -
The engine’s symbols should now be loaded:
Debug!
Pause the app if it isn’t already using Break all
(or Ctrl+Alt+Break
). In the Call Stack
section, you should see a list of method calls. Methods with the flutter_windows.dll!
prefix are part of the Flutter engine:
Double-click on one of these methods. Visual Studio will open a File Explorer popup and ask for the source code location:
In this File Explorer popup, navigate to the the Flutter engine path you git clone
d earlier and press Open
. You should now be able to debug into the Flutter engine’s source code!
Flutter engine’s threads
The Flutter engine uses multiple threads. You can switch between these using the Thread
dropdown:
The most useful threads include:
Main thread
— Runs the app’s entry point, Windows embedder, plugins, etc…io.flutter.ui
— Runs Dart codeio.flutter.raster
— Runs the Flutter engine’s rasterizerio.flutter.io
andio.flutter.worker.*
— Runs IO tasks
Additional resources
- Learn to debug C++ using Visual Studio
- Debugging External Sources with Visual Studio
- Specify symbol and source files in the debugger
Use a Windows Virtual Machine on Linux or any host operating system to develop and distribute Windows applications.
Introduction
Flutter is an open-source framework suitable for developing applications for multiple platforms. You can install it on your operating system of choice for developing web, mobile, and desktop applications; however, you cannot build your applications for all the supported platforms using a single operating system.
I’ve been using Linux Operating System as my primary development environment, mainly because of its power and flexibility. However, I can’t build Windows applications using Flutter on my Linux machine since it requires Visual Studio 2019 for Windows desktop development with C++. However, there is an effective solution available. In this article, I will explain how to set up all the requirements of Flutter on a Windows Virtual Machine to compile an application targeting the Windows operating system.
Create a Virtual Machine
VirtualBox enables you to create a virtual machine (VM) on Linux. The first step is to download and install it on your current operating system. After the installation is complete, open VirtualBox and choose «New» to create a new VM.
Provide a name for your VM, select «Windows 7» as your operating system, and set the memory size as you need. If you don’t have an existing virtual hard disk, select «Create a virtual hard disk now.»
You are required to have at least 30GB of storage on your virtual hard disk. You can choose between a Dynamically Allocated or a Fixed Size virtual hard disk. The Dynamically Allocated type initially takes a limited amount of physical disk space and gradually grows in size as you use your virtual machine. Hence this is a proper choice if the disk space on your system is limited. The Fixed Size type creates a file with the specified size on your physical disk beforehand, and it is much faster than the first type.
If your host system has multiple CPUs, you can allocate more than one processor to operate your VM. It is better not to exceed the maximum number of recommended processors, in my case, 4 CPUs.
It is recommended to increase the video memory size to the maximum value for improving guest machine performance.
Your created guest virtual machine is like real hardware with all parts configurable. To install an operating system on this machine, you can mount Windows Installation DVD/USB or an ISO image file.
You can mount some shared spaces to be accessed by both the host and the guest machine, as this is a more convenient method of sharing storage resources between two operating systems. However, some limitations might occur due to the file system inconsistencies between different types of operating systems.
During the initial steps of the Windows installation, you can select the only drive available on the guest machine and create a single partition. Here, Windows 7 automatically creates a System Reserved and a single primary partition. Select the primary partition for OS installation.
Continue with the remaining configurations until the Windows installation is initiated. The installation process takes some time based on the type of hardware you have.
During the installation, your guest machine will restart multiple times. Do not press any keys if it asks, or the process will be started from the beginning. You can unmount the ISO image file when the installation is finished successfully.
Open menu «Devices» and select «Insert Guest Additions CD Image…» to mount VirtualBox Guest Additions 5.1.18, then run it. After it is finished, you should reboot your guest machine for all the changes to take effect. Now, you will be able to change the size of the guest machine’s window on your host operating system.
Update Windows PowerShell
Check the version of the currently installed PowerShell (PS) on your Windows 7 by running Windows PowerShell from the start menu and entering the following command:
1PS C:\Users\win7> $PSVersionTable.PSVersion 2 3Major Minor Build Revision 4----- ----- ----- -------- 52 0 -1 -1
1PS C:\Users\win7> $PSVersionTable.PSVersion 2 3Major Minor Build Revision 4----- ----- ----- -------- 52 0 -1 -1
Flutter depends on Windows Powershell 5.0 or higher, so we have to update it now. After downloading Windows Powershell 5.1 and extracting Win7AndW2K8R2-KB3191566-x64.zip
file, run existing PS in administrator mode and disable ExecutionPolicy
before executing Install-WMF5.1
script:
1PS C:\Users\win7\Downloads\Win7AndW2k8R2-KB3191566-x64> Set-ExecutionPolicy Bypass 2PS C:\Users\win7\Downloads\Win7AndW2k8R2-KB3191566-x64> powershell.exe -F .\Install-WMF5.1.ps1
1PS C:\Users\win7\Downloads\Win7AndW2k8R2-KB3191566-x64> Set-ExecutionPolicy Bypass 2PS C:\Users\win7\Downloads\Win7AndW2k8R2-KB3191566-x64> powershell.exe -F .\Install-WMF5.1.ps1
After a mandatory system restart, verify the current PS version again for confirmation.
Install Git
Download and install Git 64-bit for Windows. You should be able to run git
commands from PS after the installation is complete.
Install Visual Studio 2019
To create Windows applications using Flutter, you should have Visual Studio 2019 Community on your system.
For Win32, you need the «Desktop development with C++» workload installed, including all of its default components. For UWP, you need the «Universal Windows Platform development» workload installed with the optional UWP C++ tools.
Install Flutter
Now is the time to set up Flutter on your VM. Download flutter_windows_2.5.3-stable.zip and extract the content of the archive to C:\flutter
. Then, search for env
in Windows and add Path
as a user environment variable with the C:\flutter\bin
value. It enables you to call Flutter from any path in PS.
Enable Desktop Support
Open a PS and modify Flutter configuration to enable Windows Desktop support.
1PS C:\> flutter config --enable-windows-desktop
1PS C:\> flutter config --enable-windows-desktop
For Universal Windows Platform (UWP) applications, use the following commands:
1PS C:\> flutter channel dev 2PS C:\> flutter upgrade 3PS C:\> flutter config --enable-windows-uwp-desktop
1PS C:\> flutter channel dev 2PS C:\> flutter upgrade 3PS C:\> flutter config --enable-windows-uwp-desktop
Build an Application
To create a new Flutter application, open a PS and call the flutter create
command. After the application is created, build and release it for the Windows platform.
1PS C:\projects> flutter create myapp 2PS C:\projects\myapp> cd myapp 3PS C:\projects\myapp> flutter run -d windows --release
1PS C:\projects> flutter create myapp 2PS C:\projects\myapp> cd myapp 3PS C:\projects\myapp> flutter run -d windows --release
Distribute as a Zip File
The most efficient way of finding dependencies of an executable file in Windows is using dumpbin.exe
from Microsoft Visual Studio tools. This program is able to list all the dll
files required for the Flutter application to run on Windows properly.
1PS C:\> cd C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\bin\Hostx64\x64 2PS C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\bin\Hostx64\x64> dumpbin.exe /dependents C:\projects\myapp\build\windows\runner\Release\myapp.exe 3 4flutter_windows.dll 5KERNEL32.dll 6USER32.dll 7SHELL32.dll 8ole32.dll 9MSVCP140.dll 10VCRUNTIME140_1.dll 11VCRUNTIME140.dll 12api-ms-win-crt-runtime-l1-1-0.dll 13api-ms-win-crt-stdio-l1-1-0.dll 14api-ms-win-crt-heap-l1-1-0.dll 15api-ms-win-crt-math-l1-1-0.dll 16api-ms-win-crt-locale-l1-1-0.dll
1PS C:\> cd C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\bin\Hostx64\x64 2PS C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\bin\Hostx64\x64> dumpbin.exe /dependents C:\projects\myapp\build\windows\runner\Release\myapp.exe 3 4flutter_windows.dll 5KERNEL32.dll 6USER32.dll 7SHELL32.dll 8ole32.dll 9MSVCP140.dll 10VCRUNTIME140_1.dll 11VCRUNTIME140.dll 12api-ms-win-crt-runtime-l1-1-0.dll 13api-ms-win-crt-stdio-l1-1-0.dll 14api-ms-win-crt-heap-l1-1-0.dll 15api-ms-win-crt-math-l1-1-0.dll 16api-ms-win-crt-locale-l1-1-0.dll
Locate these files in the C:\Windows\System32
folder and copy them into the Release
folder. The following files are required to be included in the root directory of the myapp.exe
executable file. You can ignore the rest.
1flutter_windows.dll 2msvcp140.dll 3myapp.exe 4vcruntime140.dll 5vcruntime140_1.dll
1flutter_windows.dll 2msvcp140.dll 3myapp.exe 4vcruntime140.dll 5vcruntime140_1.dll
And finally, after acquiring all the required dependencies, make a zip
archive out of the application’s folder for distribution.