text
stringlengths
1
474
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.<topic_end>
<topic_start>
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.<topic_end>
<topic_start>
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: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: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.<topic_end>
<topic_start>
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 the build\ 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 SolutionYou 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.<topic_end>
<topic_start>
Distributing Windows apps
There are various approaches you can use for
distributing your Windows application.
Here are some options:<topic_end>
<topic_start>
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.<topic_end>
<topic_start>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