onInitialize method

  1. @override
void onInitialize(
  1. HealthService service
)
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
// ignore: avoid_renaming_method_parameters
void onInitialize(HealthService service) {
  if (Platform.isAndroid) {
    var sdkLevel = int.parse(DeviceInfo().sdk ?? '-1');
    if (sdkLevel < 34) {
      warning(
          '$runtimeType - Trying to use Google Health Connect on a phone with SDK level < 34 (SDK is $sdkLevel). '
          'In order to use Health Connect on this phone, you need to install Health Connect as a separate app. '
          'Please read more about Health Connect at https://developer.android.com/health-and-fitness/guides/health-connect/develop/get-started');
    }
  }
}