Flutter MeData Service
This documentation is for Flutter SDK 2.1.x
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.
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.
getAggregatedMeDataRecord
Future<AggregatedMeDataRecord> getAggregatedMeDataRecord({
required String name,
required DateTime start,
required DateTime end,
required Aggregation aggregation,
AggregationInterval? aggregationInterval,
})
Aggregates the numeric MeData records in the given date range into a single record. When aggregationInterval is provided, values are first reduced per interval window using the interval's own aggregation, and aggregation is then applied over the interval results. A record is always returned; its value is null when the range holds no numeric data.
Parameters:
name: String— MeData definition name. The definition must be ofNUMBERdata type.start: DateTime— Start of the range. Sent as an absolute instant (epoch milliseconds), so building it in local time is correct on any device timezone.end: DateTime— End of the range.aggregation: Aggregation— Aggregation applied over the range.aggregationInterval: AggregationInterval?— Optional windowing;secondsmust be greater than 0.
getAggregatedMeDataRecordIntervals
Future<List<AggregatedMeDataRecord>> getAggregatedMeDataRecordIntervals({
required String name,
required DateTime start,
required DateTime end,
required AggregationInterval aggregationInterval,
})
Splits the given date range into windows of aggregationInterval.seconds and returns one aggregated record per window. Every window in the range is present in the result, in ascending order; windows that hold no numeric record carry a null value.
Parameters:
name: String— MeData definition name. The definition must be ofNUMBERdata type.start: DateTime— Start of the range. Sent as an absolute instant (epoch milliseconds), so building it in local time is correct on any device timezone.end: DateTime— End of the range.aggregationInterval: AggregationInterval— Window length and the aggregation applied inside each window;secondsmust be greater than 0.
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,
}
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;
}
AggregatedMeDataRecord
class AggregatedMeDataRecord {
final double startDate; // epoch milliseconds
final double endDate; // epoch milliseconds
final double? value; // null = no data in the range/window, not a measured 0
}
AggregationInterval
class AggregationInterval {
final int seconds; // window length, must be greater than 0
final Aggregation aggregation; // applied inside each window
}