Skip to Content
Technical Articles

Flutter with SAP Cloud Platform SDK

Flutter with SAP Cloud Platform SDK


One single mobile development language for multiple-platforms is always a dream for pass few years. We have gone through a few of different paths, such as Cordova WebView, React Native, and recently NativeScript for generating Native SDK during runtime. And recently we keep hearing the term of Flutter which has been adopted by some big companies as the cross-platform development language.

I believe there are a lot of documents have introduced how can you utilize Flutter for your cross-platform UI development. But there are a lot of areas which required to be handled platform specifically, such as client authentication, secure store, offline storage, push, and etc. SAP Cloud Mobile Service has provided native iOS & Android SDK which will address such kind of platform specific issues. It will provide you the functions of enterprise level security, online / offline OData support, connecting to SAP backend systems. This article will share with you how to enhance your Flutter application with those enterprise functions by utilizing SAP Cloud Mobile SDK on both iOS and Android platforms.

You will find this article will help you when you

  • Want to use Flutter language to develop mobile application and connect to SAP backend system
  • Want to achieve OData online and offline functionality for your Flutter application.
  • Want to have enterprise security storage for your Flutter application

Cross-platforms development is always the hot topic. We believe that to fully address all of the problems will take some time. But we like to share with you whenever we get some ideas and also like hear your feedback.


Flutter became a buzz word recently, especially after Google IO this year. It sounds quite promising in term of developing beautiful mobile application, supporting both Android and iOS with one single code line. And the developer stories show us that some big companies begin to develop their applications with Flutter, like BMW, Alibaba, etc.

So, as a mobile development team, what kind of help can we provide if this technology is widely adopted by the community? This will be a question we should prepare and try to answer.

To answer the above question, we look into the features our cloud SDK (Android and iOS) provided, and think OData, especially offline OData, will be our killer features. This blog is not able to answer the question, but we do want to make our hands dirty and do some preparation for the answers.

The code is share here:

Let’s Code

Prepare the environment

  • Download Android SDK 2.2.0-SNAPSHOT, and install it to make sure we can access the modules in the local maven repository;
  • Setup flutter development environment (
  • Install Android Studio, or VS Code as the editor.

Create Flutter Plugin

Run the following command to create the flutter plugin project:

flutter create -t plugin –org -a kotlin –androidx online_odata

The command will create a flutter plugin project ‘online_odata’ with ‘Kotlin’ as the Android development language and AndroidX support.

The reason we create the project with -t as ‘plugin’ is because we can add both Android and iOS code so the flutter/dart can call into. (

Then we can go into online_odata/example folder, then

flutter run

To launch the example application in the simulator currently running. If more than one simulators are running, we need to provide ‘-d’ with the simulator ID to the above command.

Without changing anything, the generated project can run both on Android and iOS, here is the result.


Folder Structure

Before we go on, let’s look at the folder structure of the generated application to see what we need to change for this example.


|__ android      //android Java/Kotlin code

|_ ios               //iOS code

|_ lib                //dart code in here.

|_ example       //an example application on how to use the plugin of ‘ONLINE_ODATA’

Since Android SDK 2.2.0-SNAPSHOT is targeting Android Studio 3.5, I did the following version changes:

ext.kotlin_version = ‘1.3.50’

minSdkVersion 23


We can search the keywords above and replace them with corresponding version.

Add Android SDK Dependencies

Now let’s add Android SDK dependencies into build.gradle. The changes are in ‘online_odata/android/build.gradle’.

  • add mavenLocal() so Android SDK library can be accessed;
  • 2 ‘classpath’ in dependencies so we could generate OData proxy classes
  • 2 ‘implementation’ at the end of the file

Add above into the ‘dependencies’ at the bottom of build.gradle. There is property ‘sapAndroidSDKVersion’, we can define it in the

With the changes above, run ‘flutter run’ again, then we can find the generated proxy classes in ‘online_odata/example/build/online_data/generated/source/odata’

Build the Bridge between Flutter and Java/Kotlin

Now let’s locate ‘OnlineDataPlugin.kt’ in ‘android/src’ folder and add another ‘method call’ support.

The generated version of this file has only ‘getPlatformVersion’ support, now we add another one, ‘getCustomers’, and execute it within an ‘AsyncTask’ to avoid the error saying something like ‘network call in UI thread.’

The AsyncTask basically calls into the online OData library to retrieve the customer list and return the list in a JSON string. To make things simple, we add a ‘BasicAuthenticationHeaderInterceptor’ which hard-coded the authentication header.

Dart Code

Now we need to provide the dart support so code in ‘example’ can access ‘getCustomers’ defined above.

We add a method into ‘online_odata/lib/online_odata.dart’, as below.

Then we can modify the dart code in ‘example’ to show the customers into list view.

Add ‘FloatingActionButton’ inside ‘Scafflod’, when clicking the button, we navigate to ‘Customers’ list page, please see the source of ‘customers_widget.dart’ for details, it will populate the returned JSON data into a list.

The running screen looks like:


Before we did this test, we also spent some time on trying to re-write some of the online libraries in dart, so both Android and iOS can use the same code line. But, to fully support the features SAP Cloud Platform SDK online OData library has currently, it will need a lot of efforts, and when we talk about offline later, there might be only one option left, that is, leveraging the current offline/online OData libraries.

The example above did not touch the security part, we hard coded in the basic authentication header in a class to make the example work. But security is another killer features of cloud SDK, to make the story more interesting, we may also provide support on security part with the same approach as in the example.

Currently, the areas we touched are:

  • Providing ‘flow’ framework with dart;
  • Prototype an ‘ObjectCell’ widget to see how to provide fiori style widget in flutter
  • Security store plugin to leverage library in Android SDK;
  • Basic and OAuth flow in dart
  • Firebase messaging support prototype.

Besides helping us better understand the features within our Android SDK, it may also bring more discussions about the possibilities in mobile development in the team.

You must be Logged on to comment or reply to a post.
    • Hi, I am working with Flutter to build an application for the SAP Innovator Challenge, would I follow the same process above to test this on a MAC with iOS?

      Thank You

      Larry Duncan

      • Hi, 'the same process', if you mean the way to develop iOS mobile app with Flutter, I guess it would be 'Yes'. This prototype was one year old, Flutter has more new stuffs by now, but I think we can still use the 'same process' for mobile development.

        But 'the same process', you mean for creating a plugin as the bridge for flutter and native code, please note that our prototype is only a tryout, there were many things left out in this blog, for example, how to transfer different data types with the bridge.



    • Hi,

      Thanks for the comment.

      The source code is shared in SAP GitHub, it should be accessible for colleagues (the link works for me), and we're now trying to make it pubic. Will update you when that's done.

      As for the question on how much effort for CRUD, I think the effort will be spent on exposing SAP online OData APIs in Dart. Here is the document of OData Component document of SAP cloud platform SDK for Android, which is the underlaying support for this prototype, many functionalities defined in OData Spec are supported.

      SAP UI5 also has a very solid support for OData, if you're talking about the 'web' ability of Flutter, I'm afraid I cannot comment on that. For Dart, actually we can try to implement OData APIs in Dart so both iOS and Android can use the same code line, but to fully cover the features defined in OData Spec, it will take a lot of efforts to reach what currently SAP OData component provides, that's the reason the prototype goes with Flutter channel support and call into Native OData lib both in Android and iOS. And if we add 'offline OData' support into the picture, from the mobile SDK perspective, this might be the only feasible way to go. (Offline support prototype also added into the source code).



  • Hi!


    Thanks for the interesting blogpost.

    Could you help me? I have a problem, when I run this

    flutter create -t plugin –org -a kotlin –androidx online_odata


    The error is the following:

    Multiple output directories specified.
    Try moving -a to be immediately following create


    I'm using Windows 10 x64. I tried to run under Android Studio 3.5.1 and Windows PowerShell


    Thank you,


    • Thanks for comments. The command line should be:

      flutter create -t plugin --org -a kotlin --androidx online_odata


      You can run 'flutter help create' to see the document.



    • Hi, sorry for the late response.

      We're in the process of making the source code public, but please be aware that it may take some time...

      Before that happens, one way I can think of which might be worth trying. Basically, the ideas of this blog are:

      • create a plugin with flutter command line;
      • add dependencies of SAP Cloud Platform SDK for Android into the Gradle files;
      • access Online/Offline OData APIs of the SDK, and make the result be accessible to flutter side;

      so, if you can follow the steps above and share your git repository with me, then we can talk more easily. What do you think?


        • Hi Dominik,

          This blog was more than one year old now, and it was a POC when we did that. Since both Flutter and Google Android SDK have many new stuffs, and SAP Cloud Platform SDK for Android is now about 3.x with many new features, making this public might be off the table now. Getting official Flutter support would be a big topic. I will report to my manager on this.



      • /
        • Hi there, Nice to hear from you.

          From the picture, it seems OData Android Gradle plugin was not found. The fix could be that

          • run 'install' from the SAP Platform SDK for Android folder, it will install that plugin into your maven local; for example, in my maven local repository, I can see that as '.m2/repository/com/sap/cloud/android/odata-android-gradle-plugin/2.2.0-SNAPSHOT'
          • In build.gradle, make sure 'mavenLocal' in your repository setting

          Then it could work.


          • /
          • Hi,

            Seems the previous error was fixed, now it reports another one. Please see if you have the following defined in your build.gradle:

            odata {
            verbose true
            services {
            // connection id:
            schemaFile file(“src/main/res/raw/com_sap_edm_sampleservice_v2.xml”)
            packageName “”
            serviceClass “ESPMContainer”
            We will need to get the metadata xml file, and put it into ‘res/raw’, so the odata gradle plugin should find it and generate proxy classes.
            And if you run 'install.bat' from the SDK, open Android Studio to create a sample application with the wizard provided, then the build.gradle file in the application will be a good reference.
          • /
          • Hi

            With error like this I'm afraid I cannot guess what's going wrong. If the previous one was fixed, the generated classes can be found in 'build/generated' folder. Maybe we can remove some dependencies from your project to make it simple?

            Could you please provide more information, like when this error happened?