I’m using some sqflite to do a query on a database, and extract a specific name of a table, for example: I have 3 names, Roberto, Ricardo and Andres, and I want to obtain only the name of Roberto, so this is what im doing:
loginLogic() async {
var X = 'Roberto';
final db = await database;
List<Map> result = await db.rawQuery('SELECT * FROM Usuario WHERE username=?', [X]);
So now, I want to compare this result with another one to do an "if" function, just like this:
if(result==X){
return 1;
} else {
return 0;
}
But this is what flutter says:
List<Map<dynamic, dynamic>> result
Equality operator '==' invocation with references of unrelated
And the Debug console:
type 'Future<dynamic>' is not a subtype of type 'int'
So I need a way to compare the value that results from the list of users with the string with the variable I declarated 'X'.
Try using the reference of this problem
This is what I’ve tried:
loginLogicpar() async {
var X = 'Giova';
final db = await database;
final result = await db.rawQuery('SELECT * FROM Usuario WHERE username=?', [X]);
return result;
}
loginLogic() async {
var X = 'Giova';
final user = await loginLogicpar();
if(user==X){
return 1;
}
return 0;
}
And returns the exact same result: type 'Future' is not a subtype of type 'int'
Added the code so you can replicate it, just be sure you have sqflite on your depenencies.