Skip to content

Commit 263f827

Browse files
Merge pull request #194 from Workiva/add_json_typedefs
Add typedefs for json maps
2 parents 4347e68 + 4469931 commit 263f827

File tree

7 files changed

+23
-8
lines changed

7 files changed

+23
-8
lines changed

.github/workflows/dart_ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
strategy:
1616
fail-fast: false
1717
matrix:
18-
sdk: [ 2.18.7, 2.19.6 ]
18+
sdk: [ 2.19.6, stable ]
1919
steps:
2020
- uses: actions/checkout@v2
2121
- uses: dart-lang/setup-dart@v1

w_common/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
## [3.1.0](https://github.com/Workiva/w_common/compare/3.0.0...3.1.0)
2+
3+
- Adds JsonMap and JsonMapObject typedefs
4+
- Update SDK minimum to 2.19.0 to support the non-function
5+
typedef language feature.
6+
- Raised package versions to their first nullsafe version.
7+
18
## [3.0.0](https://github.com/Workiva/w_common/compare/2.1.2...3.0.0)
29

310
- Migrate to null-safety.

w_common/lib/json_serializable.dart

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,16 @@ abstract class JsonSerializable {
2121
/// Returns a map representing the serialized class.
2222
///
2323
/// @override
24-
/// Map<String, dynamic> toJson() {
25-
/// Map<String, dynamic> fieldMap = {};
24+
/// JsonMap toJson() {
25+
/// JsonMap fieldMap = {};
2626
/// fieldMap['context'] = _context;
2727
/// return fieldMap;
2828
/// }
29-
Map<String, dynamic> toJson();
29+
JsonMap toJson();
3030
}
31+
32+
/// A type definition for a map that represents the default JSON object type Map<String, dynamic>.
33+
typedef JsonMap = Map<String, dynamic>;
34+
35+
/// A type definition for a map that represents a JSON map of Map<String, Object?>.
36+
typedef JsonMapObject = Map<String, Object?>;

w_common/lib/src/common/disposable.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,7 @@ class Disposable implements _Disposable, DisposableManagerV7, LeakFlagger {
553553
}
554554

555555
void manageDisposable(Disposable disposable) {
556+
// ignore: unnecessary_null_comparison
556557
if (disposable == null) {
557558
return;
558559
}

w_common/lib/src/common/managed_stream_subscription.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ class ManagedStreamSubscription<T> implements StreamSubscription<T> {
4343
// StreamSubscription.cancel() will return null if no cleanup was
4444
// necessary. This behavior is described in the docs as "for historical
4545
// reasons" so this may change in the future.
46+
// ignore: unnecessary_null_comparison
4647
if (result == null) {
4748
_complete();
4849
return Future(() {});

w_common/pubspec.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: General utilities for Dart projects.
44
homepage: https://www.github.com/Workiva/w_common
55

66
environment:
7-
sdk: '>=2.12.0 <3.0.0'
7+
sdk: '>=2.19.0 <3.0.0'
88

99
dependencies:
1010
intl: '>=0.17.0 <0.19.0'
@@ -17,9 +17,9 @@ dev_dependencies:
1717
build_test: ^2.0.0
1818
build_web_compilers: ^3.0.0
1919
dependency_validator: ^3.0.0
20-
mocktail: ^1.0.3
20+
mocktail: ^1.0.4
2121
test: ^1.21.1
22-
workiva_analysis_options: ^1.0.0
22+
workiva_analysis_options: ^1.4.2
2323

2424
dependency_validator:
2525
ignore:

w_common_tools/lib/src/bin/compile_sass.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ class SassCompilationOptions {
117117
exitCode = 1;
118118
return;
119119
}
120-
120+
// ignore: unnecessary_null_comparison
121121
if (unparsedArgs != null && unparsedArgs.isNotEmpty) {
122122
compileTargets = unparsedArgs.map(path.relative).toList();
123123
exitCode = _validateCompileTargets();

0 commit comments

Comments
 (0)