mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Fix autofill eligibility check (#95210)
This commit is contained in:
parent
5b6de035ce
commit
f268f82035
@ -2191,7 +2191,7 @@ class EditableTextState extends State<EditableText> with AutomaticKeepAliveClien
|
||||
bool get _hasInputConnection => _textInputConnection?.attached ?? false;
|
||||
/// Whether to send the autofill information to the autofill service. True by
|
||||
/// default.
|
||||
bool get _needsAutofill => widget.autofillHints?.isNotEmpty ?? true;
|
||||
bool get _needsAutofill => _effectiveAutofillClient.textInputConfiguration.autofillConfiguration.enabled;
|
||||
|
||||
void _openInputConnection() {
|
||||
if (!_shouldCreateInputConnection) {
|
||||
|
||||
@ -6585,6 +6585,7 @@ void main() {
|
||||
'TextInput.setStyle',
|
||||
'TextInput.setEditingState',
|
||||
'TextInput.show',
|
||||
'TextInput.requestAutofill',
|
||||
'TextInput.setEditingState',
|
||||
'TextInput.show',
|
||||
'TextInput.setCaretRect',
|
||||
@ -6648,6 +6649,7 @@ void main() {
|
||||
'TextInput.setStyle',
|
||||
'TextInput.setEditingState',
|
||||
'TextInput.show',
|
||||
'TextInput.requestAutofill',
|
||||
'TextInput.setCaretRect',
|
||||
];
|
||||
expect(
|
||||
@ -6690,6 +6692,7 @@ void main() {
|
||||
'TextInput.setStyle',
|
||||
'TextInput.setEditingState',
|
||||
'TextInput.show',
|
||||
'TextInput.requestAutofill',
|
||||
'TextInput.setEditingState',
|
||||
'TextInput.show',
|
||||
'TextInput.setCaretRect',
|
||||
@ -6740,6 +6743,7 @@ void main() {
|
||||
'TextInput.setStyle',
|
||||
'TextInput.setEditingState',
|
||||
'TextInput.show',
|
||||
'TextInput.requestAutofill',
|
||||
'TextInput.setEditingState',
|
||||
'TextInput.show',
|
||||
'TextInput.setCaretRect',
|
||||
@ -8974,6 +8978,53 @@ void main() {
|
||||
await tester.pump();
|
||||
expect(scrollController.offset.roundToDouble(), 0.0);
|
||||
});
|
||||
|
||||
testWidgets('Autofill enabled by default', (WidgetTester tester) async {
|
||||
final FocusNode focusNode = FocusNode();
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: EditableText(
|
||||
autofocus: true,
|
||||
controller: TextEditingController(text: 'A'),
|
||||
focusNode: focusNode,
|
||||
style: textStyle,
|
||||
cursorColor: Colors.blue,
|
||||
backgroundCursorColor: Colors.grey,
|
||||
cursorOpacityAnimates: true,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
assert(focusNode.hasFocus);
|
||||
expect(
|
||||
tester.testTextInput.log,
|
||||
contains(matchesMethodCall('TextInput.requestAutofill')),
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('Autofill can be disabled', (WidgetTester tester) async {
|
||||
final FocusNode focusNode = FocusNode();
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: EditableText(
|
||||
autofocus: true,
|
||||
controller: TextEditingController(text: 'A'),
|
||||
focusNode: focusNode,
|
||||
style: textStyle,
|
||||
cursorColor: Colors.blue,
|
||||
backgroundCursorColor: Colors.grey,
|
||||
cursorOpacityAnimates: true,
|
||||
autofillHints: null,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
assert(focusNode.hasFocus);
|
||||
expect(
|
||||
tester.testTextInput.log,
|
||||
isNot(contains(matchesMethodCall('TextInput.requestAutofill'))),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
class UnsettableController extends TextEditingController {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user