Created
May 30, 2022 04:11
-
-
Save pxpc2/18b61b432040858d8a635730af3334de 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 CampoTexto extends StatefulWidget { | |
const CampoTexto({Key? key}) : super(key: key); | |
@override | |
State<CampoTexto> createState() => _CampoTextoState(); | |
} | |
class _CampoTextoState extends State<CampoTexto> { | |
TextEditingController _textEditingController = TextEditingController(); | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
appBar: AppBar( | |
title: Text("I/O"), | |
backgroundColor: Colors.deepPurple, | |
), | |
backgroundColor: Colors.white, | |
body: Column( | |
children: [ | |
Padding( | |
padding: EdgeInsets.all(32), | |
child: TextField( | |
keyboardType: TextInputType.number, | |
decoration: InputDecoration( | |
labelText: "Digite um valor" | |
), | |
maxLength: 4, | |
style: TextStyle(color: Colors.purple, fontSize: 30), | |
controller: _textEditingController, | |
), | |
), | |
ElevatedButton(onPressed: () { | |
print("Value: ${_textEditingController.text}"); | |
}, child: Text("Save")) | |
], | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment