[Huawei Developers] Mayism:
Recently, it is found that some services of AppGallery Connect start to support cross-platform frameworks, including Flutter. Let's have a try on Remote Configuration.

Integration Procedure

1. Install the Flutter environment.

a) Download the Flutter SDK package from https://flutter.dev/docs/get-started/install/windows.

Decompress the package to any directory, for example, D:\Flutter.

b) Add Flutter to environment variables. Here, the path is D:\Flutter\flutter_windows_1.22.2-stable\flutter\bin.

c) In Android Studio, go to File > Settings > Plugins, download the Flutter and Dart plug-ins, and restart Android Studio for the plug-ins to take effect.

2. Create a project and enable Remote Configuration.

a) Create an Android project in AppGallery Connect and enable Remote Configuration.

b) Add the following configuration items to Remote Configuration.

c) In Android Studio, go to File > New > New Flutter Project… and create a Flutter project.

d) Go to Project settings > General information in AppGallery Connect. In the App information area, download the agconnect-services.json file.

e) Place the agconnect-services.json file in the directory shown in the following figure.

f) Configure the Maven repository and Remote Configuration plug-in in the app-level build.gradle file.

g) Open the build.gradle file in the android/app directory of the Flutter project and add the build dependencies and AppGallery Connect plug-in address.

3. Integrate the Remote Configuration SDK.

Add the SDK dependency of Remote Configuration to the pubspec.yaml file.

Click Pub get to synchronize the data.

4. Test basic functions.

Here I implement a simple demo app to demonstrate several of the most important functions.

In the UI design, the Mode 1:Fetch And Activate Immediately, Mode 2:Fetch And Activate Next Time, and Clear Data buttons are provided to implement the following functions:

1. Obtain data from the cloud. This operation takes effect this time.

Tap Mode 1:Fetch And Activate Immediately to call fetch and then applyLastFetched to obtain the data fetched this time. The operation will take effect immediately. Therefore, we call the getMergedAll API to apply all the settings to the device. Then, we can obtain the data from the cloud on the device. The following figure shows the tap effect.

2. Obtain the cloud data and make the setting obtained last time take effect.

The API for delaying the setting to take effect shares the same implementation logic as that for making the setting take effect immediately, and they differ in the execution sequence.

Tap Mode 2:Fetch And Activate Next Time to call apply and getMergedAll to apply the last fetch result, and then call fetch to obtain the latest setting for next use.

3. Clear the data.

To clear data, tap Clear Data to call the clearAll API.

4. Set local configuration items.

You can create a Map parameter in the*.dart file and call the applyDefault API to apply the local settings.

Map defaults = {
'mLong': 1000,
'mString': 'hello world',
'mDouble': 3.14,
'mBoolean': true
};
AGCRemotConfig.instance.applyDefaults(defaults);

5. Package your app.

Similar to Android, you only need to run your project in Android Studio.

Precautions

Different from setting local configuration items on the Android platform, Flutter cannot use XML files to store local configuration items.

For more details, check:

Flutter official guide: https://flutter.dev/docs/get-started/install/windows

To view more about how to integrate Remote Configuration into an Android project, visit https://developer.huawei.com/consum...-connect-Guides/agc-remoteconfig-introduction.

Demo of Remote Configuration(Flutter):https://developer.huawei.com/consum...oteconfig-flutter-samplecode-0000001056579535