-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c6a4f0b
commit 22f74d9
Showing
12 changed files
with
164 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import 'package:sqflite/sqflite.dart' as sql; | ||
import 'package:path/path.dart' as path; | ||
import 'package:sqflite/sqflite.dart'; | ||
import 'package:to_do_app/models/to_do.dart'; | ||
|
||
class SqfLiteService { | ||
Future<Database> initializeDataBase() async { | ||
final dbPath = await sql.getDatabasesPath(); | ||
return await sql.openDatabase(path.join(dbPath, 'TodstoDb'), | ||
onCreate: (dbInstance, version) async { | ||
dbInstance.execute( | ||
"CREATE TABLE user_todos (id TEXT PRIMARY KEY, taskName TEXT, time TEXT, date TEXT, taskDayClassification TEXT, repeatTaskDays TEXT, isChecked INTEGER)", | ||
); | ||
}, version: 1); | ||
} | ||
|
||
void insertIntoDatabase(ToDo todo) async { | ||
final db = await initializeDataBase(); | ||
db.insert('user_todos', { | ||
'id': todo.id, | ||
'taskName': todo.taskName, | ||
'time': todo.time.toString(), | ||
'date': todo.date.toString(), | ||
'taskDayClassification': todo.taskDayClassification, | ||
'repeatTaskDays': todo.repeatTaskDays, | ||
'isChecked': todo.isChecked ? 1 : 0 | ||
}); | ||
} | ||
|
||
void deleteFromDataBase(ToDo todo) async { | ||
final db = await initializeDataBase(); | ||
await db.delete('user_todos', where: 'id == ?', whereArgs: [todo.id]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ dependencies: | |
sqflite: ^2.3.0 | ||
|
||
path: ^1.8.3 | ||
shared_preferences: ^2.2.2 | ||
|
||
|
||
|
||
|