Updated Angel Model to Null Safety

This commit is contained in:
thomashii 2021-03-18 08:15:01 +08:00
parent 5d722a6041
commit 5a1782efba
4 changed files with 12 additions and 11 deletions

View file

@ -6,6 +6,7 @@
* Added code_buffer 2.0.0 * Added code_buffer 2.0.0
* Added combinator 2.0.0 * Added combinator 2.0.0
* Updated angel_route to 5.0.0 * Updated angel_route to 5.0.0
* Updated angel_model to 3.0.0
# 3.0.0 (Non NNBD) # 3.0.0 (Non NNBD)
* Changed Dart SDK requirements for all packages to ">=2.10.0 <3.0.0" * Changed Dart SDK requirements for all packages to ">=2.10.0 <3.0.0"

View file

@ -6,15 +6,15 @@ void main() {
} }
class Todo extends Model { class Todo extends Model {
String text; String? text;
bool isComplete; bool? isComplete;
Todo( Todo(
{String id, {String? id,
this.text, this.text,
this.isComplete, this.isComplete,
DateTime createdAt, DateTime? createdAt,
DateTime updatedAt}) DateTime? updatedAt})
: super(id: id, createdAt: createdAt, updatedAt: updatedAt); : super(id: id, createdAt: createdAt, updatedAt: updatedAt);
} }

View file

@ -1,16 +1,16 @@
/// Represents arbitrary data, with an associated ID and timestamps. /// Represents arbitrary data, with an associated ID and timestamps.
class Model { class Model {
/// A unique identifier corresponding to this item. /// A unique identifier corresponding to this item.
String id; String? id;
/// The time at which this item was created. /// The time at which this item was created.
DateTime createdAt; DateTime? createdAt;
/// The last time at which this item was updated. /// The last time at which this item was updated.
DateTime updatedAt; DateTime? updatedAt;
Model({this.id, this.createdAt, this.updatedAt}); Model({this.id, this.createdAt, this.updatedAt});
/// Returns the [id], parsed as an [int]. /// Returns the [id], parsed as an [int].
int get idAsInt => id == null ? null : int.tryParse(id); int? get idAsInt => id == null ? null : int.tryParse(id!);
} }

View file

@ -1,9 +1,9 @@
name: angel_model name: angel_model
version: 2.0.0 version: 3.0.0
description: Angel's basic data model class, no longer with the added weight of the whole framework. description: Angel's basic data model class, no longer with the added weight of the whole framework.
author: Tobe O <thosakwe@gmail.com> author: Tobe O <thosakwe@gmail.com>
homepage: https://github.com/dukefirehawk/angel/packages/model homepage: https://github.com/dukefirehawk/angel/packages/model
environment: environment:
sdk: ">=2.10.0 <3.0.0" sdk: '>=2.12.0 <3.0.0'
dev_dependencies: dev_dependencies:
pedantic: ^1.11.0 pedantic: ^1.11.0