Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Future<List<List<Widget>>> getList(List<int> list, String column) async {
- List<Widget> list1 = List();
- List<Widget> list2 = List();
- List<Widget> list3 = List();
- List<List<Widget>> listFromDB = [list1, list2, list3];
- var databasesPath = await getDatabasesPath();
- String path = join(databasesPath, 'books.db');
- Database database = await openDatabase(path, version: 1);
- for (int i = 0; i < list.length; i++) {
- var result = await database
- .rawQuery('SELECT DISTINCT $column FROM $booksTable WHERE $colId= ${list[i]}');
- debugPrint('List: ' +list[i].toString());
- if (list[i] < 18) list1.add(_item(result[0][column].toString()));
- if (list[i] > 17 && list[i] < 50)
- list2.add(_item(result[0][column].toString()));
- if (list[i] > 49) list3.add(_item(result[0][column].toString()));
- }
- // await database.close();
- return listFromDB;
- }
- bool _summary = false;
- _getAnswer() async{
- SharedPreferences pref = await SharedPreferences.getInstance();
- List<String> listString = pref.getStringList('Answers') ?? List();
- if(listString.isNotEmpty){
- List<int> listInt = listString.map(int.parse).toList();
- listInt.sort();
- _list = await DB().getList(listInt, _summary ? 'Detail' : 'Output'); //colums from db.
- setState((){});
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement