Making the app single-instanced
Single-instanced apps only allow one instance of the app running at a time. Flutter Windows apps are multi-instanced by default. If a first instance exists when trying to start a new instance, end the new instance and activate the first instance.
Via the FindWindow
method
Find the window HWND
named single_instance_example
by FindWindow
, activate the window if it exists and end the current program.
Please change
single_instance_example
to the name of your app.
Change the file windows/runner/main.cpp
as follows: