MessageAnalyzer class
Analyzes user messages to infer metadata before they are sent to the AI.
Used by Prompt to resolve ResponseLanguage.auto and ResponseTone smart defaults — it reads the message and picks the right values so developers don't have to.
All methods are static, pure, and free — no API calls, no side effects.
MessageAnalyzer.detectLanguage('مرحبا كيف حالك'); // arabic
MessageAnalyzer.detectLanguage('Hello, how are you?'); // english
MessageAnalyzer.detectLanguage('Hi مرحبا'); // bilingual
MessageAnalyzer.isQuestion('what is Flutter?'); // true
MessageAnalyzer.isQuestion('ما هو فلاتر؟'); // true
MessageAnalyzer.detectTone('hi'); // casual
MessageAnalyzer.detectTone('Can you explain...'); // friendly
MessageAnalyzer.detectTone('Analyze this full document and provide...'); // formal
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
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
Static Methods
-
detectLanguage(
String message) → ResponseLanguage -
Detects the dominant script in
messageand returns the matching ResponseLanguage. -
detectTone(
String message) → ResponseTone - Infers a likely ResponseTone from message length.
-
isQuestion(
String message) → bool -
Returns
trueifmessageappears to be a question.