<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Industrial Flutter - Medium]]></title>
        <description><![CDATA[Industrial Flutter explores the possibilities of using Flutter in industrial software applications on embedded and desktop. - Medium]]></description>
        <link>https://medium.com/industrial-flutter?source=rss----0425a63ef963---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Industrial Flutter - Medium</title>
            <link>https://medium.com/industrial-flutter?source=rss----0425a63ef963---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 27 Nov 2026 20:08:36 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/industrial-flutter" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Bringing Flutter to RISC-V]]></title>
            <link>https://medium.com/industrial-flutter/bringing-flutter-to-risc-v-f612aa9d020e?source=rss----0425a63ef963---4</link>
            <guid isPermaLink="false">https://medium.com/p/f612aa9d020e</guid>
            <category><![CDATA[flutter-development]]></category>
            <category><![CDATA[flutter-developer]]></category>
            <category><![CDATA[embedded-systems]]></category>
            <category><![CDATA[risc-v]]></category>
            <category><![CDATA[flutter]]></category>
            <dc:creator><![CDATA[KDAB]]></dc:creator>
            <pubDate>Thu, 28 May 2026 08:05:30 GMT</pubDate>
            <atom:updated>2026-05-28T08:05:30.306Z</atom:updated>
            <content:encoded><![CDATA[<p>From Engine Patches to Running Apps on RISC-V Devices</p><p><em>This blog is written by Hannes Winkler, originally posted on </em><a href="https://www.industrialflutter.com/blogs/bringing-flutter-to-risc-v/"><em>industrialflutter.com</em></a></p><p>Flutter works on many platforms: from Web and Mobile, to Desktop and Embedded. When it comes to embedded, however, support is still constrained by the CPU architecture used. <a href="https://www.industrialflutter.com/blogs/flutter-on-armv6/">In a previous blog post</a>, we made Flutter &amp; Dart work on ARMv6 as a Proof of Concept. Now, we’re going to look at something more modern: The RISC-V architecture is an upcoming, free, open-source CPU architecture, showing great potential specifically for embedded use-cases.</p><p>In cooperation with <a href="https://cloud-v.co/">Cloud-V</a>, we made it possible to run Flutter apps on RISC-V hardware. This involves a few parts: the largest one is RISC-V support in the Dart programming language. Dart has its own compiler backend, which compiles Dart code into architecture-specific native code. So naturally, it is the component that contains the most architecture-specific parts. Fortunately, adding a RISC-V backend to the Dart SDK was already done by the Dart team in 2022: <a href="https://dart-review.googlesource.com/c/sdk/+/217289">https://dart-review.googlesource.com/c/sdk/+/217289</a></p><p>Additionally, changes to the Flutter Engine (specifically the build scripts) are required to enable building for RISC-V. Lastly, the part that brings it all together — and that actually allows building and running Apps on RISC-V devices — is the Flutter Tool. We are working on PRs for the official Flutter Tool &amp; Engine, but in the meantime, that functionality can be used via <a href="https://pub.dev/packages/flutterpi_tool">flutterpi_tool</a>.</p><h3>Engine</h3><p>First, the Flutter engine has to be built for RISC-V. Normally, this involves <a href="https://github.com/flutter/flutter/blob/master/engine/src/flutter/docs/contributing/Setting-up-the-Engine-development-environment.md">checking out the engine sources</a> and then using the engines gn script to generate the build files.</p><p>As an example, building for a Linux ARM64 machine roughly looks like this:</p><pre>$ gclient sync<br>...<br><br>$ pushd engine/src &amp;&amp; ./flutter/tools/gn \<br> --linux --linux-cpu arm64 \<br> --runtime-mode release \<br> --embedder-for-target --disable-desktop-embeddings \<br> --no-enable-unittests --no-build-glfw-shell \<br> --no-build-embedder-examples<br>Generating GN files in: out/linux_release_arm64<br>Generating compile_commands took 77ms<br>Done. Made 1178 targets from 345 files in 433ms<br><br>$ ninja -C out/linux_release_arm64</pre><p>The gn script that is being invoked there doesn&#39;t actually do that much; it&#39;s just a convenience script that converts the given command-line arguments into a different form, a args.gn file. This is then used by <a href="https://gn.googlesource.com/gn/">the actual</a> gn<a href="https://gn.googlesource.com/gn/"> tool</a> to generate the build files. So technically, it&#39;s not strictly necessary to modify it; it would also be possible to skip the gn script and craft a special args.gn file for RISC-V manually. In this case, we modified it to allow passing --linux-cpu riscv64, for development convenience.</p><h3>Setting up RISC-V cross-compilation</h3><p>Of course, if you now try running a build like that, you’ll undoubtedly run into errors. One of the first errors that’ll appear is that the build scripts try to use the wrong sysroot for building the RISC-V 64 binaries.</p><p>The reason for that can be found in the sysroot.gni<a href="https://github.com/flutter/flutter/blob/aef4718b39569939ec0052c44819cd01176234ca/engine/src/build/config/sysroot.gni#L24-L37">^1</a>, which is a gn &quot;header&quot;. This header has the job of resolving the correct sysroot to be used for cross-compilation. By default, the Flutter build will download &amp; use its own custom sysroot<a href="https://github.com/flutter/flutter/blob/master/engine/src/build/linux/sysroot_scripts/install-sysroot.py">^2</a> from a Google storage bucket. For platforms like linux-armv7, which are also not officially supported by the Flutter build, it&#39;s enough to just manually invoke those scripts to download the required sysroot. For RISC-V, however, this unfortunately does not work because there&#39;s no RISC-V sysroot present that could be downloaded from the Google storage bucket.</p><p>There are multiple ways to go forward here. You could, for example, build your own custom sysroot and use that. That could be done on a native RISC-V machine, in a VM, or in a Docker container. However, there’s an easier way: installing a RISC-V gcc will also install a minimal RISC-V “sysroot” that can be used to build simple binaries. Fortunately, the Flutter engine intentionally doesn’t have a lot of shared library decencies, which is ideal because we are using a minimal sysroot that might not have them. This approach was attempted and proved to work well enough for our purposes.</p><p>In practice, that means compilation is done without an explicit sysroot and clang auto-selects the RISC-V libc headers.</p><pre>--- a/engine/src/build/config/sysroot.gni<br>+++ b/engine/src/build/config/sysroot.gni<br>@@ -21,7 +21,16 @@ if (current_toolchain == default_toolchain &amp;&amp; target_sysroot != &quot;&quot;) {diff<br>   import(&quot;//build/config/android/config.gni&quot;)<br>   sysroot = rebase_path(&quot;$android_toolchain_root/sysroot&quot;, root_build_dir)<br> } else if (is_linux &amp;&amp; !is_chromeos) {<br>-  if (use_default_linux_sysroot &amp;&amp; !is_fuchsia) {<br>+  # install-sysroot.py doesn&#39;t provide a RISC-V 64 sysroot, which means<br>+  # we can&#39;t provide a default sysroot.<br>+  # <br>+  # If we make this fail here, when use_default_linux_sysroot == true and <br>+  # current_cpu == &quot;riscv64&quot;, the sysroot choosing for arm/arm64/x64<br>+  # will fail as well, so we wouldn&#39;t be able to cross-compile the gen_snapshots<br>+  # and build the libflutter_engine.so in one build anymore.<br>+  #<br>+  # Instead we just silently use no sysroot for riscv64 at all.<br>+  if (use_default_linux_sysroot &amp;&amp; !is_fuchsia &amp;&amp; current_cpu != &quot;riscv64&quot;) {<br>     if (current_cpu == &quot;x64&quot;) {<br>       sysroot =<br>           rebase_path(&quot;//build/linux/debian_sid_amd64-sysroot&quot;, root_build_dir)</pre><p>One more thing we have to do is actually make the compiler target riscv64-linux-gnu. There&#39;s a specific gn file that does the compiler setup. The RISC-V target handling can just be added there:</p><pre>--- a/engine/src/build/config/compiler/BUILD.gn<br>+++ b/engine/src/build/config/compiler/BUILD.gn<br>@@ -288,6 +288,11 @@ config(&quot;compiler&quot;) {<br>       if (arm_tune != &quot;&quot;) {<br>         cflags += [ &quot;-mtune=$arm_tune&quot; ]<br>       }<br>+    } else if (current_cpu == &quot;riscv64&quot;) {<br>+      assert(is_clang)<br>+<br>+      cflags += [ &quot;--target=riscv64-linux-gnu&quot; ]<br>+      ldflags += [ &quot;--target=riscv64-linux-gnu&quot; ]<br>     }<br> <br>     if (!is_android) {</pre><h4>Dependency issues</h4><p>Attempting to build the engine now will result in an error while resolving the freetype2 headers via pkg-config. However, as far as I can tell, the engine checks out &amp; builds its own copy of freetype2, so it seems like this resolved dependency isn&#39;t actually used. Simply removing the offending code fixes the issue:</p><pre>--- a/engine/src/build/config/linux/BUILD.gn<br>+++ b/engine/src/build/config/linux/BUILD.gn<br>@@ -27,9 +27,9 @@ config(&quot;fontconfig&quot;) {<br>   libs = [ &quot;fontconfig&quot; ]<br> }<br> <br>-pkg_config(&quot;freetype2&quot;) {<br>-  packages = [ &quot;freetype2&quot; ]<br>-}<br>+#pkg_config(&quot;freetype2&quot;) {<br>+#  packages = [ &quot;freetype2&quot; ]<br>+#}<br> <br> config(&quot;x11&quot;) {<br>   libs = [</pre><h4>Compatibility Fixes</h4><p>In addition to that, some engine headers do architecture detection (using preprocessor defines), and RISC-V detection was added to them:</p><pre>--- a/engine/src/flutter/assets/native_assets.cc<br>+++ b/engine/src/flutter/assets/native_assets.cc<br>@@ -17,6 +17,8 @@ namespace flutter {<br> #define kTargetArchitectureName &quot;ia32&quot;<br> #elif defined(FML_ARCH_CPU_X86_64)<br> #define kTargetArchitectureName &quot;x64&quot;<br>+#elif defined(FML_ARCH_CPU_RISCV64)<br>+#define kTargetArchitectureName &quot;riscv64&quot;<br> #else<br> #error Target architecture detection failed.<br> #endif</pre><pre>--- a/engine/src/flutter/fml/build_config.h<br>+++ b/engine/src/flutter/fml/build_config.h<br>@@ -96,6 +96,11 @@<br> #elif defined(__pnacl__)<br> #define FML_ARCH_CPU_32_BITS 1<br> #define FML_ARCH_CPU_LITTLE_ENDIAN 1<br>+#elif defined(__riscv) &amp;&amp; __riscv_xlen == 64 &amp;&amp; __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__<br>+#define FML_ARCH_CPU_RISCV_FAMILY 1<br>+#define FML_ARCH_CPU_RISCV64 1<br>+#define FML_ARCH_CPU_64_BITS 1<br>+#define FML_ARCH_CPU_LITTLE_ENDIAN 1<br> #else<br> #error Please add support for your architecture in flutter/fml/build_config.h<br> #endif</pre><pre>--- a/engine/src/flutter/third_party/tonic/common/build_config.h<br>+++ b/engine/src/flutter/third_party/tonic/common/build_config.h<br>@@ -103,6 +103,11 @@<br> #define ARCH_CPU_32_BITS 1<br> #define ARCH_CPU_LITTLE_ENDIAN 1<br> #endif<br>+#elif defined(__riscv) &amp;&amp; __riscv_xlen == 64 &amp;&amp; __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__<br>+#define ARCH_CPU_RISCV_FAMILY 1<br>+#define ARCH_CPU_RISCV64 1<br>+#define ARCH_CPU_64_BITS 1<br>+#define ARCH_CPU_LITTLE_ENDIAN 1<br> #else<br> #error Please add support for your architecture in build/build_config.h<br> #endif</pre><h3>Building the RISC-V Engine in CI</h3><p>All those patches were then pushed to a custom CI pipeline at <a href="https://github.com/ardera/flutter-ci">https://github.com/ardera/flutter-ci</a>. This CI essentially watches for Flutter updates and builds the engine with the applied compatibility changes, for a lot of different architectures:</p><ul><li>It builds the Flutter engine for armv7, aarch64 &amp; x64, with separate debug symbols, partially with CPU-specific tuning (for Pi 3 &amp; 4)</li><li>Furthermore, it builds the Dart cross compiler (gen_snapshot) for a lot of different host &amp; target combinations, including linux (arm/arm64/x64/riscv64), windows &amp; mac targeting all the different linux architectures.</li></ul><p>The built artifacts for all the different architectures are then published as a GitHub release.</p><h3>Running RISC-V Flutter Apps</h3><p>Now that all the necessary artifacts are present, they can be used to assemble Flutter apps. Normally, this is done by the Flutter Tool, which downloads these artifacts from a Google Storage bucket maintained by the Flutter team. In this case, however, the modifications were made to flutterpi_tool.</p><p>In general, there was not much work involved here. Just recognizing riscv64 as a uname output for architecture detection and adding the correct values to some enumerations:<br><a href="https://github.com/ardera/flutterpi_tool/commit/443c8efbfdf884701a1e097726b7a6039a0c19d5">https://github.com/ardera/flutterpi_tool/commit/443c8efbfdf884701a1e097726b7a6039a0c19d5</a></p><h3>Demonstration</h3><p><a href="https://www.kdab.com/">KDAB</a> used a Banana Pi BPI-F3, with free compute provided by <a href="https://cloud-v.co/">Cloud-V</a>. This platform helped us to get Flutter running on RISC-V. You can try it yourself and speed up your own software development by getting a free RISC-V compute from Cloud-V.</p><p>Contact:<br>Cloud V cloud-v@10xengineers.ai<br>KDAB <a href="https://www.kdab.com/contact/">https://www.kdab.com/contact/</a></p><p>Thanks to <a href="https://cloud-v.co/">Cloud-V</a> (a project by <a href="https://10xengineers.ai/">10xEngineers</a>) for demonstrating how to run Flutter on RISC-V hardware.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2Fvx0VmmmjejA%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3Dvx0VmmmjejA&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2Fvx0VmmmjejA%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/44034ee744c669163a4f546c80c6d5fa/href">https://medium.com/media/44034ee744c669163a4f546c80c6d5fa/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f612aa9d020e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/industrial-flutter/bringing-flutter-to-risc-v-f612aa9d020e">Bringing Flutter to RISC-V</a> was originally published in <a href="https://medium.com/industrial-flutter">Industrial Flutter</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Flutter Desktop Single-Instance Applications]]></title>
            <link>https://medium.com/industrial-flutter/flutter-desktop-single-instance-applications-83c0d3e6b243?source=rss----0425a63ef963---4</link>
            <guid isPermaLink="false">https://medium.com/p/83c0d3e6b243</guid>
            <category><![CDATA[flutter-desktop]]></category>
            <category><![CDATA[flutter-development]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[flutter-application]]></category>
            <dc:creator><![CDATA[KDAB]]></dc:creator>
            <pubDate>Tue, 26 May 2026 10:13:30 GMT</pubDate>
            <atom:updated>2026-05-28T08:08:41.569Z</atom:updated>
            <content:encoded><![CDATA[<p><em>This blog is written by Werner Scholtz, originally posted on </em><a href="https://www.industrialflutter.com/blogs/flutter-desktop-single-instance-applications/"><em>industrialflutter.com</em></a></p><p>Most desktop applications are single-instance, meaning that if the user attempts to open the application again, the existing instance is typically brought to the foreground instead of launching a new one.</p><p>Flutter applications do not behave like this out of the box for all desktop platforms. Desktop Linux and Windows require some extra work.</p><h3>Section 1: Using packages</h3><p>Using packages to achieve single-instance applications in Flutter is possible. Basic functionality to focus on an existing window when it is re-launched is supported. Using packages is a lot simpler than modifying platform-specific code generated by Flutter.</p><p>Recommended packages:</p><ul><li><a href="https://pub.dev/packages/unix_single_instance">unix_single_instance</a>: Prevents multiple instances on Linux/macOS.</li><li><a href="https://pub.dev/packages/windows_single_instance">windows_single_instance</a>: A similar solution for Windows.</li><li><a href="https://pub.dev/packages/window_manager">window_manager</a>: Provides control over window states like showing and focusing.</li></ul><p>Example:</p><ol><li>flutter pub add window_manager</li><li>flutter pub add windows_single_instance</li><li>flutter pub add unix_single_instance</li></ol><pre>void main(List&lt;String&gt; args) async {<br> WidgetsFlutterBinding.ensureInitialized();<br>   // Initialize the window manager to control the app window<br> await windowManager.ensureInitialized();<br><br>  // Enforce single-instance behavior based on the platform<br> if (Platform.isLinux || Platform.isMacOS) {<br>   if (!await unixSingleInstance(args, _onSecondInstance)) exit(0);<br> } else if (Platform.isWindows) {<br>   await WindowsSingleInstance.ensureSingleInstance(<br>    args,<br>    &quot;custom_identifier&quot;,<br>    onSecondWindow: _onSecondInstance,<br>   );<br> }<br><br>  runApp(const MyApp());<br>}<br><br>// Handle what happens when a second instance is launched<br>void _onSecondInstance(List&lt;dynamic&gt; decodedArgs) async {<br>  windowManager.waitUntilReadyToShow(null, () async {<br>    await windowManager.show();<br>    await windowManager.focus();<br>  });<br>}</pre><h3>Section 2: Manual implementation</h3><p>You can achieve the same, and in some cases, more reliable results, by implementing single-instance enforcement in the files generated by Flutter. Doing it this way allows you much finer control over the behavior. It does have some downsides, as you need to maintain the code yourself.</p><p><em>Note:<br>It is possible to enforce single instances using Dart’s</em> <a href="https://api.flutter.dev/flutter/dart-io/RandomAccessFile-class.html"><em>RandomAccessFile</em></a>,<em> as it provides a way to lock files. The first instance would lock a file, the second instance would check if the file is locked, and then not start.</em></p><h3>Linux Desktop</h3><p>Desktop Linux applications built with Flutter use the GTK framework under the hood. By default, a Flutter application on Linux may allow multiple instances to run simultaneously. To enforce single-instance behavior, you can make changes to the linux/my_application.cc file. Below are the steps and explanations for each modification.</p><h3>Step 1: Remove the G_APPLICATION_NON_UNIQUE Flag</h3><p>The G_APPLICATION_NON_UNIQUE flag in GTK allows multiple instances of an application to run. To enforce single-instance behavior, you need to remove this flag from the application initialization code.</p><pre>MyApplication* my_application_new() {<br>  return MY_APPLICATION(<br>	g_object_new(<br>		my_application_get_type(), <br>		&quot;application-id&quot;, APPLICATION_ID,<br>		// &quot;flags&quot;, G_APPLICATION_NON_UNIQUE,<br>    	nullptr)<br>	);<br>}</pre><p>By removing the G_APPLICATION_NON_UNIQUE flag, the application becomes single-instance.</p><h3>Step 2: Check for Existing Windows and Present Them</h3><p>When the application is re-launched, the GApplication::activate signal is triggered. In this signal handler, you can check if a window is already open. If it exists, bring it to the foreground using the gtk_window_present() function. Otherwise, create a new window.</p><pre>// Implements GApplication::activate.<br>static void my_application_activate(GApplication* application) {<br>    MyApplication* self = MY_APPLICATION(application);<br><br>    GList* list = gtk_application_get_windows(<br>GTK_APPLICATION(application));<br><br>    GtkWindow* existing_window = list ? GTK_WINDOW(list-&gt;data) : NULL;<br><br>    if (existing_window) {<br>        gtk_window_present(existing_window);<br>    } else {<br>        // ...<br>  // Generated flutter code<br>  // ...<br>    }<br>}</pre><p><em>Note:<br>Linux distributions running Wayland have strict focus behaviors, and therefore, the above solution is inadequate for focusing the window. Instead, a request to show the window is made, and might appear as a notification.</em></p><h3>Windows</h3><p>By default, Windows desktop applications allow multiple instances to run simultaneously. To enforce single-instance behavior in a Flutter Windows app, you can make modifications to the windows/runner/main.cpp file.</p><h3>Step 1: Create a Named Mutex</h3><p>By creating a named <a href="https://en.wikipedia.org/wiki/Mutual_exclusion">mutex</a> (short for “mutual exclusion”) when starting a Flutter application, we can use it to enforce single-instance behavior.</p><p>Add the following code to the beginning of the wWinMain() function:</p><pre>#define APP_MUTEX_NAME L&quot;Global\\MyUniqueFlutterAppMutex&quot;<br><br>int APIENTRY wWinMain(...) {<br> HANDLE hMutex = CreateMutex(NULL, TRUE, APP_MUTEX_NAME);<br> if (GetLastError() == ERROR_ALREADY_EXISTS) {<br>     // App is already running.<br> }<br><br> ...<br>}</pre><h3>Step 2: Find and Present the Existing Window</h3><p>When the application detects that another instance is running, it brings the existing app window to the foreground instead of launching a new one. If you use something like window_manager to change the name of the window, the single instance will still be enforced; however, focusing on the existing window will not work.</p><p>Add the following code inside the if (GetLastError() == ERROR_ALREADY_EXISTS) block:</p><pre>HWND hwnd = FindWindow(NULL, APP_WINDOW_NAME);<br>if (hwnd) {<br>    ShowWindow(hwnd, SW_RESTORE);<br>    SetForegroundWindow(hwnd);<br>}<br>return 0;</pre><h3>Step 3: Set a Unique Window Name</h3><p>The window title serves as the identifier for FindWindow.</p><p>Update the Create call for the main window to use a unique name defined as APP_WINDOW_NAME:</p><pre>#define APP_WINDOW_NAME L&quot;unique_title&quot;<br><br>if (!window.Create(APP_WINDOW_NAME, origin, size)) {<br>    return EXIT_FAILURE;<br>}</pre><p>When the application exits or crashes, the mutex is automatically destroyed.</p><p>Add this code before the return EXIT_SUCCESS; statement:</p><pre>if (hMutex) {<br>    ReleaseMutex(hMutex);<br>}</pre><h3>macOS</h3><p>Flutter on macOS typically handles single-instance applications quite well on its own. When you launch a second instance of an application, the system usually brings the existing instance to the front. However, you can ensure the behavior by modifying the macos/Runner/AppDelegate.swift file.</p><h3>Step 1: Override the applicationShouldHandleReopen Function</h3><p>This method ensures that if the app is already running and a new instance is opened, the existing window is brought to the foreground.</p><p>Add this function to the AppDelegate class.</p><pre>override func applicationShouldHandleReopen(_ sender: NSApplication, hasVisibleWindows flag: Bool) -&gt; Bool {<br>  if !flag {<br>      sender.windows.forEach { $0.makeKeyAndOrderFront(self) }<br>  }<br>  return true<br>}</pre><h3>Step 2: Override the applicationDidFinishLaunching Function</h3><p>This function is called when the app finishes launching. It checks if there are other instances of the app running. If it finds another instance, it will activate the existing one and terminate the new instance.</p><p>Add this function to the AppDelegate class.</p><pre>override func applicationDidFinishLaunching(_ notification: Notification) {<br>  super.applicationDidFinishLaunching(notification)<br><br>  let appBundleIdentifier = Bundle.main.bundleIdentifier!<br><br>  let runningApps = NSRunningApplication.runningApplications(withBundleIdentifier: appBundleIdentifier)<br>  if runningApps.count &gt; 1 {<br>      // App is already running, activate the existing instance<br>      runningApps.first?.activate(options: .activateIgnoringOtherApps)<br>      NSApp.terminate(nil)<br>  }<br>}</pre><h3>Summary</h3><p>By implementing single-instance functionality, you can provide a polished and user-friendly experience for desktop applications. Whether you choose to use existing packages or dive into platform-specific code, Flutter makes it possible to achieve this seamlessly across platforms. The choice ultimately depends on your app’s requirements and your development preferences.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=83c0d3e6b243" width="1" height="1" alt=""><hr><p><a href="https://medium.com/industrial-flutter/flutter-desktop-single-instance-applications-83c0d3e6b243">Flutter Desktop Single-Instance Applications</a> was originally published in <a href="https://medium.com/industrial-flutter">Industrial Flutter</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>