Flutnet Architecture

 

Flutnet architecture exploit the possibility to add Flutter inside an existing application, called Flutter Embedding. Using this technique, we realized a set of tools, libraries and project-templates allowing all Xamarin Developers to use this feature in a very simple and powerful way.

The main responsibility to provide communication between the two different module is provided by the Flutnet Bridge component, present in Flutnet framework. The main idea is that

You can expose your platform code to Flutter using the Platform Services.

In this section we will discuss about the Flutnet project structure, and how it is integrated within a classic Visual Studio solution. 

 

 


The idea behind a Flutnet Project

A Flutnet project can be divided in 3 macro section:

  1. Xamarin Android / iOS project;
  2. NET standard project, used to share code between the platforms;
  3. Flutter module project, for the user interface.

 

In Xamarin, the most useful way to share code between platforms is to add a .NET standard project in the solution, so we can share code between platforms.

Flutnet framework relies on this usual procedure to provide communication from Xamarin to Flutter and vice versa.

The concept about the PlatformService is based on the idea that you can expose your cross platform code to Flutter using a specific attribute notation. 

 

 

 


How to expose your Platform C# code?

Applying $ flutnet pack command to your shared NET standard project (*.dll), the tool will generated a "Dart package", that is basically a library needed by Flutter to interact with Xamarin.

This library will contain a binding to all exposed C# code. For more details see Platform Services, Data & Events.

 

 


Accessing Xamarin code from Flutter

To expose a service instance to Flutter you must register it to the FlutnetRuntime using an unique identification id, in form of a string. This key will be used in Flutter to reference the specific instance you just registered.

 

 


Flutnet projects list 

The involved projects in a Flutnet application will be:

  1. Xamarin Android App
  2. Xamarin iOS App
  3. NET Standard "Service" Library
  4. Dart bridge package
  5. Flutter module project

 

Before deepening into details try to Write your first Flutnet app in order to understand the basics behind it.