Search code examples
fluttersqflite

How To get Sqlite Values on Load


I'm trying the following:

Get the Data.lenght from a DB and conditionally due result load on component or another...

I tryed to run it on InitState yet what I get is a Future instance of my DBProvider. any suggestions?


Solution

  • The Solution I have found is to Call the Function on the InitState... (I was doing this before) yet is important to catch the result of this after the process is done, you can do this add .then(result) to the async funcion. Like in the Example.

     void initState() {
        super.initState();
        CheckCarritoStatus().then((result){
          setState(() {
            _CarritoStatus = result;
          });
        });
      }