onRegister method

  1. @override
void onRegister()
override

Callback method when this package is being registered.

Implementation

@override
void onRegister() {
  // first register all configurations to be de/serializable
  FromJsonFactory().registerAll([
    AirQualityService(apiKey: ''),
    GeofenceSamplingConfiguration(
        name: '',
        center: GeoPosition(1.1, 1.1),
        dwell: const Duration(),
        radius: 1.0),
    LocationService(),
    WeatherService(apiKey: ''),
    AirQualityService(apiKey: ''),
    GeoPosition(1.1, 1.1)
  ]);

  // register all data types
  FromJsonFactory().registerAll([
    Activity(type: ActivityType.UNKNOWN, confidence: 0),
    AirQuality(airQualityIndex: 0, latitude: 0, longitude: 0),
    Geofence(type: GeofenceType.DWELL, name: ''),
    Location(),
    Mobility(),
    Weather()
  ]);

  // registering the transformers from CARP to OMH for geolocation and physical activity
  // we assume that there is an OMH schema registered already...
  DataTransformerSchemaRegistry().lookup(NameSpace.OMH)!
    ..add(LOCATION, OMHGeopositionDataPoint.transformer)
    ..add(ACTIVITY, OMHPhysicalActivityDataPoint.transformer);

  // register the sub-packages
  SamplingPackageRegistry()
    ..register(LocationSamplingPackage())
    ..register(AirQualitySamplingPackage())
    ..register(WeatherSamplingPackage());
}