SamplingSchema class Null safety

Specify how sampling should be done. Used to make default configuration of Measures.

A new SamplingSchema can be created for specific purposes. For example, the following schema is made for outdoor activity tracking.

SamplingSchema activitySchema = SamplingSchema(name: 'Outdoor Activity Sampling Schema', powerAware: true)
      PeriodicMeasure(MeasureType(NameSpace.CARP, DataType.PEDOMETER), enabled: true, frequency: 60 * 60 * 1000)),
    MapEntry(DataType.SCREEN, Measure(MeasureType(NameSpace.CARP, DataType.SCREEN), enabled: true)),
    MapEntry(DataType.LOCATION, Measure(MeasureType(NameSpace.CARP, DataType.LOCATION), enabled: true)),
      PeriodicMeasure(MeasureType(NameSpace.CARP, DataType.NOISE),
        enabled: true, frequency: 60 * 1000, duration: 2 * 1000)),
    MapEntry(DataType.ACTIVITY, Measure(MeasureType(NameSpace.CARP, DataType.ACTIVITY), enabled: true)),
      WeatherMeasure(MeasureType(NameSpace.CARP, DataType.WEATHER), enabled: true, frequency: 2 * 60 * 60 * 1000))

There is also a set of factory methods than provide different default sampling schemas, including:

  • common - a default, most common configuration of all known measures
  • maximum - using the common default configuration of all probes, but enabling all measures
  • light - a light configuration, enabling low-frequent sampling but with good coverage
  • minimum - a minimum set of measures, with a minimum sampling rate
  • none - no sampling at all (used to pause all sampling)

See the documentation for further details.



SamplingSchema({required SamplingSchemaType type, String? name, bool powerAware = false})
SamplingSchema.normal({bool powerAware = false})
A sampling schema that does not adapt any Measures. [...]


description String?
A description of this SamplingSchema.
read / write
hashCode int
The hash code for this object. [...]
read-only, inherited
measures Map<String, Measure>
A map of default Measures for different measure types for this sampling schema.
name String?
A printer-friendly name of this SamplingSchema.
read / write
powerAware bool
Is this sampling schema power-aware, i.e. adapting its sampling strategy to the battery power status. See PowerAwarenessState.
read / write
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited
type SamplingSchemaType
The sampling schema type according to SamplingSchemaType.
read / write


adapt(MasterDeviceDeployment deployment, {bool restore = true}) → void
Adapts all Measures in a MasterDeviceDeployment to this SamplingSchema. [...]
addMeasure(Measure measure) → void
Add a default measure to this schema.
addMeasures(List<Measure> measures) → void
Add a list of default measures to this schema.
addSamplingSchema(SamplingSchema schema) → void
Adds all measures from schema to this sampling schema. [...]
getMeasureList({required List<String> types}) List<Measure>
Returns a list of Measures from this SamplingSchema for a list of Strings as specified in types. [...]
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
removeMeasure(Measure measure) → void
Remove a measure from this schema.
toString() String
A string representation of this object. [...]


operator ==(Object other) bool
The equality operator. [...]