{"id":20517141,"url":"https://github.com/rhedgpeth/flutter-sqlite","last_synced_at":"2025-09-25T11:30:32.863Z","repository":{"id":74729794,"uuid":"460154985","full_name":"rhedgpeth/flutter-sqlite","owner":"rhedgpeth","description":"This repository contains a simple Flutter application that manages contact information using SQLite (via SQFLite).","archived":false,"fork":false,"pushed_at":"2022-04-07T20:02:12.000Z","size":1220,"stargazers_count":3,"open_issues_count":0,"forks_count":4,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-11-15T21:35:17.149Z","etag":null,"topics":["android","android-app","android-sqlite","bitrise","bitrise-flutter","cicd","dart","dart-flutter","flutter","flutter-apps","flutter-examples","flutter-sqflite","flutter-sql","flutter-sqlite","ios","ios-app","ios-sqlite","mobile","mobile-app","quickstart"],"latest_commit_sha":null,"homepage":"","language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rhedgpeth.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-02-16T19:48:40.000Z","updated_at":"2024-05-15T01:37:39.000Z","dependencies_parsed_at":null,"dependency_job_id":"cf458a5f-d6d6-4757-b952-84f08f66cc43","html_url":"https://github.com/rhedgpeth/flutter-sqlite","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rhedgpeth%2Fflutter-sqlite","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rhedgpeth%2Fflutter-sqlite/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rhedgpeth%2Fflutter-sqlite/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rhedgpeth%2Fflutter-sqlite/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rhedgpeth","download_url":"https://codeload.github.com/rhedgpeth/flutter-sqlite/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234178691,"owners_count":18791779,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","android-app","android-sqlite","bitrise","bitrise-flutter","cicd","dart","dart-flutter","flutter","flutter-apps","flutter-examples","flutter-sqflite","flutter-sql","flutter-sqlite","ios","ios-app","ios-sqlite","mobile","mobile-app","quickstart"],"created_at":"2024-11-15T21:34:02.577Z","updated_at":"2025-09-25T11:30:32.474Z","avatar_url":"https://github.com/rhedgpeth.png","language":"Dart","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Flutter + SQLite \n\n![Build status](https://app.bitrise.io/app/a3e6d55c1d6ee760/status.svg?token=wqZw6gGe-o-P4SLLYl1Caw) [![License (MIT)][licence-image]][licence-url]\n\nThis repository contains a simple [Flutter](https://flutter.dev/) application that manages contact information using [SQLite](https://www.sqlite.org/index.html) (via [SQFLite](https://pub.dev/packages/sqflite)).\n\n\u003cp align=\"center\" spacing=\"10\"\u003e\n    \u003ckbd\u003e\n        \u003cimg src=\"media/demo.gif\" /\u003e\n    \u003c/kbd\u003e\n\u003c/p\u003e\n\n## Requirements \n\nTo run this application be sure to check out [the Flutter documentation](https://docs.flutter.dev/get-started/install) for getting started. \n\n## Key takeaways \n\nTo use SQLite within a Flutter application you're going to need to add a couple dependencies to the [pubspec.yaml](src/pubspec.yaml) file.\n\n\u003e Note: The [Dart](dart.dev) ecosystem uses packages to manage shared software such as libraries and tools. To get Dart packages, you use the pub package manager. Find more information on Dart package management [here](https://dart.dev/guides/packages).\n\nMore specifically, the [sqflite](https://pub.dev/packages/sqflite) and [path_provider](https://pub.dev/packages/path_provider) packages are required.\n\n```yaml\ndependencies:\n  flutter:\n    sdk: flutter\n  sqflite: any\n  path_provider: any\n```\n\nFrom there a SQLite database (and tables) can be created and used within the application. \n\nFor this applicaiton I have put all of the SQFLite usages within [database_helper.dart](src/lib/data/database_helper.dart).\n\n```dart\nimport 'dart:async';\nimport 'dart:io' as io;\nimport 'package:path/path.dart';\nimport 'package:path_provider/path_provider.dart';\nimport 'package:rolodex/models/base_model.dart';\nimport 'package:sqflite/sqflite.dart';\n\nclass DatabaseHelper {\n  static final DatabaseHelper _instance = DatabaseHelper.internal();\n\n  factory DatabaseHelper() =\u003e _instance;\n\n  static Database? _db;\n\n  Future\u003cDatabase\u003e get db async {\n    _db ??= await init();\n    return _db!;\n  }\n\n  DatabaseHelper.internal();\n\n  Future\u003cDatabase\u003e init() async {\n      io.Directory documentsDirectory = await getApplicationDocumentsDirectory();\n      String path = join(documentsDirectory.path, \"main.db\");\n      return openDatabase(path, version: 1, onCreate: onCreate);\n  }\n\n  void onCreate(Database db, int version) async =\u003e\n      await db.execute('CREATE TABLE contacts (id INTEGER PRIMARY KEY NOT NULL, firstName STRING, lastName STRING, phone STRING, email STRING)');\n\n  Future\u003cList\u003cMap\u003cString, dynamic\u003e\u003e\u003e query(String table) async =\u003e (await db).query(table);\n\n  Future\u003cint\u003e insert(String table, BaseModel model) async =\u003e (await db).insert(table, model.toMap());\n\n  Future\u003cint\u003e update(String table, BaseModel model) async =\u003e (await db).update(table, model.toMap(), where: 'id = ?', whereArgs: [model.id]);\n\n  Future\u003cint\u003e delete(String table, BaseModel model) async =\u003e (await db).delete(table, where: 'id = ?', whereArgs: [model.id]);\n}\n```\n\n## Questions / Feedback\n\nIf you have any questions or feedback for this sample please feel free to submit an issue here or email me at rob.hedgpeth@gmail.com. \n\nHappy coding!\n\n[bitrise-image]:https://travis-ci.com/mariadb-corporation/mariadb-connector-nodejs.svg?branch=master\n[travis-url]:https://app.travis-ci.com/github/mariadb-corporation/mariadb-connector-nodejs\n[licence-image]:https://img.shields.io/badge/License-MIT-blue.svg?style=plastic\n[licence-url]:https://opensource.org/licenses/MIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frhedgpeth%2Fflutter-sqlite","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frhedgpeth%2Fflutter-sqlite","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frhedgpeth%2Fflutter-sqlite/lists"}