Sqlite in flutter, how database assets work

前端 未结 3 612
日久生厌
日久生厌 2020-12-01 11:45

I am looking at this (https://github.com/tekartik/sqflite/blob/master/doc/opening_asset_db.md) for populating data that is already formatted and need for the app, for read f

3条回答
  •  情话喂你
    2020-12-01 12:13

    Add the asset in your file system at the root of your project. Create an assets folder and put your db file in it:

    assets/examples.db
    

    Specify the asset(s) in your pubspec.yaml in the flutter section

    flutter:
    
      assets:
    
        - assets/example.db
    

    Then you will need to open the database if it exists, or copy if it doesn't.

    The link here shows the code to open/copy a pre-existing sqlite database:

    https://github.com/tekartik/sqflite/blob/master/sqflite/doc/opening_asset_db.md

提交回复
热议问题