Add 'packages/model/' from commit '308cd94c783dcf884d88c1e6660bc86510616387'

git-subtree-dir: packages/model
git-subtree-mainline: cf2ad35d2b
git-subtree-split: 308cd94c78
This commit is contained in:
Tobe O 2020-02-15 18:28:32 -05:00
commit 106535751b
8 changed files with 101 additions and 0 deletions

12
packages/model/.gitignore vendored Normal file
View file

@ -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/

View file

@ -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.

21
packages/model/LICENSE Normal file
View file

@ -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.

8
packages/model/README.md Normal file
View file

@ -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.

View file

@ -0,0 +1,4 @@
include: package:pedantic/analysis_options.yaml
analyzer:
strong-mode:
implicit-casts: false

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

@ -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);
}

View file

@ -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 <thosakwe@gmail.com>
homepage: https://github.com/angel-dart/model
environment:
sdk: ">=1.8.0 <3.0.0"
dev_dependencies:
pedantic: ^1.0.0