Skip to content
This repository was archived by the owner on May 20, 2023. It is now read-only.

Commit b9f986e

Browse files
Googlernshahan
authored andcommitted
Add attribute to set aria-label when a visible label is not desired.
PiperOrigin-RevId: 186504320
1 parent e200fb0 commit b9f986e

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

lib/material_input/base_material_input.dart

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,11 @@ class BaseMaterialInput extends FocusableMixin
8484
@Input()
8585
String label;
8686

87+
/// The label to be used for screen readers. Use [label] instead of this
88+
/// when a visible label is desired.
89+
@Input()
90+
String inputAriaLabel;
91+
8792
/// The hint text to be shown on the input. Not shown during an error.
8893
String _hintText;
8994
String get hintText => _hintText;
@@ -322,7 +327,7 @@ class BaseMaterialInput extends FocusableMixin
322327

323328
bool get labelVisible => floatingLabelVisible || !hasVisibleText;
324329

325-
String get ariaLabel => label;
330+
String get ariaLabel => inputAriaLabel ?? label;
326331

327332
String get errorMessage {
328333
if (_error?.isNotEmpty ?? false) return _error;

0 commit comments

Comments
 (0)