Take Textformfield value in double

Asked

Viewed 1,013 times

1

How can I get the value of a Textformfield in double? I’ve created a Texteditingcontroller,

var controller = new TextEditingController();

but the controller.text comes in string and I can’t get it to double.

  • Double question https://answall.com/questions/422164/convers%C3%a3o-de-values-flutter/422171#422171

1 answer

2


to receive :

controller.text = valor.toStringAsFixed(2); //para retornar com duas casas; 
controller.text = valor.toStringAsFixed(2).replaceAll('.', ','); //se quiser converter o ponto em virgula, padrao pt-br

to convert into double:

valor = double.tryParse(controller.text) + 0.00;// para nao pegar o valor em tipo dynamic

Browser other questions tagged

You are not signed in. Login or sign up in order to post.