giandifra / clustering_google_maps

A Flutter package that recreate clustering technique in a Google Maps widget

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

openDatabase() return null.

maxouille opened this issue · comments

Hi !

I'm using your library and I have a problem with the _init() method. In this method, _database is null at the end and I get an error while aggregating.

The code of the _init():

Future _init() async {
    print("AppDatabase: init database");
    // Get a location using path_provider
    Directory documentsDirectory = await getApplicationDocumentsDirectory();
    String path = join(documentsDirectory.path, "wily.db");
    print(path);
    _database = await openDatabase(path, version: 1,
        onCreate: (Database db, int version) async {
          // When creating the db, create the table
          await _createToiletTable(db);
        }, onUpgrade: (Database db, int oldVersion, int newVersion) async {
          await db.execute("DROP TABLE TOILETS_TABLE");
          await _createToiletTable(db);
        });
  }

The logs (btw it's doing aggregation twice) :

`I/flutter ( 9389): loading aggregation
I/flutter ( 9389): --------- START QUERY AGGREGATION
I/flutter ( 9389): Exception: Database must not be null
I/flutter ( 9389): --------- COMPLETE QUERY AGGREGATION WITH ERROR
I/flutter ( 9389): aggregation lenght: 0
W/System  ( 9389): A resource failed to call release. 
I/flutter ( 9389): rebuild
I/flutter ( 9389): loading aggregation
I/flutter ( 9389): --------- START QUERY AGGREGATION
I/flutter ( 9389): --------- COMPLETE QUERY AGGREGATION
I/flutter ( 9389): aggregation lenght: 0`

EDIT : FORGOT TO POPULATE DB -_- Problem solved. Can delete this stupid post.