Skip to content

Instantly share code, notes, and snippets.

@pxpc2
Created May 30, 2022 04:11
Show Gist options
  • Save pxpc2/18b61b432040858d8a635730af3334de to your computer and use it in GitHub Desktop.
Save pxpc2/18b61b432040858d8a635730af3334de to your computer and use it in GitHub Desktop.
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