Support for disabling TextField, TextFormField (#16027)

This commit is contained in:
Hans Muller
2018-03-29 07:28:22 -07:00
committed by GitHub
parent 895707324d
commit 8e97807671
6 changed files with 78 additions and 20 deletions

View File

@@ -138,8 +138,10 @@ class _DateAndTimePickerDemoState extends State<DateAndTimePickerDemo> {
padding: const EdgeInsets.all(16.0),
children: <Widget>[
new TextField(
enabled: true,
decoration: const InputDecoration(
labelText: 'Event name',
border: const OutlineInputBorder(),
),
style: Theme.of(context).textTheme.display1,
),

View File

@@ -249,17 +249,21 @@ class TextFormFieldDemoState extends State<TextFormFieldDemo> {
fieldKey: _passwordFieldKey,
helperText: 'No more than 8 characters.',
labelText: 'Password *',
onSaved: (String value) { person.password = value; },
onFieldSubmitted: (String value) {
setState(() {
person.password = value;
});
},
),
const SizedBox(height: 24.0),
new TextFormField(
enabled: person.password != null && person.password.isNotEmpty,
decoration: const InputDecoration(
border: const UnderlineInputBorder(),
filled: true,
labelText: 'Re-type password',
),
maxLength: 8,
onFieldSubmitted: (String value) { person.password = value; },
obscureText: true,
validator: _validatePassword,
),