title: How to convert date string into DateTime format in flutter
body: <p>I'm having a string in this format 03/11/2021, how can I convert it into DateTime format. I using showDate Picker to get DOB and the problem I'm facing is with the initialDate that if _dob.text.isNotEmpty then I want the showDatePicker to show the _dob date but it's not working</p>
  <pre><code> TextEditingController _dob = TextEditingController();
    @override
    void initState() {
      _dob.text = &quot;&quot;; //set the initial value of text field
      super.initState();
    }
  
  TextFormField(
  controller: _dob,
  readOnly: true,
  onTap: () async {
  DateTime? pickedDate = await showDatePicker(
  context: context,
  initialDate: _dob.text.isNotEmpty? DateTime.parse(_dob.text):DateTime.now(),
  firstDate: DateTime(1975),
  lastDate: DateTime.now()
  );
  if (pickedDate != null) {
  String formattedDate =
  DateFormat('dd/MM/yyyy').format(pickedDate);
  setState(() {
  _dob.text = formattedDate;
   });
  }
  },
  ),
  </code></pre>