database
This commit is contained in:
36
lib/database/database.dart
Normal file
36
lib/database/database.dart
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
|
||||||
|
import 'package:progetto_m335_flutter/model/note.dart';
|
||||||
|
|
||||||
|
class Database{
|
||||||
|
static final Database _instance = Database._init();
|
||||||
|
static Database? _database;
|
||||||
|
|
||||||
|
Database._init();
|
||||||
|
|
||||||
|
Future<Database> get database async {
|
||||||
|
if (_database != null) return _database!;
|
||||||
|
_database = await _initDB('database.db');
|
||||||
|
return _database!;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future _createDB(Database database) async{
|
||||||
|
const integerPrimaryKeyAutoincrement = 'INTEGER PRIMARY KEY AUTOINCREMENT';
|
||||||
|
const textNotNull = 'TEXT NOT NULL';
|
||||||
|
const integerNotNull = 'INTEGER NOT NULL';
|
||||||
|
const integer = 'INTEGER';
|
||||||
|
const real = 'REAL';
|
||||||
|
const text = 'TEXT';
|
||||||
|
|
||||||
|
|
||||||
|
await database.execute('''
|
||||||
|
CREATE TABLE $Note (
|
||||||
|
${Note.id} $integerPrimaryKeyAutoincrement,
|
||||||
|
|
||||||
|
)
|
||||||
|
''');
|
||||||
|
}
|
||||||
|
|
||||||
|
execute(String s) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,11 +1,18 @@
|
|||||||
|
import 'dart:ui';
|
||||||
|
|
||||||
import 'base_entity.dart';
|
import 'base_entity.dart';
|
||||||
import 'identifiers/enum/priority.dart';
|
import 'identifiers/enum/priority.dart';
|
||||||
|
import 'identifiers/enum/color.dart';
|
||||||
|
|
||||||
class Note extends BaseEntity{
|
class Note extends BaseEntity{
|
||||||
static String id = BaseEntity.getId;
|
static String id = BaseEntity.getId;
|
||||||
static String title = BaseEntity.getTitle;
|
static String title = BaseEntity.getTitle;
|
||||||
static String creationDate = BaseEntity.getCreationDate;
|
static String creationDate = BaseEntity.getCreationDate;
|
||||||
|
|
||||||
static String expirationDate = 'expirationDate';
|
static String expirationDate = 'expirationDate';
|
||||||
Priority priority = Priority.low;
|
static String description = 'description';
|
||||||
|
Priority priority = Priority.none;
|
||||||
|
Color color = Color.none;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user