搜索分类、插件与代码仓

插件详情v3.8.0

sqlite3

通过使用 dart:ffi 提供轻量但便捷的 SQLite 绑定

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
345万
喜欢数
465
Pub 分数
150

安装插件

flutter pub add sqlite3

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

sqlite3 包通过 Dart 的 FFI(外部函数接口)提供了轻量级且便捷的 SQLite 绑定,实现了跨多个平台的高效原生数据库访问。该包专为需要可靠嵌入式 SQL 数据库解决方案但又不想承担复杂抽象开销的开发者设计。它支持 Android、iOS、Web、macOS、Windows 和 Linux,非常适合需要本地数据持久化并具备完整 SQL 支持的跨平台应用。

适合场景

  • 移动应用中的离线数据存储
  • 跨平台桌面和Web应用程序
  • Flutter 项目中的轻量级数据库需求
  • 实时数据同步与本地缓存
  • 在无服务器函数中嵌入 SQL 功能

主要特点

  • 通过 dart:ffi 实现原生性能
  • 完整的 SQL 支持,包括事务
  • 跨平台兼容性
  • 最小内存占用
  • 与 Flutter 的轻松集成
  • 支持预处理语句和参数化查询

适合对象

  • 需要快速、低级别 SQLite 访问的开发人员
  • 需要离线优先功能的项目
  • 数据库使用中等至较高的应用
  • 偏好最小依赖项的团队
  • Flutter 应用针对多个平台

使用建议

  • 需要熟悉 SQLite 和 SQL
  • 与ORM库相比,高级抽象功能有限
  • 手动管理连接和资源
  • 不建议在未优化的情况下用于非常大的数据集
  • 由于 JS 互操作性限制,Web 上可能需要额外设置

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

sqlite3.dart

This project contains Dart packages to use SQLite from Dart via dart:ffi.

The main package in this repository is sqlite3, which contains all the Dart apis and their implementation. package:sqlite3 is a pure-Dart package without a dependency on Flutter. It can be used both in Flutter apps or in standalone Dart applications.

package:sqlite3_test contains utilities that make integrating SQLite databases into Dart tests easier. In particular, they patch CURRENT_TIMESTAMP and related constructs to return the (potentially faked) time returned by package:clock.

package:sqlite3_web contains helpers for running SQLite on the web, including code to compile web workers that help with the process.

package:sqlite3_connection_pool provides an asynchronous connection pool for SQLite that works well across isolates.

Example Usage

A file with basic usage examples for pure Dart can be found here.

所属分类

依赖

依赖清单 10 项

源码仓库

使用此插件的项目