fix: revert null-aware map entries; disable use_null_aware_elements lint
The ? operator on map entries applies to the key, not the value. String literal keys can never be null, so ?'key': value was flagged as invalid_null_aware_operator. Reverted to if (x != null) 'key': x form and disabled the lint project-wide since it doesn't apply here.
This commit is contained in:
@@ -23,6 +23,9 @@ linter:
|
|||||||
rules:
|
rules:
|
||||||
# avoid_print: false # Uncomment to disable the `avoid_print` rule
|
# avoid_print: false # Uncomment to disable the `avoid_print` rule
|
||||||
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule
|
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule
|
||||||
|
# ?'key': value applies ? to the key (never null for string literals);
|
||||||
|
# the if (x != null) form is correct for nullable-value map entries.
|
||||||
|
use_null_aware_elements: false
|
||||||
|
|
||||||
# Additional information about this file can be found at
|
# Additional information about this file can be found at
|
||||||
# https://dart.dev/guides/language/analysis-options
|
# https://dart.dev/guides/language/analysis-options
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ class NotesApi {
|
|||||||
'title': title,
|
'title': title,
|
||||||
'body': body,
|
'body': body,
|
||||||
'tags': tags,
|
'tags': tags,
|
||||||
?'project_id': projectId,
|
if (projectId != null) 'project_id': projectId,
|
||||||
});
|
});
|
||||||
return Note.fromJson(response.data as Map<String, dynamic>);
|
return Note.fromJson(response.data as Map<String, dynamic>);
|
||||||
} on DioException catch (e) {
|
} on DioException catch (e) {
|
||||||
@@ -59,7 +59,7 @@ class NotesApi {
|
|||||||
'title': title,
|
'title': title,
|
||||||
'body': body,
|
'body': body,
|
||||||
'tags': tags,
|
'tags': tags,
|
||||||
if (clearProject) 'project_id': null else ?'project_id': projectId,
|
if (clearProject) 'project_id': null else if (projectId != null) 'project_id': projectId,
|
||||||
});
|
});
|
||||||
return Note.fromJson(response.data as Map<String, dynamic>);
|
return Note.fromJson(response.data as Map<String, dynamic>);
|
||||||
} on DioException catch (e) {
|
} on DioException catch (e) {
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ class ProjectsApi {
|
|||||||
if (description != null && description.isNotEmpty)
|
if (description != null && description.isNotEmpty)
|
||||||
'description': description,
|
'description': description,
|
||||||
if (goal != null && goal.isNotEmpty) 'goal': goal,
|
if (goal != null && goal.isNotEmpty) 'goal': goal,
|
||||||
?'color': color,
|
if (color != null) 'color': color,
|
||||||
});
|
});
|
||||||
return Project.fromJson(response.data as Map<String, dynamic>);
|
return Project.fromJson(response.data as Map<String, dynamic>);
|
||||||
} on DioException catch (e) {
|
} on DioException catch (e) {
|
||||||
|
|||||||
@@ -43,8 +43,8 @@ class TasksApi {
|
|||||||
'status': status.value,
|
'status': status.value,
|
||||||
'priority': priority.value,
|
'priority': priority.value,
|
||||||
'due_date': dueDate?.toIso8601String(),
|
'due_date': dueDate?.toIso8601String(),
|
||||||
?'project_id': projectId,
|
if (projectId != null) 'project_id': projectId,
|
||||||
?'parent_id': parentId,
|
if (parentId != null) 'parent_id': parentId,
|
||||||
});
|
});
|
||||||
return Task.fromJson(response.data as Map<String, dynamic>);
|
return Task.fromJson(response.data as Map<String, dynamic>);
|
||||||
} on DioException catch (e) {
|
} on DioException catch (e) {
|
||||||
|
|||||||
Reference in New Issue
Block a user