![type ‘String’ is not a subtype of type ‘DateTime’ in type cast](https://oflutter.com/wp-content/uploads/2021/02/type-‘String-is-not-a-subtype-of-type-‘DateTime-in-type-cast-1536x900.jpg)
When you are working with date time in Flutter, sometimes you might get an error: type ‘String’ is not a subtype of type ‘DateTime’ in type cast. Usually, it happens when you retrieve a date from the database and pass the data to a DateTime as a string.
Solution: use DateTime.parse()
To solve this error, you have to convert string type to DateTime type using: DateTime.parse(string)
DateTime.parse(string)