Add 'packages/model/' from commit '308cd94c783dcf884d88c1e6660bc86510616387'
git-subtree-dir: packages/model git-subtree-mainline:cf2ad35d2b
git-subtree-split:308cd94c78
This commit is contained in:
commit
106535751b
8 changed files with 101 additions and 0 deletions
12
packages/model/.gitignore
vendored
Normal file
12
packages/model/.gitignore
vendored
Normal 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/
|
11
packages/model/CHANGELOG.md
Normal file
11
packages/model/CHANGELOG.md
Normal 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
21
packages/model/LICENSE
Normal 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
8
packages/model/README.md
Normal 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.
|
4
packages/model/analysis_options.yaml
Normal file
4
packages/model/analysis_options.yaml
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
include: package:pedantic/analysis_options.yaml
|
||||||
|
analyzer:
|
||||||
|
strong-mode:
|
||||||
|
implicit-casts: false
|
20
packages/model/example/main.dart
Normal file
20
packages/model/example/main.dart
Normal 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);
|
||||||
|
}
|
16
packages/model/lib/angel_model.dart
Normal file
16
packages/model/lib/angel_model.dart
Normal 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);
|
||||||
|
}
|
9
packages/model/pubspec.yaml
Normal file
9
packages/model/pubspec.yaml
Normal 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
|
Loading…
Reference in a new issue