Created
January 28, 2022 15:22
-
-
Save saliouseck2009/29e62c2128d513f11039297065cca4b9 to your computer and use it in GitHub Desktop.
Flutter TextField
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
TextEditingController controller = TextEditingController(); | |
TextField( | |
keyboardType: TextInputType.number, | |
textCapitalization: TextCapitalization.sentences, | |
textAlign: TextAlign.center, | |
style: TextStyle(color: Colors.red, fontWeight: FontWeight.w300), | |
cursorColor: Colors.red, | |
cursorRadius: Radius.circular(16.0), | |
cursorWidth: 16.0, | |
maxLength: 4, | |
obscureText: true, | |
decoration: InputDecoration( | |
icon: Icon(Icons.print) | |
border: OutlineInputBorder() | |
), | |
textInputAction: TextInputAction.continueAction, | |
onChanged: (text) { | |
value = text; | |
}, | |
controller: controller, | |
onEditingComplete: () {}, | |
onSubmitted: (value) {}, | |
autofocus: true, | |
) | |
#Working with custom focus changes | |
# Initialise outside the build method | |
FocusNode nodeOne = FocusNode(); | |
FocusNode nodeTwo = FocusNode(); | |
// Do this inside the build method | |
TextField( | |
focusNode: nodeOne, | |
decoration: InputDecoration( | |
hintText: "Demo Text", | |
hintStyle: TextStyle(fontWeight: FontWeight.w300, color: Colors.red) | |
), | |
TextField( | |
focusNode: nodeTwo, | |
), | |
RaisedButton( | |
onPressed: () { | |
FocusScope.of(context).requestFocus(nodeTwo); | |
}, | |
child: Text("Next Field"), | |
), |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment