aye aye good people, I'm really confused about the behavior of DateTime.parse();

on dartpad this works

void main() {
      const String _iso8601 = '2019-04-01T08:30:00';
      final DateTime _date = DateTime.parse(_iso8601);
        print(_date.toIso8601String());
}

but in flutter doesn't, but this does

      const String _iso8601 = '2019-04-01T08:30:00.000';
      final DateTime _date = DateTime.parse(_iso8601);

I'm now in aqueduct and neither of those works including this

String _iso8601 = '2019-04-01T08:30:00Z';

please note that with "didn't work" I don't mean that it returns an error, but just a null.

[edit: correction

when I mock the string instead of mapping it from the body of a request it returns

Exception has occurred. FormatException (null)

but then again I'm using Iso8601]

If you have some experience with this situation I could use some help.

[edit: note that aqueduct runs on dart 2.0]

Thank you in advance, Francesco


Solution 1: user3907398

Examples of accepted strings:

"2012-02-27 13:27:00"
"2012-02-27 13:27:00.123456z"
"2012-02-27 13:27:00,123456z"
"20120227 13:27:00"
"20120227T132700"
"20120227"
"+20120227"
"2012-02-27T14Z"
"2012-02-27T14+00:00"
"-123450101 00:00:00 Z": in the year -12345.
"2002-02-27T14:00:00-0500": Same as "2002-02-27T19:00:00Z"