identifyWidget method

Widget identifyWidget({
  1. required dynamic onSafetyDetection(
    1. dynamic
    ),
  2. dynamic onBoundingBox(
    1. dynamic
    )?,
  3. dynamic onDetectionComplete(
    1. dynamic
    )?,
  4. dynamic fps(
    1. dynamic
    )?,
  5. dynamic error(
    1. dynamic
    )?,
  6. dynamic cameraStatus(
    1. dynamic
    )?,
  7. dynamic loading(
    1. dynamic
    )?,
  8. dynamic disposed(
    1. dynamic
    )?,
  9. dynamic filterUpdated(
    1. dynamic
    )?,
  10. dynamic cameraSwitch(
    1. dynamic
    )?,
  11. required Widget customPermissionBuilder(
    1. dynamic
    ),
  12. required Center onLoadingWidget,
  13. Widget? faceMaskOverlay,
  14. required Stack builder(
    1. Widget,
    2. FlutterSafetyPlatformCameraController
    ),
  15. Map<String, dynamic>? filterParams,
  16. String? cameraSelected,
  17. bool? autoFinishDetectionActivity = true,
})

Creates a widget for identifying faces with various customization options.

The identifyWidget method returns a widget that integrates face identification functionality with customizable components.

Parameters:

  • onSafetyDetection: A required callback function that is triggered when a face is identified.
  • customPermissionBuilder: A required builder function that returns a widget for custom permission handling.
  • onLoadingWidget: A required widget that is displayed while the identification process is loading.
  • faceMaskOverlay: A required widget that overlays the face mask on the camera view.
  • builder: A required builder function that returns a stack widget containing the camera view and the controller.

Returns:

  • A widget that integrates face identification with the provided customization options.

Implementation

// Response format received in Flutter:
// {
//   "objects": [
//     {
//       "class_id": int,
//       "count": int,
//       "min": int,
//       "max": int,
//       "min_error": bool,
//       "max_error": bool,
//       "positions": [
//         {
//           "left": float,
//           "top": float,
//           "right": float,
//           "bottom": float
//         }
//       ]
//     }
//   ],
//   "bitmap": String?,    // Path to saved bitmap if successful
//   "timeout": boolean?   // Present only if timeout occurred
// }
/// - [customPermissionBuilder]: A required builder function that returns a widget for custom permission handling.
/// - [onLoadingWidget]: A required widget that is displayed while the identification process is loading.
/// - [faceMaskOverlay]: A required widget that overlays the face mask on the camera view.
/// - [builder]: A required builder function that returns a stack widget containing the camera view and the controller.
///
/// Returns:
/// - A widget that integrates face identification with the provided customization options.
Widget identifyWidget({
  required Function(dynamic) onSafetyDetection,
  Function(dynamic)? onBoundingBox,
  Function(dynamic)? onDetectionComplete,
  Function(dynamic)? fps,
  Function(dynamic)? error,
  Function(dynamic)? cameraStatus,
  Function(dynamic)? loading,
  Function(dynamic)? disposed,
  Function(dynamic)? filterUpdated,
  Function(dynamic)? cameraSwitch,
  required Widget Function(dynamic) customPermissionBuilder,
  required Center onLoadingWidget,
  Widget? faceMaskOverlay,
  required Stack Function(Widget, FlutterSafetyPlatformCameraController)
      builder,
  Map<String, dynamic>? filterParams,
  String? cameraSelected,
  bool? autoFinishDetectionActivity = true,
}) {
  return platformViewLink(
    onSafetyDetection: onSafetyDetection,
    fps: fps,
    error: error ?? _handleError,
    customPermissionBuilder: customPermissionBuilder,
    onLoadingWidget: onLoadingWidget,
    faceMaskOverlay: faceMaskOverlay,
    onDetectionComplete: onDetectionComplete,
    onBoundingBox: onBoundingBox,
    cameraStatus: cameraStatus,
    loading: loading,
    disposed: disposed,
    filterUpdated: filterUpdated,
    cameraSwitch: cameraSwitch,
    builder: builder,
    viewType: 'safety_identify_view',
    creationParams: {
      'filter': filterParams ?? _defaultFilter,
      'cameraSelected': cameraSelected ?? '0',
      'useNativeBoundingBox': onBoundingBox == null,
      'autoFinishDetectionActivity': autoFinishDetectionActivity,
    },
  );
}