-
Notifications
You must be signed in to change notification settings - Fork 241
Description
Description
The MLCustomInteractiveLivenessDetectionSetting object, which is used for custom liveness detection, accepts a TextOptions parameter. Within the TextOptions class, the textColor property is defined with the type Color.
When a Dart Color object (e.g., Colors.red) is assigned to this property and passed to the startCustomizedView method, the application throws a serialization exception. This occurs because the Flutter MethodChannel cannot encode the complex Color object into a primitive type that the native Android/iOS platform can understand. The native platform expects an integer (ARGB) representation for the color, not a Dart-specific object.
Expected behavior
I expected to be able to pass a standard Dart Color object to the textColor property. The startCustomizedView method should then execute without errors, launching the native UI where the text elements are rendered in the specified color.
Current behavior
The application crashes when startCustomizedView is called, throwing a Converting object to an encodable object failed: Instance of 'Color' exception. The custom liveness detection view fails to launch.
Screenshots
Not applicable, as this is a runtime exception, not a visual bug.
Logs
[ERROR:flutter/lib/ui/ui_dart_state.cc(198)] Unhandled Exception: Converting object to an encodable object failed: Instance of 'Color'
Other
This appears to be a design flaw in the plugin's public API. The Dart-side API should accept types that are directly serializable by the MethodChannel.
Proposed Solution:
- In the file
lib/src/model/text_options.dart, change the type of thetextColorfield fromColor?toint?. - Update the documentation for the
textColorfield to clarify that it expects the 32-bit integer value of a color, which can be obtained from aColorobject via the.valueproperty (e.g.,Colors.red.value). - Update the example application (
example/lib/screens/interactive_liveness_example.dart) to useColors.red.valueinstead ofColors.redto demonstrate the correct usage and prevent confusion.