tokenCount abstract method
Token count for text from the model's own tokenizer, or null when it
cannot be obtained (no engine, native call failed). Callers must handle
null rather than assume a number — this feeds context budgeting, and the
four-chars-per-token estimate it replaced undercounts Chinese by more than
half (measured 0.44x on gemma-4-E2B-it) while looking authoritative.
Implementation
Future<int?> tokenCount(String text);