LanguageDetectorExecutor class
Executes MediaPipe's "detect language" task.
Instantiates and manages an object which can complete MediaPipe tasks. The managed task-completing object does not exist in Dart memory, but instead in platform-dependent native memory.
Extending classes should implement createResultsPointer, createWorker, closeWorker, and any additional task-specific methods. Applications will only call those extra task-specific methods, which will throw an exception on any error communicating with the native workers. It is the job of application code to surround those task-specific methods with try-catch clauses.
Executors are separated from their public API counterparts because FFI and MediaPipe have no concept of asynchrony or futures, so this pattern allows a public-facing task handler to create an executor on a separate isolate, and for Flutter apps to await the results of MediaPipe tasks.
Constructors
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- options → LanguageDetectorOptions
-
Initialization values for the
worker
.finalinherited - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- taskName → String
-
Debug value for log statements.
final
-
worker
→ Pointer<
Void> -
The native MediaPipe object which will complete this task.
no setterinherited
Methods
-
closeWorker(
Pointer< Void> worker, Pointer<Pointer< error) → intChar> > -
Releases the
worker
object behind this task. -
createResultsPointer(
) → Pointer< LanguageDetectorResult> - Allocates this task's results struct in native memory.
-
createWorker(
Pointer< LanguageDetectorOptions> options, Pointer<Pointer< error) → Pointer<Char> >Void> - Allocates this task's worker object in native memory.
-
detect(
String text) → LanguageDetectorResult -
Passes
text
to MediaPipe for classification, yielding a LanguageDetectorResult or throwing an exception. -
dispose(
) → void -
Releases the
worker
and any remaining resources. After callingdispose
, re-using theworker
property will recreate the native object and will require a second call todispose
.inherited -
handleErrorMessage(
Pointer< Pointer< errorMessage, [int? status]) → voidChar> > -
Throws an exception if
errorMessage
is non-empty.inherited -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited