sqflite-platform-interface-implementers

Implements and registers platform implementations of the sqflite federated Flutter plugin.

3.0k|555|Updated May 22, 2017
One-click install
npx skills add https://github.com/tekartik/sqflite --skill sqflite-platform-interface-implementers-tekartik
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: sqflite-platform-interface-implementers
Source: https://github.com/tekartik/sqflite/tree/main/sqflite_platform_interface/skills/sqflite-platform-interface-implementers
Command: npx skills add https://github.com/tekartik/sqflite --skill sqflite-platform-interface-implementers-tekartik

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing a new platform implementation of the sqflite SQLite plugin (a new sqflite_<platform> package or a custom DatabaseFactory) requires correctly wiring SqflitePlatform, the dartPluginClass registerWith() hook, and the com.tekartik.sqflite method channel protocol, and mistakes cause runtime failures like uninitialized databaseFactory errors. ## Core Features & Use Cases - Platform Implementation Guidance: Explains how to extend SqflitePlatform, declare dartPluginClass in pubspec.yaml, and register via registerWith() so Flutter installs the factory before main(). - Factory Registration Paths: Covers both the method channel route (initWithDatabaseFactoryMethodChannel) and Dart-side factories built with buildDatabaseFactory from sqflite_common. - Error Protocol Compliance: Documents the sqlite_error PlatformException code convention so native errors surface as DatabaseException. - Use Case: You are porting sqflite to a new OS: create an sqflite_myos package, implement the native method channel, and register it with a dartPluginClass following this guidance. ## Quick Start Ask the AI to scaffold a new sqflite platform implementation package for your target platform with the correct pubspec plugin declaration and registerWith() method.

Frequently Asked Questions about sqflite-platform-interface-implementers

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I implement a sqflite platform plugin for a new platform?▼

Create a package extending SqflitePlatform with a static registerWith() method, declare it as dartPluginClass under flutter plugin platforms in pubspec.yaml, and call SqflitePlatform.initWithDatabaseFactoryMethodChannel() if your native side implements the com.tekartik.sqflite method channel protocol.

How do I register a custom DatabaseFactory in sqflite?▼

Assign it with SqflitePlatform().databaseFactory = factory or the databaseFactory setter from package:sqflite_common. The factory must be a real sqflite implementation built with buildDatabaseFactory or SqfliteDatabaseFactoryMixin; a plain class implementing DatabaseFactory is rejected.

Should my Flutter app depend on sqflite_platform_interface?▼

No, applications should depend on package:sqflite, which declares sqflite_android and sqflite_darwin as default implementations. The platform interface package is only for implementation packages, not app code.

Why does openDatabase throw StateError databaseFactory not initialized?▼

This happens when registerWith() never runs, usually because dartPluginClass is missing from the implementation package's pubspec.yaml. Flutter calls registerWith() before main() only when dartPluginClass is declared.

Why do native sqflite errors surface as PlatformException instead of DatabaseException?▼

The method channel factory only converts PlatformExceptions whose code is sqlite_error into DatabaseException. Native code must use that code and pass the SQL and arguments in details for getResultCode() and toString() to work.