From be7226f08ec9028d50d438444d7e33b1d78ce5c7 Mon Sep 17 00:00:00 2001 From: jslavitz Date: Tue, 30 Oct 2018 13:54:19 -0700 Subject: [PATCH] Adds sample code to TextFormField (#23680) * Adds sample code to TextFormField --- .../lib/src/material/text_form_field.dart | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/packages/flutter/lib/src/material/text_form_field.dart b/packages/flutter/lib/src/material/text_form_field.dart index 3380712204..dd3c51f5f1 100644 --- a/packages/flutter/lib/src/material/text_form_field.dart +++ b/packages/flutter/lib/src/material/text_form_field.dart @@ -38,6 +38,27 @@ import 'theme.dart'; /// integration. /// * [InputDecorator], which shows the labels and other visual elements that /// surround the actual text editing widget. +/// +/// ## Sample code +/// +/// Creates a [TextFormField] with an [InputDecoration] and validator function. +/// +/// ```dart +/// TextFormField( +/// decoration: const InputDecoration( +/// icon: Icon(Icons.person), +/// hintText: 'What do people call you?', +/// labelText: 'Name *', +/// ), +/// onSaved: (String value) { +/// // This optional block of code can be used to run +/// // code when the user saves the form. +/// }, +/// validator: (String value) { +/// return value.contains('@') ? 'Do not use the @ char.' : null; +/// }, +/// ) +/// ``` class TextFormField extends FormField { /// Creates a [FormField] that contains a [TextField]. ///