on passing the version to the on create method and integer(int) of the id that i want to fetch from the database,i get an error saying "int isn't a type"error Image
class NewsDbProvider {
Database db;
int() async {
Directory documentsDirectory =await getApplicationDocumentsDirectory();
final path = join(documentsDirectory.path, "items.db");
db = await openDatabase(
path,
version: 1,
onCreate: (Database newDb,int version){
newDb.execute("""
CREATE TABLE Items
(
)
""");
}
);
}
fetchItem(int id) async{
db.query(
"Items",
columns: null,
where: 'id = ?',
whereArgs: {id},
);
}
}
Yes, Dart's int type is a "reference type". Dart does not have value types at all, all values are instances of a class, including integers.
To Solve type 'int' is not a subtype of type 'String' error in Dart Error is saying you are passing String where flutter required for the Integer value. So that you have to pass Integer there Or you can just use our solutions to solve this error.
Covariant is a fancy type theory term, but it basically means 'this class or its subclasses'. You are explicitly telling Dart to tighten the type checking of this argument to a subclass of the original.
You named a method of NewsDbProvider
as int
, which is why the keyword isn't being recognised anymore. Try renaming it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With