onInitialize method

  1. @override
bool onInitialize()
override

Callback when this executor is initialized. Returns true if successfully initialized, false otherwise.

Note that this is a non-async method and should hence be 'light-weight' and not block execution for a long duration.

Implementation

@override
bool onInitialize() {
  super.onInitialize();
  if (beaconRegions.isEmpty) {
    warning(
        '$runtimeType - No beacon regions specified for monitoring. Will not start monitoring.');
    return false;
  }

  try {
    info('$runtimeType - Initializing iBeacon scanning...');
    flutterBeacon.initializeScanning.then((_) {
      info('$runtimeType - Initialized.');
      return true;
    }, onError: (Object error) {
      warning('$runtimeType - Error while initializing scanner - $error');
      return false;
    });
  } catch (error) {
    warning('$runtimeType - Error while initializing scanner - $error');
    return false;
  }
  return true;
}