Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
70aa0457
Unverified
Commit
70aa0457
authored
Mar 17, 2021
by
Justin McCandless
Committed by
GitHub
Mar 17, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Autocomplete dartpad examples fix (#77863)
Fixes the dartpad examples on the docs site.
parent
637fb5b9
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
294 additions
and
206 deletions
+294
-206
autocomplete.dart
packages/flutter/lib/src/material/autocomplete.dart
+44
-8
autocomplete.dart
packages/flutter/lib/src/widgets/autocomplete.dart
+250
-198
No files found.
packages/flutter/lib/src/material/autocomplete.dart
View file @
70aa0457
...
@@ -14,15 +14,33 @@ import 'text_form_field.dart';
...
@@ -14,15 +14,33 @@ import 'text_form_field.dart';
/// This example shows how to create a very basic Autocomplete widget using the
/// This example shows how to create a very basic Autocomplete widget using the
/// default UI.
/// default UI.
///
///
/// ```dart
imports
/// ```dart
main
/// import 'package:flutter/material.dart';
/// import 'package:flutter/material.dart';
/// ```
///
///
/// ```dart
/// void main() => runApp(const AutocompleteExampleApp());
///
/// class AutocompleteExampleApp extends StatelessWidget {
/// const AutocompleteExampleApp({Key? key}) : super(key: key);
///
/// @override
/// Widget build(BuildContext context) {
/// return MaterialApp(
/// home: Scaffold(
/// appBar: AppBar(
/// title: const Text('Autocomplete Basic'),
/// ),
/// body: const Center(
/// child: AutocompleteBasicExample(),
/// ),
/// ),
/// );
/// }
/// }
///
/// class AutocompleteBasicExample extends StatelessWidget {
/// class AutocompleteBasicExample extends StatelessWidget {
/// AutocompleteBasicExample({Key? key}) : super(key: key);
///
const
AutocompleteBasicExample({Key? key}) : super(key: key);
///
///
///
final
List<String> _kOptions = <String>[
///
static const
List<String> _kOptions = <String>[
/// 'aardvark',
/// 'aardvark',
/// 'bobcat',
/// 'bobcat',
/// 'chameleon',
/// 'chameleon',
...
@@ -52,11 +70,29 @@ import 'text_form_field.dart';
...
@@ -52,11 +70,29 @@ import 'text_form_field.dart';
/// This example shows how to create an Autocomplete widget with a custom type.
/// This example shows how to create an Autocomplete widget with a custom type.
/// Try searching with text from the name or email field.
/// Try searching with text from the name or email field.
///
///
/// ```dart
imports
/// ```dart
main
/// import 'package:flutter/material.dart';
/// import 'package:flutter/material.dart';
/// ```
///
///
/// ```dart
/// void main() => runApp(const AutocompleteExampleApp());
///
/// class AutocompleteExampleApp extends StatelessWidget {
/// const AutocompleteExampleApp({Key? key}) : super(key: key);
///
/// @override
/// Widget build(BuildContext context) {
/// return MaterialApp(
/// home: Scaffold(
/// appBar: AppBar(
/// title: const Text('Autocomplete Basic User'),
/// ),
/// body: const Center(
/// child: AutocompleteBasicUserExample(),
/// ),
/// ),
/// );
/// }
/// }
///
/// @immutable
/// @immutable
/// class User {
/// class User {
/// const User({
/// const User({
...
...
packages/flutter/lib/src/widgets/autocomplete.dart
View file @
70aa0457
...
@@ -78,12 +78,30 @@ typedef AutocompleteOptionToString<T extends Object> = String Function(T option)
...
@@ -78,12 +78,30 @@ typedef AutocompleteOptionToString<T extends Object> = String Function(T option)
/// This example shows how to create a very basic autocomplete widget using the
/// This example shows how to create a very basic autocomplete widget using the
/// [fieldViewBuilder] and [optionsViewBuilder] parameters.
/// [fieldViewBuilder] and [optionsViewBuilder] parameters.
///
///
/// ```dart imports
/// ```dart main
/// import 'package:flutter/widgets.dart';
/// import 'package:flutter/material.dart';
/// import 'package:flutter/material.dart';
/// ```
/// import 'package:flutter/widgets.dart';
///
/// void main() => runApp(const AutocompleteExampleApp());
///
/// class AutocompleteExampleApp extends StatelessWidget {
/// const AutocompleteExampleApp({Key? key}) : super(key: key);
///
/// @override
/// Widget build(BuildContext context) {
/// return MaterialApp(
/// home: Scaffold(
/// appBar: AppBar(
/// title: const Text('RawAutocomplete Basic'),
/// ),
/// body: const Center(
/// child: AutocompleteBasicExample(),
/// ),
/// ),
/// );
/// }
/// }
///
///
/// ```dart
/// class AutocompleteBasicExample extends StatelessWidget {
/// class AutocompleteBasicExample extends StatelessWidget {
/// const AutocompleteBasicExample({Key? key}) : super(key: key);
/// const AutocompleteBasicExample({Key? key}) : super(key: key);
///
///
...
@@ -152,12 +170,30 @@ typedef AutocompleteOptionToString<T extends Object> = String Function(T option)
...
@@ -152,12 +170,30 @@ typedef AutocompleteOptionToString<T extends Object> = String Function(T option)
/// This example is similar to the previous example, but it uses a custom T data
/// This example is similar to the previous example, but it uses a custom T data
/// type instead of directly using String.
/// type instead of directly using String.
///
///
/// ```dart imports
/// ```dart main
/// import 'package:flutter/widgets.dart';
/// import 'package:flutter/material.dart';
/// import 'package:flutter/material.dart';
/// ```
/// import 'package:flutter/widgets.dart';
///
/// void main() => runApp(const AutocompleteExampleApp());
///
/// class AutocompleteExampleApp extends StatelessWidget {
/// const AutocompleteExampleApp({Key? key}) : super(key: key);
///
/// @override
/// Widget build(BuildContext context) {
/// return MaterialApp(
/// home: Scaffold(
/// appBar: AppBar(
/// title: const Text('RawAutocomplete Custom Type'),
/// ),
/// body: const Center(
/// child: AutocompleteCustomTypeExample(),
/// ),
/// ),
/// );
/// }
/// }
///
///
/// ```dart
/// // An example of a type that someone might want to autocomplete a list of.
/// // An example of a type that someone might want to autocomplete a list of.
/// @immutable
/// @immutable
/// class User {
/// class User {
...
@@ -254,26 +290,44 @@ typedef AutocompleteOptionToString<T extends Object> = String Function(T option)
...
@@ -254,26 +290,44 @@ typedef AutocompleteOptionToString<T extends Object> = String Function(T option)
/// {@tool dartpad --template=freeform}
/// {@tool dartpad --template=freeform}
/// This example shows the use of RawAutocomplete in a form.
/// This example shows the use of RawAutocomplete in a form.
///
///
/// ```dart imports
/// ```dart main
/// import 'package:flutter/widgets.dart';
/// import 'package:flutter/material.dart';
/// import 'package:flutter/material.dart';
/// ```
/// import 'package:flutter/widgets.dart';
///
/// void main() => runApp(const AutocompleteExampleApp());
///
/// class AutocompleteExampleApp extends StatelessWidget {
/// const AutocompleteExampleApp({Key? key}) : super(key: key);
///
/// @override
/// Widget build(BuildContext context) {
/// return MaterialApp(
/// home: Scaffold(
/// appBar: AppBar(
/// title: const Text('RawAutocomplete Form'),
/// ),
/// body: const Center(
/// child: AutocompleteFormExample(),
/// ),
/// ),
/// );
/// }
/// }
///
///
/// ```dart
/// class AutocompleteFormExample extends StatefulWidget {
/// class AutocompleteFormExamplePage extends StatefulWidget {
/// const AutocompleteFormExample({Key? key}) : super(key: key);
/// const AutocompleteFormExamplePage({Key? key}) : super(key: key);
///
///
/// @override
/// @override
/// AutocompleteFormExample
createState() => AutocompleteFormExampl
e();
/// AutocompleteFormExample
State createState() => AutocompleteFormExampleStat
e();
/// }
/// }
///
///
/// class AutocompleteFormExample
extends State<AutocompleteFormExamplePag
e> {
/// class AutocompleteFormExample
State extends State<AutocompleteFormExampl
e> {
/// final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
/// final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
/// final TextEditingController _textEditingController = TextEditingController();
/// final TextEditingController _textEditingController = TextEditingController();
/// String? _dropdownValue;
/// String? _dropdownValue;
/// String? _autocompleteSelection;
/// String? _autocompleteSelection;
///
///
///
final
List<String> _options = <String>[
///
static const
List<String> _options = <String>[
/// 'aardvark',
/// 'aardvark',
/// 'bobcat',
/// 'bobcat',
/// 'chameleon',
/// 'chameleon',
...
@@ -281,12 +335,7 @@ typedef AutocompleteOptionToString<T extends Object> = String Function(T option)
...
@@ -281,12 +335,7 @@ typedef AutocompleteOptionToString<T extends Object> = String Function(T option)
///
///
/// @override
/// @override
/// Widget build(BuildContext context) {
/// Widget build(BuildContext context) {
/// return Scaffold(
/// return Form(
/// appBar: AppBar(
/// title: const Text('Autocomplete Form Example'),
/// ),
/// body: Center(
/// child: Form(
/// key: _formKey,
/// key: _formKey,
/// child: Column(
/// child: Column(
/// children: <Widget>[
/// children: <Widget>[
...
@@ -343,7 +392,7 @@ typedef AutocompleteOptionToString<T extends Object> = String Function(T option)
...
@@ -343,7 +392,7 @@ typedef AutocompleteOptionToString<T extends Object> = String Function(T option)
/// return TextFormField(
/// return TextFormField(
/// controller: textEditingController,
/// controller: textEditingController,
/// decoration: const InputDecoration(
/// decoration: const InputDecoration(
///
hintText: 'This is an
RawAutocomplete!',
///
hintText: 'This is a
RawAutocomplete!',
/// ),
/// ),
/// focusNode: focusNode,
/// focusNode: focusNode,
/// onFieldSubmitted: (String value) {
/// onFieldSubmitted: (String value) {
...
@@ -420,8 +469,6 @@ typedef AutocompleteOptionToString<T extends Object> = String Function(T option)
...
@@ -420,8 +469,6 @@ typedef AutocompleteOptionToString<T extends Object> = String Function(T option)
/// ),
/// ),
/// ],
/// ],
/// ),
/// ),
/// ),
/// ),
/// );
/// );
/// }
/// }
/// }
/// }
...
@@ -483,38 +530,44 @@ class RawAutocomplete<T extends Object> extends StatefulWidget {
...
@@ -483,38 +530,44 @@ class RawAutocomplete<T extends Object> extends StatefulWidget {
/// This examples shows how to create an autocomplete widget with the text
/// This examples shows how to create an autocomplete widget with the text
/// field in the AppBar and the results in the main body of the app.
/// field in the AppBar and the results in the main body of the app.
///
///
/// ```dart imports
/// ```dart main
/// import 'package:flutter/widgets.dart';
/// import 'package:flutter/material.dart';
/// import 'package:flutter/material.dart';
/// ```
/// import 'package:flutter/widgets.dart';
///
/// void main() => runApp(const AutocompleteExampleApp());
///
///
/// ```dart
/// class AutocompleteExampleApp extends StatelessWidget {
/// final List<String> _options = <String>[
/// const AutocompleteExampleApp({Key? key}) : super(key: key);
///
/// @override
/// Widget build(BuildContext context) {
/// return const MaterialApp(
/// home: RawAutocompleteSplit(),
/// );
/// }
/// }
///
/// const List<String> _options = <String>[
/// 'aardvark',
/// 'aardvark',
/// 'bobcat',
/// 'bobcat',
/// 'chameleon',
/// 'chameleon',
/// ];
/// ];
///
///
/// class RawAutocompleteSplit
Page
extends StatefulWidget {
/// class RawAutocompleteSplit extends StatefulWidget {
/// const RawAutocompleteSplit
Page
({Key? key}) : super(key: key);
/// const RawAutocompleteSplit({Key? key}) : super(key: key);
///
///
/// @override
/// @override
/// RawAutocompleteSplit
PageState createState() => RawAutocompleteSplitPage
State();
/// RawAutocompleteSplit
State createState() => RawAutocompleteSplit
State();
/// }
/// }
///
///
/// class RawAutocompleteSplit
PageState extends State<RawAutocompleteSplitPage
> {
/// class RawAutocompleteSplit
State extends State<RawAutocompleteSplit
> {
/// final TextEditingController _textEditingController = TextEditingController();
/// final TextEditingController _textEditingController = TextEditingController();
/// final FocusNode _focusNode = FocusNode();
/// final FocusNode _focusNode = FocusNode();
/// final GlobalKey _autocompleteKey = GlobalKey();
/// final GlobalKey _autocompleteKey = GlobalKey();
///
///
/// @override
/// @override
/// Widget build(BuildContext context) {
/// Widget build(BuildContext context) {
/// return MaterialApp(
/// return Scaffold(
/// theme: ThemeData(
/// primarySwatch: Colors.blue,
/// ),
/// title: 'Split RawAutocomplete App',
/// home: Scaffold(
/// appBar: AppBar(
/// appBar: AppBar(
/// // This is where the real field is being built.
/// // This is where the real field is being built.
/// title: TextFormField(
/// title: TextFormField(
...
@@ -556,7 +609,6 @@ class RawAutocomplete<T extends Object> extends StatefulWidget {
...
@@ -556,7 +609,6 @@ class RawAutocomplete<T extends Object> extends StatefulWidget {
/// },
/// },
/// ),
/// ),
/// ),
/// ),
/// ),
/// );
/// );
/// }
/// }
/// }
/// }
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment