Null safety
This commit is contained in:
parent
2da1686395
commit
4a99ef1042
|
|
@ -314,7 +314,7 @@ class TaskSidebar extends StatelessWidget {
|
|||
itemCount: runningTasks.length,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
return TaskListItem(
|
||||
task: runningTasks[index],
|
||||
task: runningTasks[index]!,
|
||||
showCheckbox: false,
|
||||
);
|
||||
},
|
||||
|
|
|
|||
|
|
@ -209,7 +209,7 @@ class _InvoiceItemSelectorState extends State<InvoiceItemSelector>
|
|||
itemCount: tasks.length,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
final String? entityId = tasks[index];
|
||||
final task = state.taskState.map[entityId];
|
||||
final task = state.taskState.map[entityId]!;
|
||||
return TaskListItem(
|
||||
isDismissible: false,
|
||||
onCheckboxChanged: (checked) => _toggleEntity(task),
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ class TaskListItem extends StatelessWidget {
|
|||
|
||||
final Function(bool?)? onCheckboxChanged;
|
||||
final GestureTapCallback? onTap;
|
||||
final TaskEntity? task;
|
||||
final TaskEntity task;
|
||||
final String? filter;
|
||||
final bool showCheckbox;
|
||||
final bool isDismissible;
|
||||
|
|
@ -46,63 +46,62 @@ class TaskListItem extends StatelessWidget {
|
|||
final state = store.state;
|
||||
final uiState = state.uiState;
|
||||
final taskUIState = uiState.taskUIState;
|
||||
final client = state.clientState.get(task!.clientId);
|
||||
final client = state.clientState.get(task.clientId);
|
||||
final filterMatch = filter != null && filter!.isNotEmpty
|
||||
? (task!.matchesFilterValue(filter) ??
|
||||
client.matchesFilterValue(filter))
|
||||
? (task.matchesFilterValue(filter) ?? client.matchesFilterValue(filter))
|
||||
: null;
|
||||
final listUIState = taskUIState.listUIState;
|
||||
final isInMultiselect = listUIState.isInMultiselect();
|
||||
final showCheckbox = onCheckboxChanged != null || isInMultiselect;
|
||||
final isChecked = isDismissible
|
||||
? (isInMultiselect && listUIState.isSelected(task!.id))
|
||||
? (isInMultiselect && listUIState.isSelected(task.id))
|
||||
: this.isChecked;
|
||||
final textStyle = TextStyle(fontSize: 16);
|
||||
final textColor = Theme.of(context).textTheme.bodyLarge!.color;
|
||||
final localization = AppLocalization.of(context);
|
||||
|
||||
final status = state.taskStatusState.get(task!.statusId);
|
||||
final statusLabel = task!.isInvoiced
|
||||
final status = state.taskStatusState.get(task.statusId);
|
||||
final statusLabel = task.isInvoiced
|
||||
? localization!.invoiced
|
||||
: task!.isRunning
|
||||
: task.isRunning
|
||||
? localization!.running
|
||||
: status.name.isNotEmpty
|
||||
? status.name
|
||||
: localization!.logged;
|
||||
final statusColor = task!.isInvoiced
|
||||
final statusColor = task.isInvoiced
|
||||
? state.prefState.colorThemeModel!.colorSuccess
|
||||
: task!.isRunning
|
||||
: task.isRunning
|
||||
? state.prefState.colorThemeModel!.colorInfo
|
||||
: status.color.isNotEmpty && status.color != '#fff'
|
||||
? convertHexStringToColor(status.color)
|
||||
: TaskStatusColors(state.prefState.colorThemeModel)
|
||||
.colors[task!.calculateStatusId];
|
||||
.colors[task.calculateStatusId];
|
||||
|
||||
String subtitle = client.displayName;
|
||||
if (task!.projectId.isNotEmpty) {
|
||||
if (task.projectId.isNotEmpty) {
|
||||
subtitle +=
|
||||
' • ' + state.projectState.get(task!.projectId).listDisplayName;
|
||||
' • ' + state.projectState.get(task.projectId).listDisplayName;
|
||||
}
|
||||
|
||||
final duration = LiveText(() {
|
||||
return formatNumber(task!.listDisplayAmount, context,
|
||||
return formatNumber(task.listDisplayAmount, context,
|
||||
formatNumberType: FormatNumberType.duration);
|
||||
}, style: textStyle);
|
||||
|
||||
final startStopButton = !isDismissible
|
||||
? SizedBox()
|
||||
: IconButton(
|
||||
icon: task!.isInvoiced
|
||||
icon: task.isInvoiced
|
||||
? SizedBox()
|
||||
: Icon(
|
||||
getEntityActionIcon(task!.isRunning
|
||||
getEntityActionIcon(task.isRunning
|
||||
? EntityAction.stop
|
||||
: EntityAction.start),
|
||||
),
|
||||
onPressed: task!.isInvoiced
|
||||
onPressed: task.isInvoiced
|
||||
? null
|
||||
: () => handleEntityAction(task,
|
||||
task!.isRunning ? EntityAction.stop : EntityAction.start),
|
||||
task.isRunning ? EntityAction.stop : EntityAction.start),
|
||||
visualDensity: VisualDensity.compact,
|
||||
);
|
||||
|
||||
|
|
@ -110,7 +109,7 @@ class TaskListItem extends StatelessWidget {
|
|||
showMultiselect: this.showCheckbox,
|
||||
isDismissible: isDismissible,
|
||||
isSelected: isDesktop(context) &&
|
||||
task!.id ==
|
||||
task.id ==
|
||||
(uiState.isEditing
|
||||
? taskUIState.editing!.id
|
||||
: taskUIState.selectedId),
|
||||
|
|
@ -121,9 +120,9 @@ class TaskListItem extends StatelessWidget {
|
|||
return constraints.maxWidth > kTableListWidthCutoff
|
||||
? InkWell(
|
||||
onTap: () =>
|
||||
onTap != null ? onTap!() : selectEntity(entity: task!),
|
||||
onTap != null ? onTap!() : selectEntity(entity: task),
|
||||
onLongPress: () => selectEntity(
|
||||
entity: task!,
|
||||
entity: task,
|
||||
longPress: true,
|
||||
),
|
||||
child: Padding(
|
||||
|
|
@ -154,7 +153,7 @@ class TaskListItem extends StatelessWidget {
|
|||
),
|
||||
)
|
||||
: ActionMenuButton(
|
||||
entityActions: task!.getActions(
|
||||
entityActions: task.getActions(
|
||||
userCompany: state.userCompany,
|
||||
includeEdit: true,
|
||||
),
|
||||
|
|
@ -170,11 +169,11 @@ class TaskListItem extends StatelessWidget {
|
|||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Text(
|
||||
task!.number,
|
||||
task.number,
|
||||
style: textStyle,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
if (!task!.isActive) EntityStateLabel(task)
|
||||
if (!task.isActive) EntityStateLabel(task)
|
||||
],
|
||||
),
|
||||
),
|
||||
|
|
@ -184,8 +183,8 @@ class TaskListItem extends StatelessWidget {
|
|||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Text(
|
||||
task!.description +
|
||||
(task!.documents.isNotEmpty ? ' 📎' : ''),
|
||||
task.description +
|
||||
(task.documents.isNotEmpty ? ' 📎' : ''),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: textStyle),
|
||||
|
|
@ -216,8 +215,8 @@ class TaskListItem extends StatelessWidget {
|
|||
)
|
||||
: ListTile(
|
||||
onTap: () =>
|
||||
onTap != null ? onTap!() : selectEntity(entity: task!),
|
||||
onLongPress: () => selectEntity(entity: task!, longPress: true),
|
||||
onTap != null ? onTap!() : selectEntity(entity: task),
|
||||
onLongPress: () => selectEntity(entity: task, longPress: true),
|
||||
leading: showCheckbox
|
||||
? IgnorePointer(
|
||||
ignoring: listUIState.isInMultiselect(),
|
||||
|
|
@ -237,10 +236,10 @@ class TaskListItem extends StatelessWidget {
|
|||
children: <Widget>[
|
||||
Expanded(
|
||||
child: Text(
|
||||
(task!.description.isEmpty
|
||||
? task!.number
|
||||
: task!.description) +
|
||||
(task!.documents.isNotEmpty ? ' 📎' : ''),
|
||||
(task.description.isEmpty
|
||||
? task.number
|
||||
: task.description) +
|
||||
(task.documents.isNotEmpty ? ' 📎' : ''),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: Theme.of(context).textTheme.titleMedium,
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ class TaskListBuilder extends StatelessWidget {
|
|||
onSortColumn: viewModel.onSortColumn,
|
||||
itemBuilder: (BuildContext context, index) {
|
||||
final taskId = viewModel.taskList[index];
|
||||
final task = viewModel.taskMap[taskId];
|
||||
final task = viewModel.taskMap[taskId]!;
|
||||
|
||||
return TaskListItem(
|
||||
filter: viewModel.filter,
|
||||
|
|
|
|||
Loading…
Reference in New Issue