onInitialize method

  1. @override
void onInitialize(
  1. Smartphone configuration
)
override

Callback on initialize.

Is to be overridden in sub-classes. Note, however, that it must not be doing a lot of work on startup.

Implementation

@override
void onInitialize(Smartphone configuration) {
  // listen to the battery
  battery.onBatteryStateChanged
      .listen((state) async => _batteryLevel = await battery.batteryLevel);

  // find the supported data types
  for (var package in SamplingPackageRegistry().packages) {
    if (package is SmartphoneSamplingPackage) {
      _supportedDataTypes.addAll(package.dataTypes.map((type) => type.type));
    }
  }
}