Last active
April 9, 2019 13:43
-
-
Save ashishrawat2911/333a6b650568b9b59468a2e70e33175b to your computer and use it in GitHub Desktop.
This file contains hidden or 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
//return all persons from the database | |
Future<List<Person>> getAllPersons() async { | |
final db = await database; | |
var response = await db.query("Person"); | |
List<Person> list = response.map((c) => Person.fromMap(c)).toList(); | |
return list; | |
} | |
//return single person with id | |
Future<Person> getPersonWithId(int id) async { | |
final db = await database; | |
var response = await db.query("Person", where: "id = ?", whereArgs: [id]); | |
return response.isNotEmpty ? Person.fromMap(response.first) : null; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment