Blog

Home / Blog

Rapid UI Development with Flutter for Windows

Billy Yann
Deep learning and machine learning specialist, well-versed with experience in Cloud infrastructure, Block-chain technologies and Big Data solutions.
October 15, 2020


Google's Cross-Platform User Interface

One of the biggest news in the software world is that Google's cross-platform user interface tool arrives on Windows. The user interface tool serves as a support for a Universal Windows Platform (UWP) and Win32. Several programming tools make it easier for targeting multiple platforms from a single code-base, which results in a reduced load for developers while an increased reach for the apps.

A windows platform for a mobile development tool!

In a surprising move, an established mobile development tool has added Windows as a new platform. Recently, it has come to light that, Google's Flutter mobile development environment is adding a build-target in Windows. This process gets done alongside existing support of Android, iOS, macOS, Linux, and the web! With these latest developments, as a programmer or developer, you can design & develop Flutter apps for Win32. The same controls, as well as design tools, get used to delivering the desktop code at the same time for building mobile apps.

Interestingly, more than half of Flutter developers utilize Windows development tools as Flutter's UI tooling is native code. It works well with standard Windows API calls and one can use it with either new or existing code.

Usage of Flutter on Windows

As is known, Flutter is developed around the latest version of Google's Dart language. The Dart language is a C-like language with its attributes like that of C# and JavaScript. The language construct of Dart is similar to that of .NET and this makes it easier to start coding in fairly simple ways. The Windows support offered by Flutter is experimental as of now and it warrants in making changes to a standard installation from the command line. An upgraded dev channel helps with Flutter running in a Windows platform. Command-line Flutter tools get used for enabling the much-needed Window's desktop support. Restart any open editors and check for Windows support that gets enabled by checking for all connected devices. Flutter doctor utility check is run to identify those appropriate dependencies are installed.

The Windows desktop usually relies on Visual Studio 2019 with its C++ development tools, unlike the mobile device versions of Flutter. With the help of existing mobile Flutter apps, one can work in the Visual Studio Code, which one needs to be brought into a desktop. Desktop Flutter needs the Windows C++ compiler for creating apps with all the required supporting libraries.

Flutter Applications on Windows

For developing Flutter applications on Windows, one needs Visual Studio's C++ tools with appropriate edits and designs that match your Flutter desktop applications in Visual Studio Code. A Flutter plug-in gets used for switching out of Visual Studio during the editing process of C++ or apt use of Windows SDKs (Software Development Kits). Developing a new project automatically generates a scaffolding, which is needed to build a Windows Desktop Application alongside the default Android as well as iOS versions. One can edit the application code using a common main.dart file that gets compiled into appropriate versions at build time.

Common Dart code remains in the lib folder and the Windows folder is where one writes a platform-specific code; this keeps it separate from any cross-platform functions. The approach allows in building over your existing investments inside the Windows code & Application Programming Interfaces (APIs) with the use of Flutter's Platform Channels. This process helps to deliver interoperability between the Windows C++ code as well as Flutter's Dart.

The Visual Studio Code Flutter & Dart tools require Android Studio to be installed. These installations help with developing Android versions of the apps. For a cross-platform app, it is wise to write any Android code in Android Studio. This process helps with saving the Kotlin Code into your Flutter app's Android code tree. According to experts, sharing a code structure in such a way makes sense with the option of having Visual Studio Code for editing the Windows C++ code. The full Visual Studio IDE (Integrated Development Environment) has more affordances with better library support, making it a preferable development environment for certain codes. These codes need to use the Win32 SDK and libraries to work properly.

Flutter

Windows SDKs, APIs, and Libraries with Flutter

Flutter gets designed for working across several developmental stacks and offers two separate routes for working with Windows-native APIs. The first includes platform channels that provide a way of passing messages from Flutter UI to a native API. A platform plug-in is used as a wrapper for the API. However, it is not suited for all the Windows APIs. The second route includes using of a Foreign Function Interface for linking directly to a native library and use its API calls. This approach is more apt for delivering the Windows functionality to a Flutter App. This is because you can link to an existing or new code directly using either static or dynamic links. The native codes need to have available C symbols for Flutter codes to link to them. Any C++ code needs to be exported in C format via the extern option.

Most of the Windows SDK libraries get already compiled and thus, dynamic linking is required for bringing them into your Flutter applications. The Flutter DynamicLibrary.open function is used for adding them on to the applications, which is then treated like a Flutter plug-in. Flutter team is working on a Win32 plug-in that provides access for most of the Windows APIs; ready for use in your code.

Tool for Rapid, Collaborative UI Development

Flutter comes with a hot reload option and one can have a copy of the code running and attach it to the debugger. You can make changes to the code while hitting a reload button in the Visual Studio Code terminal. A hot restart option is available as well if you prefer it that way. A really useful feature of Flutter is to quickly change UI or business logic without restarting an app. The programming becomes more interactive with the ability to bring in suggested changes quickly. This process helps in getting an instant response from your development partners. Once it's ready to publish & deploy the code, an .exe file gets generated with support DLLs, which is ready for packaging with your choice of installer.

With Flutter, you are not limited to Win32 either, as a Universal Windows Platform (UWP) Flutter shell is under development and being used for Store Apps. The overall result is a flexible & powerful cross-platform UI that works with native codes across a wide range of platforms. These platforms scale up to larger screens of PCs, works with both modern & legacy Windows Software Development Kits (SDKs), and should be ready for Project Reunion.

Project Reunion

Project Reunion is referred to as a set of libraries, frameworks, tools, and components that can be used in your apps for accessing powerful Windows platform functionality from all kinds of applications on many Windows versions. The project combine, powers of Win32 native applications alongside modern API usage techniques; apps light up when it's working! Windows app use parts of Project Reunion without having to rewrite a new model or deployment system. The Project Reunion provides a single & consistent Application Programming Interface (API) surface for all existing functionalities. This process helps with the automatic adaptation of your preferred app model and deployment mechanism. Microsoft is slated to deliver new Windows functionalities as part of the Project Reunion Family and through this feature, developers take advantage of it in their apps when they design & develop!

Summary

With rapid UI development using Flutter for Windows, many applications can be designed & developed in the Windows platform. Google's cross-platform user interface helps in designing & developing several native apps in record time. This platform works with Windows for mobile app development. Apps get developed for Win32, a Windows API (Application Programming Interface). The Visual Studio Code Flutter as well as Dart tools get utilized for app development in the Windows platform. With a Windows C++ compiler, apps get created using some supporting libraries. Flutter provides two separate ways of working with Windows APIs. Project Reunion works well with Flutter for creating native apps via Win32.

Conclusion

Native apps get developed in the Windows platform with the help of Flutter, and Visual Studio. A rapid UI development with Flutter for Windows makes it possible to design & develop mobile apps. Dart tools are also used in the process of developing native apps on the Windows platform. Flutter helps with optimum use of Win32, a Windows API that works as a Universal Windows Platform (UWP) for developing & using the store apps. A flexible, as well as powerful cross-platform UI, gets developed with native codes using Flutter in the Windows medium, which can be used in any platform with ease.