initHumanFaceHelper method

  1. @override
Future<bool> initHumanFaceHelper()
override

Initializes the human face helper.

This method communicates with the native Android platform to initialize the human face detection helper. It returns a boolean indicating whether the initialization was successful.

Returns:

  • true if the human face helper is initialized successfully.
  • false if an error occurs during initialization.

Note: Debug logs will be printed if kDebugMode is enabled.

Implementation

@override
Future<bool> initHumanFaceHelper() async {
  try {
    // Invoke the native method to initialize the human face helper
    await methodChannel.invokeMethod('initHumanFaceHelper');

    // Log success in debug mode
    if (kDebugMode) {
      print('Human face helper initialized successfully.');
    }

    return true; // Initialization successful
  } on PlatformException catch (e) {
    // Handle platform-specific exceptions and log error details
    if (kDebugMode) {
      print('Error initializing Human Face Helper: ${e.code} - ${e.message}');
      if (e.details != null) {
        print('Details: ${e.details}');
      }
    }

    return false; // Initialization failed
  } catch (e) {
    // Catch any other unexpected exceptions
    if (kDebugMode) {
      print('Unexpected error: ${e.toString()}');
    }

    return false; // Initialization failed
  }
}