Skip to content
Advertisement

Instance member can’t be accessed using static access

I hope you are all doing well !

I have ran into a problem concerning my Flutter app : I’ve been following a tutorial on Youtube on how to use sqflite in Flutter, and I couldn’t get my toMap function to work in my database class… It always returns me the error “Instance member “toMap” can’t be accessed using static access”. Does anyone know what this is about? I really don’t understand it… Thanks in advance !!

Down below, the problematic code :

poi.dart

poi_db.dart

Advertisement

Answer

You are referencing the class POI instead of the parameter poi:

You should change it to reference the parameter that you are passing in.

NOTE: I would suggest, to avoid such confusions in the future, name your classes with less abbreviation. It helps to name them as descriptively as possible. Then for instanced variables, you can use shortened notation (though I would still try to name things in a descriptive manner to how it is being used).

In this case, whatever POI stands for: Place of Interest?

Then your parameter or field could be currentPoi, activePoi, poiData, etc…

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement