How to use local Sqlite database efficiency in Dart/Flutter

252

Solution 1

you can try Hive or Objectbox. Both of them are local DB that easy to use and also faster than SQFLite.

If you want to learn more about Hives, you can learn here

If you want to learn more about Objectbox, you can learn here

this is the database performance benchmark between Hive, Objectbox, and SQFLite (image source: link) image

I have try both hive and objectbox. Its recommended for you if you have a complex data and want to solve the storing problem.

Goodluck, hope it helps!

Solution 2

Its better if you use Hive, its a local DB that will let you solve your complex data problem. Super easy and works much faster than SQflite

Things you need:

And of course some tutorial as well. So,

Cheers and good luck!

Share:
252
Littlepea
Author by

Littlepea

Updated on December 02, 2022

Comments

  • Littlepea
    Littlepea over 1 year

    I'm a newbie in flutter and android application. I have developed a quiz app. It loading a Json data from Firebase and i want to save it to Sqlite(for query fast purpose). My problem is Json data quite complicated, it have multi data array nested(refer Json data as bellow)

    Since Sqlite doesn't allow nesting tables within tables, I not sure how to organize or convert the data to Sqlite most reasonable. I am thinking of saving all my Json as a String, but I know it not a good idea. Any have a better idea, very appreciate it

    {
        "title": "TEST title",
        "des": null,
        "ver": 0,
        "partOne": [
            {
                "number": 1,
                "correctAns": 3,
                "question": "question 1 here?",
                "ansA": "answer A here",
                "ansB": "answer B here",
                "ansC": "answer C here",
                "ansD": "answer D here"
            },
            // about 100 question
            ...
        // about 100 part
        ...
        ]
    }
    
  • Littlepea
    Littlepea over 2 years
    Hi Hamza, thank for your sharing, I'll try to do it.
  • Littlepea
    Littlepea about 2 years
    Hi, I tried Hive as Hamza recommended, it seem quite fitting with my project. I'll try objectbox another time. Thank for your sharing.