Flutnet.Android | Flutnet.iOS |
---|---|
This repository holds the class libraries that allow the communication between Flutter and Xamarin inside a Xamarin.Android or Xamarin.iOS project. The main components for initializing and managing this communication layer are the FlutnetRuntime and the FlutnetBrigde classes. For more information on the overall architecture please read through the Flutnet documentation.
These libraries are published on NuGet Gallery with the names Flutnet.Android and Flutnet.iOS.
Flutnet is a set of tools and libraries that allows you to create rich and beautiful Xamarin apps using Flutter as UI Layer and .NET as backend. For more details please visit https://www.flutnet.com/.
To build and run the source projects and the sample apps, you need a macOS properly configured with:
- Xamarin (Visual Studio 2019 for Mac version 8.9.5 or later)
- Xcode with Command Line Tools (version 12.3 or later)
- Flutter SDK (version 2.0.4 or later)
For specific instructions on how to install and configure Flutter please refer to:
- The official Flutter installation guide
- The Flutnet documentation page (you can skip the last section Installing Flutnet SDK)
To check if Flutter is correctly installed run:
flutter doctor -v
- Build the source projects
- Create the NuGet packages
- (optionally) Build using custom Flutnet.Interop packages
The following script will build all the projects within the Flutnet.sln
solution, restoring all the required NuGet packages:
src/Flutnet.Android
src/Flutnet.iOS
src/Flutnet.ServiceModel
scripts/build-src.sh
You can always compile the .sln file in a IDE. Please make sure to build
Release
configuration before moving on to the next step.
Once the Xamarin bindings have been built, run the following script to create the corresponding NuGet packages:
scripts/pack.sh
All the packages will be placed into artifacts/nuget-packages/
folder.
The projects in this repository reference by default the Flutnet.Interop packages that are published on NuGet Gallery. If you want these projects to reference your own bindings (i.e. local NuGet packages that you built on your own), please edit the NuGet.Config
files and/or the <PackageReference>
inside each .csproj
(both under src/
and samples/
folders) accordingly.
Before building the projects, you may want to clean the NuGet cache first by running:
scripts/clear-nuget-cache.sh
Folder samples/
contains a full example of what you can do with Flutnet. In this folder you can find:
-
A Flutter module (
flutter_module/
) defining the UI layer. In this case it's a simple view showing a counter and two buttons for incrementing and decrementing the value. -
A Visual Studio solution (
Flutnet.Samples.sln
) containing:- A Xamarin.Android app (
Flutnet.Sample.Android
) - A Xamarin.iOS app (
Flutnet.Sample.iOS
) - A further Xamarin.Android bindings library (
Flutnet.ModuleInterop.Android
) needed to embed the AAR representing the UI of the Flutter module - A .NET Standard class library (
Flutnet.Sample.ServiceLibrary
) containing the code shared between Android and iOS. It actually represents the business logic layer where the increment and decrement functions are implemented
- A Xamarin.Android app (
-
A Flutter package (
flutter_package
) containing the Dart code where all the communication logic with the native side (Xamarin) is implemented.
This project structure may look complex at a first glance. However, most of the work is done by Flutnet SDK behind the curtains. Please consult the official documentation to better understand Flutnet and its architecture.
To ensure we're using the latest NuGet Packages, we can clean the NuGet cache first by running:
scripts/clear-nuget-cache.sh
Now we can run:
scripts/build-samples.sh
This script will perform the following tasks:
- Build the Flutter module
- Restore all the required NuGet packages for the sample solution
- Build all the projects within the solution
Once the script has completed, you can open the samples/Flutnet.Samples.sln
solution in your IDE and start debugging both the Xamarin.Android and the Xamarin.iOS app in a simulator or on a real device.
The sample projects reference by default the Flutnet packages that are published on NuGet Gallery. If you want these projects to reference your own runtime libraries (i.e. local NuGet packages that you built on your own), please edit the
samples/NuGet.Config
file and/or the<PackageReference>
inside each.csproj
accordingly.
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
This project is licensed under the LPGL v3 license (https://www.gnu.org/licenses/lgpl-3.0.html)