Repository navigation
Description
Use case
Flutter already exposes the text-class password variations through TextInputType.visiblePassword (added in #36695, closing #31738), which maps to Android's TYPE_TEXT_VARIATION_VISIBLE_PASSWORD.
The numeric-class counterpart — TYPE_NUMBER_VARIATION_PASSWORD — has no representation in TextInputType. TextInputType.numberWithOptions currently exposes only signed and decimal, so there is no way for a Flutter field to declare itself as a numeric-password input to the platform / IME. The engine's Android TextInputPlugin NUMBER branch never sets TYPE_NUMBER_VARIATION_PASSWORD, and — correctly — obscureText is not used to derive it, because visual obscuring is a Flutter rendering concern independent of the platform input classification.
Concretely, a native Android field declared as
inputType = TYPE_CLASS_NUMBER | TYPE_NUMBER_VARIATION_PASSWORD // 2 | 16 = 18is also the canonical form documented by the platform as android:inputType="numberPassword" — i.e. Android itself treats this combination as a first-class, named input type. It cannot be produced from Flutter public API today.
Real-world numeric password fields in native apps (banking PIN entry, OTP screens) are routinely built with inputType == 18; a Flutter port has to settle for inputType == 2 and give up any platform-level cues tied to the numeric-password classification (IME candidate policy, contextual suggestions, form-manager heuristics, per-IME learning behavior).
Why not use existing knobs
obscureText: true— wrong tool. It masks the glyphs Flutter renders; consumers that draw their own cells (custom PIN widgets) need the raw text visible while still declaring the field as numeric-password to the platform.TextInputType.visiblePassword— text class, not numeric; brings up a full alphanumeric keyboard.AutofillHints/enableIMEPersonalizedLearning— orthogonal signals (autofill hints andimeOptionsrespectively); they don't setinputType.- A pub.dev package — not viable: the
inputTypemapping lives in the engine'sTextInputPluginand is not pluggable from Dart.
Proposal
Add a password parameter to TextInputType.numberWithOptions, symmetric to the visiblePassword precedent:
const TextInputType.numberWithOptions({
this.signed = false,
this.decimal = false,
this.password = false, // NEW
});Default false — construction of existing TextInputType.number and TextInputType.numberWithOptions(...) is byte-for-byte unchanged. toJson, operator ==, hashCode, and toString are updated to include the new field.
Serialization — additive JSON field; older engines that don't parse it fall back to today's behavior:
{
"name": "TextInputType.number",
"signed": false,
"decimal": false,
"password": true
}Platform mapping
-
Android (
TextInputPlugin.inputTypeFromTextInputType, NUMBER branch):int textType = InputType.TYPE_CLASS_NUMBER; if (type.isSigned) textType |= InputType.TYPE_NUMBER_FLAG_SIGNED; if (type.isDecimal) textType |= InputType.TYPE_NUMBER_FLAG_DECIMAL; if (type.isPassword) textType |= InputType.TYPE_NUMBER_VARIATION_PASSWORD;
obscureTextremains orthogonal — it neither implies nor is implied byTYPE_NUMBER_VARIATION_PASSWORD. This preserves behavior for every existingkeyboardType: number+obscureText: truefield. -
iOS — iOS traits are independent, not a bit field.
password: trueis a no-op forUIKeyboardType(stays.numberPad) and does not setisSecureTextEntry.obscureTextcontinues to drive masking;AutofillHints.oneTimeCodecontinues to drive.oneTimeCode. -
Web —
inputmode="numeric"unchanged; HTMLtype="password"continues to be driven byobscureText. -
Windows / macOS / Linux — no-op in v1, documented.
Backward compatibility
- Additive; default
false; no behavior change for existing callers. - JSON is additive.
- No change to
obscureText,AutofillHints, orenableIMEPersonalizedLearningsemantics.
Docs will state explicitly: password: true declares the platform input classification only. It does not obscure Flutter-rendered glyphs — use obscureText for that. It is currently a no-op on iOS / web / desktop.
Tests
- Framework: default value,
toJson,==,hashCode,toString, unchanged signed/decimal behavior. - Android engine
inputTypematrix: number→2, number+password→18, number+signed→4098, number+decimal→8194, JSON withoutpassword→2. - Orthogonality:
obscureTextalone doesn't set the variation;enableIMEPersonalizedLearning: falsestill only touchesimeOptions;AutofillHints.oneTimeCodestill only touches autofill hints.
Landing order — per Tree Hygiene, engine JSON parsing + Android mapping first, framework field once the engine revision is available; happy to split PRs that way.
Filing this issue before sending a PR to align on API shape. Precedent: #36695 / #31738.
References:
Activity
AlexV525 commentedon Jul 29, 2026
Proposed implementation checklist
isPasswordtoTextInputChannel.InputType, parsejson.optBoolean("password", false), and OR inTYPE_NUMBER_VARIATION_PASSWORDinTextInputPlugin's NUMBER branch; unit-test theinputTypematrix (number→2, +password→18, +signed→4098, +decimal→8194, JSON withoutpassword→2) and orthogonality vsobscureText/imeOptions/ autofill hints. iOS / Web / desktop: no code change; assert in tests that iOS keeps.numberPadand does not setisSecureTextEntry, Web keepsinputmode="numeric", desktop is documented no-op. [Android] Add numeric-password variation to TextInputType (embedding) #190207packages/flutter/lib/src/services/text_input.dart: addpasswordparam (defaultfalse) toTextInputType.numberWithOptions; updatetoJson,operator ==,hashCode,toString, and dartdoc (explicitly: platform input classification only, does not obscure rendered glyphs, no-op on iOS / web / desktop); tests cover default value,toJson,==,hashCode,toString, unchanged signed/decimal behavior. Add numeric-password variation to TextInputType.numberWithOptions #190637Renzo-Olivares commentedon Jul 30, 2026
Hi @AlexV525 I assigned this to you since it looks like you are already working on it. Feel free to unassign if this is not the case. Overall this looks like a reasonable add to the framework since it is not currently possible to achieve the desired secure functionality of the IME without the correct
TextInputTypeconfiguration.[Android] Add numeric-password variation to TextInputType (embedding) (…
Add numeric-password variation to TextInputType.numberWithOptions (fl…
[Android] Remove old `InputType` constructor from embedding (flutter#…
Renzo-Olivares commentedon Aug 27, 2026
Hi @AlexV525, can we declare victory on this now that the engine/framework prs have been merged?
AlexV525 commentedon Aug 28, 2026
Yes! I've just checked this by producing new APKs and verified on devices. All of the work is valid. So the goal is complete. 🥇
github-actions commentedon Sep 12, 2026
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.