Skip to main content

Flutter MeData Service

Functions

saveMeDataRecord

Future<void> saveMeDataRecord(String name, Object? values)

Saves a new MeData record for the given definition name with the provided values.

Parameters:

  • name: String — MeData definition name (for example "daily_steps").
  • values: Object? — JSON‑serializable value or list of values to be stored for the definition.

syncMeDataDefinitions

Future<void> syncMeDataDefinitions()

Synchronizes MeData definitions with the Orchestrator and updates local storage in the Data Vault.

Parameters: None.

getMeDataDefinitions

Future<List<MeDataDefinition>> getMeDataDefinitions()

Returns all MeData definitions currently available in local storage.

Parameters: None.

getMeDataDefinition

Future<MeDataDefinition?> getMeDataDefinition(String name)

Returns a single MeData definition by its name, or null if it is not found.

Parameters:

  • name: String — Unique MeData definition name (for example "daily_steps").

getMeDataCategories

Future<List<MeDataCategory>?> getMeDataCategories()

Returns the list of MeData categories used for grouping and UI organization, or null if no categories are available.

Parameters: None.

getMeDataDefinitionsByCategory

Future<List<MeDataDefinition>?> getMeDataDefinitionsByCategory(String name)

Retrieves MeData definitions that belong to the specified category name, or null if none exist.

Parameters:

  • name: String — Category name.

getMeDataRecords

Future<List<MeDataRecord>?> getMeDataRecords(String name)

Returns all stored records for the given MeData definition name, or null if no records exist.

Parameters:

  • name: String — MeData definition name whose records should be fetched.

getLastMeDataRecord

Future<MeDataRecord?> getLastMeDataRecord(String name)

Returns the most recent MeData record for the given definition name, or null if there is no record.

Parameters:

  • name: String — MeData definition name whose latest record should be returned.

collectMeData

Future<Map<String, dynamic>> collectMeData(
List<String> meDataDefinitionNames
)

Triggers MeData collectors for the given definition names and returns a map from definition name to collected data.

Parameters:

  • meDataDefinitionNames: List — List of MeData definition names to collect.

getAggregatedMeDataRecords

Future<Object?> getAggregatedMeDataRecords({
required String name,
required DateTime start,
required DateTime end,
required Aggregation aggregation,
int? intervalSeconds,
Aggregation? intervalAggregation,
})

Returns aggregated MeData records for the given definition and time range, optionally grouped by an interval.

Parameters:

  • name: String — MeData definition name to aggregate.
  • start: DateTime — Start of the aggregation window.
  • end: DateTime — End of the aggregation window.
  • aggregation: Aggregation — Aggregation function to apply (for example Aggregation.avg).
  • intervalSeconds: int? — Optional interval in seconds to split the aggregation into buckets.
  • intervalAggregation: Aggregation? — Optional aggregation to apply within each interval bucket.

Classes

DataType

enum DataType {
string,
number,
boolean,
datetime,
image,
video,
object,
unknown,
}

MeDataType

enum MeDataType {
native,
qaBased,
apiBased,
scripted,
inferred,
unknown,
}

Aggregation

enum Aggregation {
avg,
sum,
min,
max,
count,
}

EnumeratedValue

class EnumeratedValue {
final String? id;
final String name;
final String text;
final String? description;
final String? imageUrl;
}

EnumeratedValueConstraints

class EnumeratedValueConstraints {
final bool? allowNone;
final bool? allowIdk;
final bool? allowNa;
final bool? allowOther;
}

ValueTypeConstraints

class ValueTypeConstraints {
final num? minValue;
final num? maxValue;
final String? regex;
final bool? allowCamera;
final bool? allowGallery;
}

MultiValueConstraints

class MultiValueConstraints {
final int minValue;
final int maxValue;
}

ValueDefinition

class ValueDefinition {
final DataType type;
final ValueTypeConstraints? constraints;
final bool? multivalued;
final MultiValueConstraints? multiValueConstraints;
final bool? enumerated;
final List<EnumeratedValue>? enumeratedValues;
final EnumeratedValueConstraints? enumeratedValueConstraints;
}

MeDataCategory

class MeDataCategory {
final String id;
final String text;
final String name;
final String? iconUrl;
final String? description;
}

MeDataStorageSettings

class MeDataStorageSettings {
final bool? onlyIfChanged;
final int? longLimit;
}

Question

class Question {
final String? id;
final String name;
final String text;
final String? description;
final String? imageUrl;
}

QuestionDefinition

class QuestionDefinition {
final ValueDefinition valueDef;
final Question question;
final bool isMeData;
final String contextKey;
}

MeDataDefinition

class MeDataDefinition {
final String id;
final String name;
final String text;
final String source;
final Map<String, dynamic>? script;
final ValueDefinition? valueDef;
final MeDataCategory? category;
final String? iconUrl;
final String? description;
final bool? sharable;
final bool? hidden;
final MeDataStorageSettings? storageSettings;
final Question? question;
}

MeDataValue

class MeDataValue {
final String id;
final String? evName;
final String value;
}

MeDataRecord

class MeDataRecord {
final String id;
final String meDataDefinitionId;
final bool notAvailable;
final num date;
final List<MeDataValue> values;
}