Created
January 20, 2020 22:55
-
-
Save cristianfb1989/3b7a3c8345fd6410ab866224ae2e0e09 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
class ExampleLoginFocus extends StatefulWidget { | |
@override | |
_ExampleLoginFocusState createState() => _ExampleLoginFocusState(); | |
} | |
class _ExampleLoginFocusState extends State<ExampleLoginFocus> { | |
bool _obscureText = true; | |
String _password; | |
void _toggle() { | |
setState(() { | |
_obscureText = !_obscureText; | |
}); | |
} | |
@override | |
Widget build(BuildContext context) { | |
return new Scaffold( | |
appBar: new AppBar( | |
title: new Text("Sample"), | |
), | |
body: Listener( | |
onPointerUp: (e) { | |
FocusScope.of(context).requestFocus(FocusNode()); | |
}, | |
child: new Container( | |
child: new Column( | |
children: <Widget>[ | |
new TextField( | |
decoration: const InputDecoration( | |
labelText: 'Password', | |
icon: const Padding( | |
padding: const EdgeInsets.only(top: 15.0), | |
child: const Icon(Icons.lock))), | |
//validator: (val) => val.length < 6 ? 'Password too short.' : null, | |
onChanged: (val) => _password = val, | |
obscureText: _obscureText, | |
), | |
new FlatButton( | |
onPressed: _toggle, | |
child: new Text(_obscureText ? "Show" : "Hide")) | |
], | |
), | |
), | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment