-2
I need to take a figure that comes from a field like text
. However, this field only receives numbers.
Text field:
Container(
child: CupertinoTextField(
textCapitalization: TextCapitalization.none,
placeholder: 'Digite um numero',
decoration: BoxDecoration(
border: Border.all(
width: 1.0,
color: Colors.deepOrangeAccent,
),
borderRadius: BorderRadius.circular(25.0),
),
maxLines: null,
keyboardType: TextInputType.number,
controller: controllerTextnum,
),
padding: EdgeInsets.fromLTRB(17.0, 30.0, 25.0, 1.0),
),
Knob:
Container(
child: CupertinoButton(
color: Colors.deepOrangeAccent,
child: Text("Mostrar número digitado",
style: TextStyle(
fontSize: 20.0, color: Colors.white,
)),
onPressed: (){
alertNum(context);
},
),
padding: EdgeInsets.fromLTRB(17.0, 30.0, 25.0, 1.0),
),
Alert that shows what was typed in the field.
void alertNum (BuildContext context){
var alert = CupertinoAlertDialog(
title: Text("O NúMERO Digitado foi:"),
content: Text(controllerTextnum.text),
actions: <Widget>[
CupertinoDialogAction(
child: Text("Fechar"),
onPressed: (){
Navigator.of(context).pop();
},
),
],
);
showDialog(context: context,
builder: (BuildContext context){
return alert;
}
);
}
I’d like to take that amount that comes from CupertinoTextField
and for example multiply by 2.
He had done a function that "played" him in a Dynamic variable, however, it did not work.
This is something very simple, Voce has the methods of conversation, int.parse(string) and double.parse(string) and all this is in doc, if you put in google flutter convertrto to int or to double, will appear various post. You have to do more research before you ask.
– Chance