diff --git a/CHANGELOG.md b/CHANGELOG.md index e28d4188..f1c86f13 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +# 1.0.3 +* `idAsInt` returns `null` when `id` is `null`. + # 1.0.2 * `idAsInt` now uses `int.tryParse`. diff --git a/lib/angel_model.dart b/lib/angel_model.dart index 0694c33a..d179fa54 100644 --- a/lib/angel_model.dart +++ b/lib/angel_model.dart @@ -12,5 +12,5 @@ class Model { Model({this.id, this.createdAt, this.updatedAt}); /// Returns the [id], parsed as an [int]. - int get idAsInt => int.tryParse(id); + int get idAsInt => id == null ? null : int.tryParse(id); } diff --git a/pubspec.yaml b/pubspec.yaml index e751fa00..22040435 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: angel_model -version: 1.0.2 +version: 1.0.3 description: Angel's basic data model class, no longer with the added weight of the whole framework. author: Tobe O homepage: https://github.com/angel-dart/model