搜尋套件、儲存庫與 APP 分類

套件詳情v1.1.0

pocketbase_server_flutter

直接從 Android/iOS 使用 Flutter 啟動 Pocketbase 伺服器

AndroidiOSWebmacOSWindowsLinux
近 30 天下載
138
喜歡數
35
Pub 分數
130

安裝套件

flutter pub add pocketbase_server_flutter

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

pocketbase_server_flutter 套件讓開發者能在 Android、iOS、Web、macOS、Windows 與 Linux 上的 Flutter 應用中直接啟動 PocketBase 伺服器。它透過將資料庫伺服器內嵌於應用中,簡化後端設定,非常適合原型設計、本機開發或輕量級後端需求。該套件為各平台使用原生二進位檔,確保相容性與效能。對於需要即時資料、驗證與檔案儲存卻無需外部伺服器基礎設施的應用尤為實用。

適用情境

  • 使用嵌入式後端進行Flutter應用的本地開發
  • 快速原型開發全棧應用程式
  • 具有同步功能的離線優先應用程式
  • 演示全棧Flutter的教育專案
  • 帶有內建資料庫的簡單 CRUD 應用

主要特色

  • 在 Flutter 應用中嵌入 PocketBase 伺服器
  • 支援所有主要平台,包含行動裝置與桌面端
  • 自動化伺服器啟動與管理
  • 即時資料庫和驗證
  • 輕量且易於整合

適合對象

  • Flutter 開發人員建構全端應用
  • 初學者學習後端整合
  • 團隊快速原型開發MVP
  • 需要本地資料庫和即時功能的專案
  • 需要最少伺服器維護的應用程式

使用建議

  • 不適合用於生產規模的部署
  • 由於捆綁了伺服器二進位檔,應用程式大小增加
  • 需要仔細處理伺服器生命週期
  • 與雲端主機解決方案相比,可擴展性有限
  • 如果公開暴露,可能存在安全風險

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

Pocketbase Server Flutter

pocketbase_server version

Run Pocketbase Server directly from Android/IOS with flutter

Screenshot 2023-09-16 at 12 09 12 PM

Usage

Checkout Pocketbase Server example app

Start pocketbaseServer
PocketbaseServerFlutter.start(
  superUserEmail: "test@user.com",
  superUserPassword: "password",
  hostName: await PocketbaseServerFlutter.localIpAddress,
  port: "8080",
);
Advanced Usage
// Get path to load resources using `path_provider`
final Directory staticDir = await getTemporaryDirectory();

// Directory to load static files (Optional)
final String staticFolder = "${staticDir.path}/pb_static/";

// Directory to load js hook files (Optional)
final String hooksFolder = "${staticDir.path}/pb_hooks/";

// Directory to save sqlite files and default data
final String dataFolder = "${staticDir.path}/pb_data/";

// add `pb_static` and `pb_hooks` folder in assets of your project, and load all files from assets to given path
await PocketbaseServerFlutter.copyAssetsFolderToPath(
  path: staticFolder,
  assetFolder: "pb_static",
  overwriteExisting: true,
)

await PocketbaseServerFlutter.copyAssetsFolderToPath(
  path: hooksFolder,
  assetFolder: "pb_hooks",
  overwriteExisting: true,
);

PocketbaseServerFlutter.start(
  superUserEmail: "test@user.com",
  superUserPassword: "password",
  hostName: await PocketbaseServerFlutter.localIpAddress,
  port: "8080",
  enablePocketbaseApiLogs: true,
  dataPath: dataFolder,
  staticFilesPath: staticFolder,
  hookFilesPath: hooksFolder,
);

Stop pocketbaseServer

PocketbaseServerFlutter.stop();

Listen to pocketbaseServer events, setup eventCallback

PocketbaseServerFlutter.setEventCallback(
    callback: (event, data){
        // Handle event and data
    },
);

Some helper methods

// To check if pocketBase is running (not reliable)
PocketbaseServerFlutter.isRunning

// To check pocketbaseMobile version
PocketbaseServerFlutter.pocketbaseMobileVersion

// To get the ipAddress of mobile ( to run pocketbase with this hostname )
PocketbaseServerFlutter.localIpAddress

Mobile Setup

  • IOS

If getting error related to Undefined symbol, Make sure to run pod install on ios directory, open IOS project in XCode

Click on Pods, Then select pocketbase_server_flutter from Targets list, and select Build Phases

Screenshot 2023-09-16 at 11 19 30 AM

Then in Link Binary With Libraries section, click on + button and search for libresolv.tbd and choose from result and click on Add

image

  • Android

Should work out of the box

Desktop Setup

Desktop requires pocketbaseExecutable path in start()

To get pocketbaseExecutable in app, add the executable in Assets and on runtime copy it from assets to another path using path_provider Or download the executable on Runtime

  • MacOS

Edit your Runner/**.entitlements file

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
	<dict>
		<key>com.apple.security.app-sandbox</key>
		<false />
		<key>com.apple.security.cs.allow-jit</key>
		<true />
		<key>com.apple.security.network.client</key>
		<true />
		<key>com.apple.security.network.server</key>
		<true />
	</dict>
</plist>
  • Windows, Linux

Should work out of the box

Resources

https://pocketbase.io/

Built with: pocketbase_mobile

Note

This is for running Pocketbase server from mobile, to connect with pocketbase server, use official pocketbase client plugin

所屬分類

依賴

依賴清單 1 項

原始碼儲存庫

使用此套件的專案

暫無相關資料。