![]() ![]() This code will select rows in the 'myTable' table where the 'name' column is 'John' and return each row as a 'Map' object.ĭata deletion is done using the 'delete' method:Īwait lete('myTable', where: 'name = ?', whereArgs: ) This object contains the name and value of each column.įinal List> rows = await database.query('myTable', where: 'name = ?', whereArgs: ) This code will select all rows in the 'myTable' table and return each row as a 'Map' object. This code will update the 'value' column of the rows where the 'name' column is 'John' in the 'myTable' table to '30'.ĭata querying is done using the 'query' method:įinal List> rows = await database.query('myTable') OnCreate: (Database db, int version) async, where: 'name = ?', whereArgs: ) You can use the following code to create the database file:įinal Database database = await openDatabase(path, version: 1, This code will create an SQLite database file named myDatabase.db and store it in the device's native database directory. Then, specify the path of the folder where the database file will be created:įinal String databaseName = 'myDatabase.db' įinal String databasePath = await getDatabasesPath() įinal String path = join(databasePath, databaseName) To create a database, first, include the sqflite package in your project: Then, run the flutter pub get command in the terminal to reload your project. To include the sqflite package in your project, open your pubspec.yaml file and add the following code: In this post, we will use the sqflite package. In this blog post, you will learn the steps to create an application using native SQLite database in Flutter.įlutter provides many packages to use SQLite database. ![]() SQLite database is preferred by many mobile applications because it is lightweight, portable, and scalable. Flutter satisfies this need by using the native SQLite database. Many applications require managing data stored in a local database. Flutter is a fast, modern, and performance-focused mobile app development framework. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |