diff --git a/packages/flutter/lib/src/widgets/autocomplete.dart b/packages/flutter/lib/src/widgets/autocomplete.dart index 0261a96e2d..77b7f48f87 100644 --- a/packages/flutter/lib/src/widgets/autocomplete.dart +++ b/packages/flutter/lib/src/widgets/autocomplete.dart @@ -12,27 +12,27 @@ import 'focus_manager.dart'; import 'framework.dart'; import 'overlay.dart'; -/// The type of the [AutocompleteCore] callback which computes the list of +/// The type of the [RawAutocomplete] callback which computes the list of /// optional completions for the widget's field based on the text the user has /// entered so far. /// /// See also: -/// * [AutocompleteCore.optionsBuilder], which is of this type. +/// * [RawAutocomplete.optionsBuilder], which is of this type. typedef AutocompleteOptionsBuilder = Iterable Function(TextEditingValue textEditingValue); -/// The type of the callback used by the [AutocompleteCore] widget to indicate +/// The type of the callback used by the [RawAutocomplete] widget to indicate /// that the user has selected an option. /// /// See also: -/// * [AutocompleteCore.onSelected], which is of this type. +/// * [RawAutocomplete.onSelected], which is of this type. typedef AutocompleteOnSelected = void Function(T option); -/// The type of the [AutocompleteCore] callback which returns a [Widget] that +/// The type of the [RawAutocomplete] callback which returns a [Widget] that /// displays the specified [options] and calls [onSelected] if the user /// selects an option. /// /// See also: -/// * [AutocompleteCore.optionsViewBuilder], which is of this type. +/// * [RawAutocomplete.optionsViewBuilder], which is of this type. typedef AutocompleteOptionsViewBuilder = Widget Function( BuildContext context, AutocompleteOnSelected onSelected, @@ -43,7 +43,7 @@ typedef AutocompleteOptionsViewBuilder = Widget Function( /// contains the input [TextField] or [TextFormField]. /// /// See also: -/// * [AutocompleteCore.fieldViewBuilder], which is of this type. +/// * [RawAutocomplete.fieldViewBuilder], which is of this type. typedef AutocompleteFieldViewBuilder = Widget Function( BuildContext context, TextEditingController textEditingController, @@ -51,11 +51,11 @@ typedef AutocompleteFieldViewBuilder = Widget Function( VoidCallback onFieldSubmitted, ); -/// The type of the [AutocompleteCore] callback that converts an option value to +/// The type of the [RawAutocomplete] callback that converts an option value to /// a string which can be displayed in the widget's options menu. /// /// See also: -/// * [AutocompleteCore.displayStringForOption], which is of this type. +/// * [RawAutocomplete.displayStringForOption], which is of this type. typedef AutocompleteOptionToString = String Function(T option); // TODO(justinmc): Mention Autocomplete and AutocompleteCupertino when they are @@ -90,7 +90,7 @@ typedef AutocompleteOptionToString = String Function(T option) /// /// @override /// Widget build(BuildContext context) { -/// return AutocompleteCore( +/// return RawAutocomplete( /// optionsBuilder: (TextEditingValue textEditingValue) { /// return _options.where((String option) { /// return option.contains(textEditingValue.text.toLowerCase()); @@ -194,7 +194,7 @@ typedef AutocompleteOptionToString = String Function(T option) /// /// @override /// Widget build(BuildContext context) { -/// return AutocompleteCore( +/// return RawAutocomplete( /// optionsBuilder: (TextEditingValue textEditingValue) { /// return _userOptions.where((User option) { /// // Search based on User.toString, which includes both name and @@ -245,7 +245,7 @@ typedef AutocompleteOptionToString = String Function(T option) /// {@end-tool} /// /// {@tool dartpad --template=freeform} -/// This example shows the use of AutocompleteCore in a form. +/// This example shows the use of RawAutocomplete in a form. /// /// ```dart imports /// import 'package:flutter/widgets.dart'; @@ -321,7 +321,7 @@ typedef AutocompleteOptionToString = String Function(T option) /// return null; /// }, /// ), -/// AutocompleteCore( +/// RawAutocomplete( /// optionsBuilder: (TextEditingValue textEditingValue) { /// return _options.where((String option) { /// return option.contains(textEditingValue.text.toLowerCase()); @@ -336,7 +336,7 @@ typedef AutocompleteOptionToString = String Function(T option) /// return TextFormField( /// controller: textEditingController, /// decoration: InputDecoration( -/// hintText: 'This is an AutocompleteCore!', +/// hintText: 'This is an RawAutocomplete!', /// ), /// focusNode: focusNode, /// onFieldSubmitted: (String value) { @@ -393,7 +393,7 @@ typedef AutocompleteOptionToString = String Function(T option) /// children: [ /// Text('DropdownButtonFormField: "$_dropdownValue"'), /// Text('TextFormField: "${_textEditingController.text}"'), -/// Text('AutocompleteCore: "$_autocompleteSelection"'), +/// Text('RawAutocomplete: "$_autocompleteSelection"'), /// ], /// ), /// ), @@ -420,11 +420,11 @@ typedef AutocompleteOptionToString = String Function(T option) /// } /// ``` /// {@end-tool} -class AutocompleteCore extends StatefulWidget { - /// Create an instance of AutocompleteCore. +class RawAutocomplete extends StatefulWidget { + /// Create an instance of RawAutocomplete. /// /// [fieldViewBuilder] and [optionsViewBuilder] must not be null. - const AutocompleteCore({ + const RawAutocomplete({ Key? key, required this.fieldViewBuilder, required this.optionsViewBuilder, @@ -440,14 +440,14 @@ class AutocompleteCore extends StatefulWidget { /// Builds the field whose input is used to get the options. /// /// Pass the provided [TextEditingController] to the field built here so that - /// AutocompleteCore can listen for changes. + /// RawAutocomplete can listen for changes. final AutocompleteFieldViewBuilder fieldViewBuilder; /// Builds the selectable options widgets from a list of options objects. /// /// The options are displayed floating below the field using a /// [CompositedTransformFollower] inside of an [Overlay], not at the same - /// place in the widget tree as AutocompleteCore. + /// place in the widget tree as RawAutocomplete. final AutocompleteOptionsViewBuilder optionsViewBuilder; /// Returns the string to display in the field when the option is selected. @@ -475,10 +475,10 @@ class AutocompleteCore extends StatefulWidget { } @override - _AutocompleteCoreState createState() => _AutocompleteCoreState(); + _RawAutocompleteState createState() => _RawAutocompleteState(); } -class _AutocompleteCoreState extends State> { +class _RawAutocompleteState extends State> { final GlobalKey _fieldKey = GlobalKey(); final LayerLink _optionsLayerLink = LayerLink(); final TextEditingController _textEditingController = TextEditingController(); @@ -566,7 +566,7 @@ class _AutocompleteCoreState extends State } @override - void didUpdateWidget(AutocompleteCore oldWidget) { + void didUpdateWidget(RawAutocomplete oldWidget) { super.didUpdateWidget(oldWidget); SchedulerBinding.instance!.addPostFrameCallback((Duration _) { _updateOverlay(); diff --git a/packages/flutter/test/widgets/autocomplete_test.dart b/packages/flutter/test/widgets/autocomplete_test.dart index 90dcbdf0e4..8d7d44b217 100644 --- a/packages/flutter/test/widgets/autocomplete_test.dart +++ b/packages/flutter/test/widgets/autocomplete_test.dart @@ -45,7 +45,7 @@ void main() { User(name: 'Charlie', email: 'charlie123@gmail.com'), ]; - group('AutocompleteCore', () { + group('RawAutocomplete', () { testWidgets('can filter and select a list of string options', (WidgetTester tester) async { final GlobalKey fieldKey = GlobalKey(); final GlobalKey optionsKey = GlobalKey(); @@ -57,7 +57,7 @@ void main() { await tester.pumpWidget( MaterialApp( home: Scaffold( - body: AutocompleteCore( + body: RawAutocomplete( optionsBuilder: (TextEditingValue textEditingValue) { return kOptions.where((String option) { return option.contains(textEditingValue.text.toLowerCase()); @@ -142,7 +142,7 @@ void main() { await tester.pumpWidget( MaterialApp( home: Scaffold( - body: AutocompleteCore( + body: RawAutocomplete( optionsBuilder: (TextEditingValue textEditingValue) { return kOptionsUsers.where((User option) { return option.toString().contains(textEditingValue.text.toLowerCase()); @@ -221,7 +221,7 @@ void main() { await tester.pumpWidget( MaterialApp( home: Scaffold( - body: AutocompleteCore( + body: RawAutocomplete( optionsBuilder: (TextEditingValue textEditingValue) { return kOptionsUsers.where((User option) { return option @@ -302,7 +302,7 @@ void main() { await tester.pumpWidget( MaterialApp( home: Scaffold( - body: AutocompleteCore( + body: RawAutocomplete( optionsBuilder: (TextEditingValue textEditingValue) { return kOptions.where((String option) { return option.contains(textEditingValue.text.toLowerCase()); @@ -365,7 +365,7 @@ void main() { setState = setter; return Align( alignment: alignment, - child: AutocompleteCore( + child: RawAutocomplete( optionsBuilder: (TextEditingValue textEditingValue) { return kOptions.where((String option) { return option.contains(textEditingValue.text.toLowerCase()); @@ -433,7 +433,7 @@ void main() { await tester.pumpWidget( MaterialApp( home: Scaffold( - body: AutocompleteCore( + body: RawAutocomplete( optionsBuilder: (TextEditingValue textEditingValue) { if (textEditingValue.text == null || textEditingValue.text == '') { return const Iterable.empty();