-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implements sqflite caching for offline use. (minor changes)
- Loading branch information
Showing
31 changed files
with
1,874 additions
and
218 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
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,40 @@ | ||
class Branches { | ||
final int id; | ||
final DateTime createdAt; | ||
final String branchName; | ||
final String program; | ||
final String authority; | ||
|
||
Branches({ | ||
required this.id, | ||
required this.createdAt, | ||
required this.branchName, | ||
required this.program, | ||
required this.authority, | ||
}); | ||
|
||
factory Branches.fromJson(Map<String, dynamic> json) { | ||
return Branches( | ||
id: json['id'], | ||
createdAt: DateTime.parse(json['created_at']), | ||
branchName: json['branch_name'], | ||
program: json['program'], | ||
authority: json['authority'], | ||
); | ||
} | ||
|
||
Map<String, dynamic> toJson() { | ||
return { | ||
'id': id, | ||
'created_at': createdAt.toIso8601String(), | ||
'branch_name': branchName, | ||
'program': program, | ||
'authority': authority, | ||
}; | ||
} | ||
|
||
@override | ||
String toString() { | ||
return 'Branches{id: $id, createdAt: $createdAt, branchName: $branchName, program: $program, authority: $authority}'; | ||
} | ||
} |
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,41 @@ | ||
class Program { | ||
final int? id; | ||
final DateTime? createdAt; | ||
final String name; | ||
final String authority; | ||
|
||
Program({ | ||
this.id, | ||
this.createdAt, | ||
required this.name, | ||
this.authority = '', | ||
}); | ||
|
||
// Convert a Program object into a Map (to insert into the database) | ||
Map<String, dynamic> toJson() { | ||
return { | ||
'id': id, | ||
'created_at': createdAt?.toIso8601String(), | ||
'name': name, | ||
'authority': authority, | ||
}; | ||
} | ||
|
||
// Convert a Map object (retrieved from the database) into a Program object | ||
factory Program.fromJson(Map<String, dynamic> map) { | ||
return Program( | ||
id: map['id'] as int?, | ||
createdAt: map['created_at'] != null | ||
? DateTime.parse(map['created_at'] as String) | ||
: null, | ||
name: map['name'] as String, | ||
authority: map['authority'] as String? ?? '', | ||
); | ||
} | ||
|
||
// Override toString for easy debugging | ||
@override | ||
String toString() { | ||
return 'Program(id: $id, createdAt: $createdAt, name: $name, authority: $authority)'; | ||
} | ||
} |
Oops, something went wrong.