0
validator: (value) {
                                if (value.isEmpty) {
                                  _casing.depth = 0;
                                } else if (double.tryParse(value) != null) {
                                  // setState(() {
                                  _casing.depth = double.tryParse(value);
                                  // });
                                } else {
                                  _casing.depth = 0;
                                  return kTextFieldError;
                                }
                                return null;
                              },

This returns an error that says unable to setState while currently doing so. What I need is as the user inputs (or finishes either by clicking ok or tapping anywhere which automatically hides keyboard), I want to use the input value to calculate numbers in the parent widget

Khaled Mahmoud
  • 302
  • 1
  • 7
  • 16

1 Answers1

0

you can use the onChanged property of TextFormField

onChanged:(value){
 if (value.isEmpty) {
_casing.depth = 0;
} else if (double.tryParse(value) != null) {
 // setState(() {
 _casing.depth = double.tryParse(value);
 // });
 } else {
  _casing.depth = 0;
   return kTextFieldError;
 }
}
Huthaifa Muayyad
  • 11,321
  • 3
  • 17
  • 49