I think the issue is when _endingMilesController.text might be null or contain unexpected values. A robust solution is to use double.tryParse() to safely convert the text to a double. If double.tryParse() returns null (meaning the conversion failed), assign a default value, such as null or 999999.
Try :