In Flutter, I have used dateTimePicker in my code for date of birth filed , i am able to select the date but after selecting it shows that particular date only for some time, after that it is back to the current date , how do i make it to show the date i selected. here is my code,
`Card( color: Colors.blue[50], margin: EdgeInsets.only(left: 20, top: 5, right: 20), shape: RoundedRectangleBorder( side: BorderSide(color: Colors.black54, width: 1), ), child: Container( margin: EdgeInsets.only( left: 30, top: 5, right: 30, bottom: 10), child: DateTimePicker( validator: (val) => val == null ? "Please pick date of birth" : null, cursorColor: Color(0xFF75101D), type: DateTimePickerType.date, dateMask: 'dd MMMM yyyy', initialValue: dob, lastDate: DateTime(2100), icon: Icon(Icons.event), dateLabelText: 'Date of Birth', onChanged: (val) { var localDate = DateTime.parse(val);
var formatter = new DateFormat('dd-MM-yyyy');
var formatted = formatter.format(localDate);
print(formatted);
setState(() {
dob = formatted;
print(dob);
});
},
firstDate: DateTime(1950),
),
),
),`