Skip to content
GitLab
Projets
Groupes
Sujets
Extraits de code
/
Aide
Aide
Support
Forum de la communauté
Raccourcis clavier
?
Proposer une rétroaction
Contribuer à GitLab
Connexion
Activer/désactiver la navigation
Menu
Jérémy DEZETREE
NFC_Google_Sheet
Comparer les révisions
b696277ba5354c097960a742ebac947bc34af106...d86a2bff6c62a2cb0d46c7793f89109d2b5f547a
Commits (2)
add model and sqlLite database helper
· 9075b2f6
Clément Flambard
a écrit
oct. 22, 2025
9075b2f6
add model and sqlLite database helper
· d86a2bff
Clément Flambard
a écrit
oct. 22, 2025
d86a2bff
Masquer les modifications d'espaces
En ligne
Côte à côte
lib/database/databaseHelper.dart
0 → 100644
Voir le fichier @
d86a2bff
import
'package:path/path.dart'
;
import
'package:sqflite/sqflite.dart'
;
import
'../model/student.dart'
;
class
DatabaseHelper
{
static
final
DatabaseHelper
instance
=
DatabaseHelper
.
_instance
();
static
Database
?
_database
;
DatabaseHelper
.
_instance
();
Future
<
Database
>
get
db
async
{
_database
??=
await
initDb
();
return
_database
!
;
}
Future
<
Database
>
initDb
()
async
{
String
databasesPath
=
await
getDatabasesPath
();
String
path
=
join
(
databasesPath
,
'student_university.db'
);
return
await
openDatabase
(
path
,
version:
1
,
onCreate:
_onCreate
);
}
Future
_onCreate
(
Database
db
,
int
version
)
async
{
await
db
.
execute
(
'''
CREATE TABLE student (
studentNFCCardId TEXT PRIMARY KEY,
firstName TEXT,
name TEXT,
promotion TEXT,
studentId TEXT
)
'''
);
}
Future
<
int
>
insertUser
(
Student
student
)
async
{
Database
db
=
await
instance
.
db
;
return
await
db
.
insert
(
'student'
,
student
.
toMap
());
}
Future
<
List
<
Map
<
String
,
dynamic
>>>
queryAllUsers
()
async
{
Database
db
=
await
instance
.
db
;
return
await
db
.
query
(
'student'
);
}
Future
<
int
>
updateUser
(
Student
student
)
async
{
Database
db
=
await
instance
.
db
;
return
await
db
.
update
(
'student'
,
student
.
toMap
(),
where:
'studentNFCCardId = ?'
,
whereArgs:
[
student
.
studentNFCCardId
]);
}
Future
<
int
>
deleteUser
(
String
studentNFCCardId
)
async
{
Database
db
=
await
instance
.
db
;
return
await
db
.
delete
(
'student'
,
where:
'studentNFCCardId = ?'
,
whereArgs:
[
studentNFCCardId
]);
}
}
\ No newline at end of file
lib/model/student.dart
0 → 100644
Voir le fichier @
d86a2bff
class
Student
{
final
String
studentNFCCardId
;
final
String
firstName
;
final
String
name
;
final
String
promotion
;
final
String
studentId
;
Student
({
required
this
.
studentNFCCardId
,
required
this
.
firstName
,
required
this
.
name
,
required
this
.
promotion
,
required
this
.
studentId
});
Map
<
String
,
dynamic
>
toMap
()
{
return
{
'studentNFCCardId'
:
studentNFCCardId
,
'firstName'
:
firstName
,
'name'
:
name
,
'promotion'
:
promotion
,
'studentId'
:
studentId
};
}
factory
Student
.
fromMap
(
Map
<
String
,
dynamic
>
map
)
{
return
Student
(
studentNFCCardId:
map
[
'studentNFCCardId'
],
firstName:
map
[
'firstName'
],
name:
map
[
'name'
],
promotion:
map
[
'promotion'
],
studentId:
map
[
'studentId'
]
);
}
}
\ No newline at end of file
macos/Flutter/GeneratedPluginRegistrant.swift
Voir le fichier @
d86a2bff
...
@@ -5,6 +5,8 @@
...
@@ -5,6 +5,8 @@
import
FlutterMacOS
import
FlutterMacOS
import
Foundation
import
Foundation
import
sqflite_darwin
func
RegisterGeneratedPlugins
(
registry
:
FlutterPluginRegistry
)
{
func
RegisterGeneratedPlugins
(
registry
:
FlutterPluginRegistry
)
{
SqflitePlugin
.
register
(
with
:
registry
.
registrar
(
forPlugin
:
"SqflitePlugin"
))
}
}
pubspec.lock
Voir le fichier @
d86a2bff
...
@@ -132,13 +132,29 @@ packages:
...
@@ -132,13 +132,29 @@ packages:
source: hosted
source: hosted
version: "1.16.0"
version: "1.16.0"
path:
path:
dependency:
transitive
dependency:
"direct main"
description:
description:
name: path
name: path
sha256: "75cca69d1490965be98c73ceaea117e8a04dd21217b37b292c9ddbec0d955bc5"
sha256: "75cca69d1490965be98c73ceaea117e8a04dd21217b37b292c9ddbec0d955bc5"
url: "https://pub.dev"
url: "https://pub.dev"
source: hosted
source: hosted
version: "1.9.1"
version: "1.9.1"
platform:
dependency: transitive
description:
name: platform
sha256: "5d6b1b0036a5f331ebc77c850ebc8506cbc1e9416c27e59b439f917a902a4984"
url: "https://pub.dev"
source: hosted
version: "3.1.6"
plugin_platform_interface:
dependency: transitive
description:
name: plugin_platform_interface
sha256: "4820fbfdb9478b1ebae27888254d445073732dae3d6ea81f0b7e06d5dedc3f02"
url: "https://pub.dev"
source: hosted
version: "2.1.8"
sky_engine:
sky_engine:
dependency: transitive
dependency: transitive
description: flutter
description: flutter
...
@@ -152,6 +168,46 @@ packages:
...
@@ -152,6 +168,46 @@ packages:
url: "https://pub.dev"
url: "https://pub.dev"
source: hosted
source: hosted
version: "1.10.1"
version: "1.10.1"
sqflite:
dependency: "direct main"
description:
name: sqflite
sha256: e2297b1da52f127bc7a3da11439985d9b536f75070f3325e62ada69a5c585d03
url: "https://pub.dev"
source: hosted
version: "2.4.2"
sqflite_android:
dependency: transitive
description:
name: sqflite_android
sha256: ecd684501ebc2ae9a83536e8b15731642b9570dc8623e0073d227d0ee2bfea88
url: "https://pub.dev"
source: hosted
version: "2.4.2+2"
sqflite_common:
dependency: transitive
description:
name: sqflite_common
sha256: "6ef422a4525ecc601db6c0a2233ff448c731307906e92cabc9ba292afaae16a6"
url: "https://pub.dev"
source: hosted
version: "2.5.6"
sqflite_darwin:
dependency: transitive
description:
name: sqflite_darwin
sha256: "279832e5cde3fe99e8571879498c9211f3ca6391b0d818df4e17d9fff5c6ccb3"
url: "https://pub.dev"
source: hosted
version: "2.4.2"
sqflite_platform_interface:
dependency: transitive
description:
name: sqflite_platform_interface
sha256: "8dd4515c7bdcae0a785b0062859336de775e8c65db81ae33dd5445f35be61920"
url: "https://pub.dev"
source: hosted
version: "2.4.0"
stack_trace:
stack_trace:
dependency: transitive
dependency: transitive
description:
description:
...
@@ -176,6 +232,14 @@ packages:
...
@@ -176,6 +232,14 @@ packages:
url: "https://pub.dev"
url: "https://pub.dev"
source: hosted
source: hosted
version: "1.4.1"
version: "1.4.1"
synchronized:
dependency: transitive
description:
name: synchronized
sha256: c254ade258ec8282947a0acbbc90b9575b4f19673533ee46f2f6e9b3aeefd7c0
url: "https://pub.dev"
source: hosted
version: "3.4.0"
term_glyph:
term_glyph:
dependency: transitive
dependency: transitive
description:
description:
...
@@ -210,4 +274,4 @@ packages:
...
@@ -210,4 +274,4 @@ packages:
version: "15.0.2"
version: "15.0.2"
sdks:
sdks:
dart: ">=3.9.2 <4.0.0"
dart: ">=3.9.2 <4.0.0"
flutter: ">=3.
18.0-18.0.pre.54
"
flutter: ">=3.
24.0
"
pubspec.yaml
Voir le fichier @
d86a2bff
...
@@ -30,6 +30,8 @@ environment:
...
@@ -30,6 +30,8 @@ environment:
dependencies
:
dependencies
:
flutter
:
flutter
:
sdk
:
flutter
sdk
:
flutter
sqflite
:
^2.4.2
path
:
^1.9.0
# The following adds the Cupertino Icons font to your application.
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
# Use with the CupertinoIcons class for iOS style icons.
...
...