Updated model

This commit is contained in:
thomashii 2021-08-02 20:20:07 +08:00
parent 8885a6b1c3
commit 9184dce6ab
5 changed files with 35 additions and 19 deletions

View file

@ -1,20 +1,34 @@
# 3.0.1 # Change Log
## 3.0.2
* Updated README
* Updated `id` to be `required`
## 3.0.1
* Updated README * Updated README
# 3.0.0 ## 3.0.0
* Migrated to support Dart SDK 2.12.x NNBD * Migrated to support Dart SDK 2.12.x NNBD
# 2.0.0 ## 2.0.0
* Migrated to work with Dart SDK 2.12.x Non NNBD * Migrated to work with Dart SDK 2.12.x Non NNBD
# 1.0.3 ## 1.0.3
* `idAsInt` returns `null` when `id` is `null`. * `idAsInt` returns `null` when `id` is `null`.
# 1.0.2 ## 1.0.2
* `idAsInt` now uses `int.tryParse`. * `idAsInt` now uses `int.tryParse`.
# 1.0.1 ## 1.0.1
* Add `idAsInt`. * Add `idAsInt`.
# 1.0.0+1 ## 1.0.0+1
* Update constraint to work with Dart 2. * Update constraint to work with Dart 2.

View file

@ -1,14 +1,15 @@
# angel3_model # Angel3 Basic Model
[![version](https://img.shields.io/badge/pub-v3.0.1-brightgreen)](https://pub.dartlang.org/packages/angel3_model)
[![version](https://img.shields.io/badge/pub-v3.0.2-brightgreen)](https://pub.dartlang.org/packages/angel3_model)
[![Null Safety](https://img.shields.io/badge/null-safety-brightgreen)](https://dart.dev/null-safety) [![Null Safety](https://img.shields.io/badge/null-safety-brightgreen)](https://dart.dev/null-safety)
[![Gitter](https://img.shields.io/gitter/room/angel_dart/discussion)](https://gitter.im/angel_dart/discussion) [![Gitter](https://img.shields.io/gitter/room/angel_dart/discussion)](https://gitter.im/angel_dart/discussion)
[![License](https://img.shields.io/github/license/dukefirehawk/angel)](https://github.com/dukefirehawk/angel/tree/angel3/packages/model/LICENSE) [![License](https://img.shields.io/github/license/dukefirehawk/angel)](https://github.com/dukefirehawk/angel/tree/angel3/packages/model/LICENSE)
Angel's basic data model class, no longer with the added weight of the whole framework. Angel3 basic data model class, no longer with the added weight of the whole framework.
```dart ```dart
import 'package:angel3_model/angel3_model.dart'; import 'package:angel3_model/angel3_model.dart';
``` ```
This package was created to prevent dependency collisions with third-party packages. This package was created to prevent dependency collisions with third-party packages.

View file

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

View file

@ -3,7 +3,7 @@
/// 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;
String? error; String? error;
@ -13,8 +13,8 @@ class Model {
/// 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({required 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 => int.tryParse(id) ?? 0;
} }

View file

@ -1,7 +1,8 @@
name: angel3_model name: angel3_model
version: 3.0.1 version: 3.0.1
description: Angel's basic data model class, no longer with the added weight of the whole framework. description: Angel3 basic data model class, no longer with the added weight of the whole framework.
homepage: https://github.com/dukefirehawk/angel/tree/angel3/packages/model homepage: https://angel3-framework.web.app/
repository: https://github.com/dukefirehawk/angel/tree/angel3/packages/model
environment: environment:
sdk: '>=2.12.0 <3.0.0' sdk: '>=2.12.0 <3.0.0'
dev_dependencies: dev_dependencies: