-
-
Couldn't load subscription status.
- Fork 16
Open
Labels
bugSomething isn't workingSomething isn't working
Description
If you try to search "google"
final List<Book> books = await queryBooks( 'google', maxResults: 3, printType: PrintType.books, orderBy: OrderBy.relevance, reschemeImageLinks: true, );
the second result is a book that has a different publishedDate format, i think ISO (2016-09-15T00:00:00+02:00) and it raises a format exception at books.dart line 241
day = int.parse(publishedDateArray[2]);
I think you can try to parse the date with something like
`DateTime? publishedDate =
DateTime.tryParse((json['publishedDate'] as String?) ?? '0000-00-00');
if (publishedDate == null) {
final publishedDateArray =
((json['publishedDate'] as String?) ?? '0000-00-00').split('-');
// initialize datetime variable
if (publishedDateArray.isNotEmpty) {
// initialize date
int year = int.parse(publishedDateArray[0]);
int month = 1;
int day = 1;
// now test the date string
if (publishedDateArray.length == 1) {
// assume we have only the year
year = int.parse(publishedDateArray[0]);
}
if (publishedDateArray.length == 2) {
// assume we have the year and maybe the month (this could be just a speculative case)
year = int.parse(publishedDateArray[0]);
month = int.parse(publishedDateArray[1]);
}
if (publishedDateArray.length == 3) {
// assume we have year-month-day
year = int.parse(publishedDateArray[0]);
month = int.parse(publishedDateArray[1]);
day = int.parse(publishedDateArray[2]);
}
publishedDate = DateTime(year, month, day);
}
}`
If I can help in any mode please tell me (but I'm NOT a professional developer).
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working