mirror of
https://github.com/johrpan/memor.git
synced 2025-10-28 19:27:25 +01:00
Initial commit
This commit is contained in:
commit
4be8aa8ff5
47 changed files with 1577 additions and 0 deletions
41
lib/memo.dart
Normal file
41
lib/memo.dart
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
import 'dart:math';
|
||||
|
||||
import 'package:meta/meta.dart';
|
||||
|
||||
/// A simple memo.
|
||||
///
|
||||
/// This is the model to represent Memor's reminders.
|
||||
class Memo {
|
||||
/// An unique ID for the memo.
|
||||
///
|
||||
/// This will be used for scheduling the notification. It will be generated,
|
||||
/// if set to null.
|
||||
final int id;
|
||||
|
||||
/// The actual memo set by the user.
|
||||
final String text;
|
||||
|
||||
/// The date and time for the scheduled notification.
|
||||
final DateTime scheduled;
|
||||
|
||||
static final _random = Random();
|
||||
static int _generateId() => _random.nextInt(0xFFFFFFF);
|
||||
|
||||
Memo({
|
||||
int id,
|
||||
@required this.text,
|
||||
@required this.scheduled,
|
||||
}) : id = id ?? _generateId();
|
||||
|
||||
factory Memo.fromJson(Map<String, dynamic> json) => Memo(
|
||||
id: json['id'],
|
||||
text: json['text'],
|
||||
scheduled: DateTime.parse(json['scheduled']),
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'id': id,
|
||||
'text': text,
|
||||
'scheduled': scheduled.toIso8601String(),
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue