Fixed app not working with the newest api change which has multiple reminders #19

Merged
konrad merged 3 commits from fix/latest-api-reminder-dates into master 2018-12-03 21:26:01 +00:00
2 changed files with 9 additions and 4 deletions

View File

@ -3,7 +3,8 @@ import 'package:meta/meta.dart';
class Task {
final int id;
final DateTime created, updated, reminder, due;
final DateTime created, updated, due;
final List<DateTime> reminders;
final String text, description;
final bool done;
final User owner;
@ -12,7 +13,7 @@ class Task {
{@required this.id,
this.created,
this.updated,
this.reminder,
this.reminders,
this.due,
@required this.text,
this.description,
@ -23,7 +24,9 @@ class Task {
: id = json['id'],
updated = DateTime.fromMillisecondsSinceEpoch(json['updated']),
created = DateTime.fromMillisecondsSinceEpoch(json['created']),
reminder = DateTime.fromMillisecondsSinceEpoch(json['reminderDate']),
reminders = (json['reminderDates'] as List<dynamic>)
?.map((milli) => DateTime.fromMillisecondsSinceEpoch(milli))
?.toList(),
due = DateTime.fromMillisecondsSinceEpoch(json['dueDate']),
description = json['description'],
text = json['text'],
@ -34,7 +37,8 @@ class Task {
'id': id,
'updated': updated?.millisecondsSinceEpoch,

The reminders should be transfered into an unix timestamp.

Use something like that:

reminders?.map((date) => date.millisecondsSinceEpoch)?.toList()
The reminders should be transfered into an unix timestamp. Use something like that: ```dart reminders?.map((date) => date.millisecondsSinceEpoch)?.toList() ```

Fixed.

Fixed.
'created': created?.millisecondsSinceEpoch,
'reminderDate': reminder?.millisecondsSinceEpoch,
'reminderDates':
reminders?.map((date) => date.millisecondsSinceEpoch)?.toList(),
'dueDate': due?.millisecondsSinceEpoch,
'description': description,
'text': text,

View File

@ -14,6 +14,7 @@ dependencies:
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.2
flutter_secure_storage: 3.1.1
http: 0.12.0
Review

Why do you add this dependency?

Why do you add this dependency?
Review

Because the build would otherwise fail. Apparantly this was changed in the latest flutter version.

Because the build would otherwise fail. Apparantly this was changed in the latest flutter version.
Review

Fair enough

Fair enough
dev_dependencies:
flutter_test: