ChatInputProvider class
Manages chat input logic: text entry, image picking, and audio recording gestures.
- Tracks recording state and drag threshold for slide-to-cancel.
- Requests permissions, starts/stops audio recording.
- Emits callbacks for text submission, image selection, and audio recording.
- Inheritance
-
- Object
- ChangeNotifier
- ChatInputProvider
Constructors
-
ChatInputProvider.new({required ValueChanged<
ChatMessage> onRecordComplete, required ValueChanged<ChatMessage> onTextSubmit, required ValueChanged<ChatMessage> onImageSelected, required TextEditingController textController, required double cancelThreshold}) - Constructs a ChatInputProvider.
Properties
- cancelThreshold → double
-
Horizontal drag distance threshold to cancel recording (in pixels).
final
- dragOffset → double
-
Current drag offset along the X axis (negative when dragging left).
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- hasListeners → bool
-
Whether any listeners are currently registered.
no setterinherited
- hasText → bool
-
True if the text input contains non-whitespace characters.
no setter
- isRecording → bool
-
Whether the provider is currently recording audio.
no setter
-
onImageSelected
→ ValueChanged<
ChatMessage> -
Invoked with a ChatMessage when an image is picked, or
null
on cancel.final -
onRecordComplete
→ ValueChanged<
ChatMessage> -
Invoked with a ChatMessage when audio recording completes successfully.
final
-
onTextSubmit
→ ValueChanged<
ChatMessage> -
Invoked with a ChatMessage on text submission.
final
- recordDuration → Duration
-
Elapsed recording duration.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- textController → TextEditingController
-
Controller for the text input field.
final
Methods
-
addListener(
VoidCallback listener) → void -
Register a closure to be called when the object changes.
inherited
-
dispose(
) → void -
Discards any resources used by the object. After this is called, the
object is not in a usable state and should be discarded (calls to
addListener will throw after the object is disposed).
override
-
endRecording(
) → Future< void> - Ends recording on long-press release; completes or cancels accordingly.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
notifyListeners(
) → void -
Call all the registered listeners.
inherited
-
onMove(
Offset offset) → void - Updates drag offset. Cancels recording if threshold is exceeded.
-
pickImage(
ImageSourceType sourceType) → Future< void> -
Picks an image from
sourceType
, then invokes onImageSelected. -
removeListener(
VoidCallback listener) → void -
Remove a previously registered closure from the list of closures that are
notified when the object changes.
inherited
-
sendTextMessage(
) → void - Sends the current text message if non-empty, then clears the input.
-
startRecording(
) → Future< void> - Initiates audio recording on long-press start if no text is present.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited