Skip to content

m8ty_client_features

m8ty_client_features solves this by retrieving server-configured feature flags, so apps can render capabilities according to the customer’s configured experience.

Features client to retrieve features configured on the server. Features are names of available features on the client which can be activated or deactivated on the server. Based on the configuration widgets should be rendered in the client or not. See therefore m8ty_feature_flags

Check the documentation of the m8ty_client_features library to get an idea about the available models and their properties.

import 'package:dio/dio.dart';
import 'package:m8ty_client_features/m8ty_client_features.dart';
import 'package:m8ty_client_common/m8ty_client_common.dart';
import 'package:built_collection/built_collection.dart';
final featuresClient = M8tyClientFeatures();
featuresClient.setApiKey(m8tyApiKeyAuth, "myApiKey");
Method Description
getFeatures Load backend feature flags to toggle functionality in the app

Here some examples how the dart client can be used

Retrieve all configured features from server

Section titled “Retrieve all configured features from server”
final featuresClient = M8tyClientFeatures();
featuresClient.setApiKey(m8tyApiKeyAuth, "myApiKey");
final FeaturesApi featuresApi = featuresClient.getFeaturesApi();
final metadata = MetadataModel((final b) => b
..deviceId = "mydevice"
..userAgent = "Mozilla"
..buildNumber = "256"
..version = "1.2.1"
..userId = "myuser"
..packageName = "com.crealogix.mobilex.qa",
);
final featuresRequestModel = FeaturesRequestModel((final b) => b
..name = "production"
..clientFeatures = MapBuilder({"featureA": true, "fatureB": false})
..metadata = metadata.toBuilder());
try {
final Response<BuiltMap<String, bool>> featureFlags = await featuresApi.getFeatures(
featuresRequestModel: featuresRequestModel,
);
print('Features: ${featureFlags.data}');
} on DioException catch (e) {
throw Exception(
'Request failed (status: ${e.response?.statusCode}): ${e.response?.data}',
);
}