This commit is contained in:
Tobe O 2018-12-30 19:30:23 -05:00
parent 7658217d05
commit eb1c5f7df2
5 changed files with 34 additions and 7 deletions

View file

@ -1,2 +1,5 @@
# 1.0.1
* Add `idAsInt`.
# 1.0.0+1
* Update constraint to work with Dart 2.

View file

@ -2,11 +2,7 @@
Angel's basic data model class, no longer with the added weight of the whole framework.
```dart
// Old: import 'package:angel_framework/common.dart' show Model;
// The new way!!!
import 'package:angel_model/angel_model.dart';
```
This package was created to prevent dependency collisions with third-party packages.
`framework/common` will continue to export this class.
This package was created to prevent dependency collisions with third-party packages.

20
example/main.dart Normal file
View file

@ -0,0 +1,20 @@
import 'package:angel_model/angel_model.dart';
void main() {
var todo = Todo(id: '34', isComplete: false);
print(todo.idAsInt == 34);
}
class Todo extends Model {
String text;
bool isComplete;
Todo(
{String id,
this.text,
this.isComplete,
DateTime createdAt,
DateTime updatedAt})
: super(id: id, createdAt: createdAt, updatedAt: updatedAt);
}

View file

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

View file

@ -1,5 +1,5 @@
name: angel_model
version: 1.0.0+1
version: 1.0.1
description: Angel's basic data model class, no longer with the added weight of the whole framework.
author: Tobe O <thosakwe@gmail.com>
homepage: https://github.com/angel-dart/model