int isn't a type

1,016

You named a method of NewsDbProvider as int, which is why the keyword isn't being recognised anymore. Try renaming it.

Share:
1,016
user8273163
Author by

user8273163

Updated on December 12, 2022

Comments

  • user8273163
    user8273163 over 1 year

    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},
        );
      }
    }
    
  • user8273163
    user8273163 almost 5 years
    Thanks, i nearly pulled my hair out. Clumsy me