1
0
mirror of https://github.com/go-vikunja/app synced 2024-06-02 18:49:47 +00:00

fixed various "cannot be null" warnings

This commit is contained in:
Benimautner 2022-08-27 23:43:53 +02:00
parent ae71e21e44
commit 1146a71ded
11 changed files with 41 additions and 38 deletions

View File

@ -97,6 +97,7 @@ class Client {
Future<Response> post(String url, {dynamic body}) {
log('post');
log('body: ' + body.toString());
return http
.post(
'${this.base}$url'.toUri()!,

View File

@ -69,7 +69,7 @@ class _BucketTaskCardState extends State<BucketTaskCard> with AutomaticKeepAlive
),
],
);
if (widget.task.done ?? false) {
if (widget.task.done) {
identifierRow.children.insert(0, Container(
constraints: chipConstraints,
padding: EdgeInsets.only(right: 4),

View File

@ -36,6 +36,7 @@ class TaskTileState extends State<TaskTile> with AutomaticKeepAliveClientMixin {
@override
Widget build(BuildContext context) {
super.build(context);
final taskState = Provider.of<ListProvider>(context);
Duration? durationUntilDue = _currentTask.dueDate?.difference(DateTime.now());
if (_currentTask.loading) {
return ListTile(
@ -74,7 +75,7 @@ class TaskTileState extends State<TaskTile> with AutomaticKeepAliveClientMixin {
)
) : Text(_currentTask.title ?? ""),
controlAffinity: ListTileControlAffinity.leading,
value: _currentTask.done ?? false,
value: _currentTask.done,
subtitle: widget.showInfo && _currentTask.hasDueDate ?
Text("Due " + durationToHumanReadable(durationUntilDue!), style: TextStyle(color: durationUntilDue.isNegative ? Colors.red : null),)
: _currentTask.description == null || _currentTask.description!.isEmpty
@ -87,7 +88,7 @@ class TaskTileState extends State<TaskTile> with AutomaticKeepAliveClientMixin {
MaterialPageRoute(
builder: (buildContext) => TaskEditPage(
task: _currentTask,
taskState: Provider.of<ListProvider>(context),
taskState: taskState,
),
),
).then((task) => setState(() {

View File

@ -18,7 +18,7 @@ class LabelComponent extends StatefulWidget {
class LabelComponentState extends State<LabelComponent> {
@override
Widget build(BuildContext context) {
Color backgroundColor = widget.label.color ?? vLabelDefaultColor;
Color backgroundColor = widget.label.color;
Color textColor =
backgroundColor.computeLuminance() > 0.5 ? vLabelDark : vLabelLight;

View File

@ -44,7 +44,7 @@ class Bucket {
tasks = (json['tasks'] as List<dynamic>)
.map((task) => Task.fromJson(task))
.cast<Task>()
.toList() ?? <Task>[];
.toList();
toJSON() => {
'id': id,
@ -52,10 +52,10 @@ class Bucket {
'title': title,
'position': position,
'limit': limit,
'is_done_bucket': isDoneBucket ?? false,
'is_done_bucket': isDoneBucket,
'created': created?.toUtc().toIso8601String(),
'updated': updated?.toUtc().toIso8601String(),
'createdBy': createdBy?.toJSON(),
'tasks': tasks?.map((task) => task.toJSON()).toList(),
'tasks': tasks.map((task) => task.toJSON()).toList(),
};
}

View File

@ -36,10 +36,10 @@ class Label {
'title': title,
'description': description,
'hex_color':
color?.value?.toRadixString(16)?.padLeft(8, '0')?.substring(2),
color.value.toRadixString(16).padLeft(8, '0').substring(2),
'created_by': createdBy?.toJSON(),
'updated': updated?.toUtc()?.toIso8601String(),
'created': created?.toUtc()?.toIso8601String(),
'updated': updated?.toUtc().toIso8601String(),
'created': created?.toUtc().toIso8601String(),
};
Color get textColor => color != null && color.computeLuminance() <= 0.5 ? vLabelLight : vLabelDark;

View File

@ -102,7 +102,7 @@ class Task {
'title': title,
'description': description,
'identifier': identifier,
'done': done ?? false,
'done': done,
'reminder_dates':
reminderDates?.map((date) => date?.toUtc().toIso8601String()).toList(),
'due_date': dueDate?.toUtc().toIso8601String(),
@ -160,27 +160,27 @@ class Task {
}) {
return Task(
id: id ?? this.id,
parentTaskId: parentTaskId ?? this.parentTaskId,
priority: priority ?? this.priority,
listId: listId ?? this.listId,
bucketId: bucketId ?? this.bucketId,
created: created ?? this.created,
updated: updated ?? this.updated,
dueDate: dueDate ?? this.dueDate,
startDate: startDate ?? this.startDate,
endDate: endDate ?? this.endDate,
reminderDates: reminderDates ?? this.reminderDates,
title: title ?? this.title,
description: description ?? this.description,
parentTaskId: parentTaskId,
priority: priority,
listId: listId,
bucketId: bucketId,
created: created,
updated: updated,
dueDate: dueDate,
startDate: startDate,
endDate: endDate,
reminderDates: reminderDates,
title: title,
description: description,
identifier: identifier ?? this.identifier,
done: done ?? this.done,
color: (resetColor ?? false) ? vBlue : (color ?? this.color),
kanbanPosition: kanbanPosition ?? this.kanbanPosition,
createdBy: createdBy ?? this.createdBy,
repeatAfter: repeatAfter ?? this.repeatAfter,
subtasks: subtasks ?? this.subtasks,
labels: labels ?? this.labels,
attachments: attachments ?? this.attachments,
kanbanPosition: kanbanPosition,
createdBy: createdBy,
repeatAfter: repeatAfter,
subtasks: subtasks,
labels: labels,
attachments: attachments,
);
}
}

View File

@ -28,7 +28,7 @@ class TaskAttachment {
toJSON() => {
'id': id,
'task_id': taskId,
'created': created?.toUtc()?.toIso8601String(),
'created': created?.toUtc().toIso8601String(),
'created_by': createdBy?.toJSON(),
};
}

View File

@ -66,7 +66,7 @@ class _TaskEditPageState extends State<TaskEditPage> {
return WillPopScope(
onWillPop: () {
if(_changed) {
return (_showConfirmationDialog() ?? Future.value(false));
return (_showConfirmationDialog());
}
return new Future(() => true);
},
@ -375,6 +375,11 @@ class _TaskEditPageState extends State<TaskEditPage> {
color: _resetColor ? null : (_color ?? widget.task.color),
resetColor: _resetColor,
);
if(_dueDate != null)
log(_dueDate.toString());
else
log("due date is null");
log(updatedTask.toJSON().toString());
// update the labels
await VikunjaGlobal.of(context)

View File

@ -184,7 +184,7 @@ class ListProvider with ChangeNotifier {
_buckets[newBucketIndex].tasks.insert(index, task);
task = await VikunjaGlobal.of(context).taskService.update(task.copyWith(
bucketId: newBucketId ?? task.bucketId,
bucketId: newBucketId,
kanbanPosition: calculateItemPosition(
positionBefore: index != 0
? _buckets[newBucketIndex].tasks[index - 1].kanbanPosition : null,

View File

@ -1,11 +1,7 @@
datetimeToUnixTimestamp(DateTime dt) {
return dt?.millisecondsSinceEpoch == null
? null
: (dt.millisecondsSinceEpoch / 1000).round();
return (dt.millisecondsSinceEpoch / 1000).round();
}
dateTimeFromUnixTimestamp(int timestamp) {
return timestamp == null
? 0
: DateTime.fromMillisecondsSinceEpoch(timestamp * 1000);
return DateTime.fromMillisecondsSinceEpoch(timestamp * 1000);
}