diff --git a/packages/model/.gitignore b/packages/model/.gitignore new file mode 100644 index 00000000..4d2a4d6d --- /dev/null +++ b/packages/model/.gitignore @@ -0,0 +1,12 @@ +# See https://www.dartlang.org/tools/private-files.html + +# Files and directories created by pub +.packages +.pub/ +build/ +# If you're building an application, you may want to check-in your pubspec.lock +pubspec.lock + +# Directory created by dartdoc +# If you don't generate documentation locally you can remove this line. +doc/api/ diff --git a/packages/model/CHANGELOG.md b/packages/model/CHANGELOG.md new file mode 100644 index 00000000..f1c86f13 --- /dev/null +++ b/packages/model/CHANGELOG.md @@ -0,0 +1,11 @@ +# 1.0.3 +* `idAsInt` returns `null` when `id` is `null`. + +# 1.0.2 +* `idAsInt` now uses `int.tryParse`. + +# 1.0.1 +* Add `idAsInt`. + +# 1.0.0+1 +* Update constraint to work with Dart 2. diff --git a/packages/model/LICENSE b/packages/model/LICENSE new file mode 100644 index 00000000..3de28325 --- /dev/null +++ b/packages/model/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2017 Tobe O + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/packages/model/README.md b/packages/model/README.md new file mode 100644 index 00000000..fdb704c9 --- /dev/null +++ b/packages/model/README.md @@ -0,0 +1,8 @@ +# angel_model +Angel's basic data model class, no longer with the added weight of the whole framework. + +```dart +import 'package:angel_model/angel_model.dart'; +``` + +This package was created to prevent dependency collisions with third-party packages. \ No newline at end of file diff --git a/packages/model/analysis_options.yaml b/packages/model/analysis_options.yaml new file mode 100644 index 00000000..c230cee7 --- /dev/null +++ b/packages/model/analysis_options.yaml @@ -0,0 +1,4 @@ +include: package:pedantic/analysis_options.yaml +analyzer: + strong-mode: + implicit-casts: false \ No newline at end of file diff --git a/packages/model/example/main.dart b/packages/model/example/main.dart new file mode 100644 index 00000000..f6c5caef --- /dev/null +++ b/packages/model/example/main.dart @@ -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); +} diff --git a/packages/model/lib/angel_model.dart b/packages/model/lib/angel_model.dart new file mode 100644 index 00000000..d179fa54 --- /dev/null +++ b/packages/model/lib/angel_model.dart @@ -0,0 +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 => id == null ? null : int.tryParse(id); +} diff --git a/packages/model/pubspec.yaml b/packages/model/pubspec.yaml new file mode 100644 index 00000000..22040435 --- /dev/null +++ b/packages/model/pubspec.yaml @@ -0,0 +1,9 @@ +name: angel_model +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 +environment: + sdk: ">=1.8.0 <3.0.0" +dev_dependencies: + pedantic: ^1.0.0