-
Notifications
You must be signed in to change notification settings - Fork 30.1k
Description
CupertinoTextField does not call onChanged when its clear button is tapped. This is a problem because my app needs to know when the user has cleared the search field so it can display unconstrained suggestions (including paid ads).
Here's a minimal reproduction. Tap the '(x)' button to clear the text box. Note that no message is printed. I tested debug builds on iOS Simulator and Android Emulator.
import 'package:flutter/cupertino.dart'
show CupertinoApp, CupertinoPageScaffold;
import 'package:flutter/widgets.dart' show Center, runApp;
import 'package:flutter/cupertino.dart'
show CupertinoTextField, OverlayVisibilityMode, TextEditingController;
void main() {
runApp(
CupertinoApp(
home: CupertinoPageScaffold(
child: Center(
child: CupertinoTextField(
controller: new TextEditingController(text: 'initial text'),
clearButtonMode: OverlayVisibilityMode.always,
onChanged: (String contents) {
print('onChanged $contents');
},
),
),
),
),
);
}
$ flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, v1.2.1, on Mac OS X 10.14.3 18D109, locale en-US)
[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
[!] iOS toolchain - develop for iOS devices (Xcode 10.1)
[✓] Android Studio (version 3.3)
[!] IntelliJ IDEA Community Edition (version 2018.3.5)
✗ Flutter plugin not installed; this adds Flutter specific functionality.
✗ Dart plugin not installed; this adds Dart specific functionality.
[✓] Connected device (2 available)
! Doctor found issues in 2 categories.