pocketbase_server_flutter 패키지는 Android, iOS, Web, macOS, Windows 및 Linux에서 Flutter 애플리케이션 내부에 PocketBase 서버를 직접 실행할 수 있도록 해줍니다. 데이터베이스 서버를 앱에 내장함으로써 백엔드 설정을 간소화하며, 프로토타이핑, 로컬 개발 또는 가벼운 백엔드 요구 사항에 이상적입니다. 각 플랫폼용 네이티브 바이너리를 활용하여 호환성과 성능을 보장합니다. 외부 서버 인프라 없이 실시간 데이터, 인증 및 파일 저장 기능이 필요한 앱에 특히 유용합니다.
사용 사례
임베디드 백엔드를 사용한 Flutter 앱 로컬 개발
빠른 전체 스택 앱 프로토타이핑
동기화 기능을 갖춘 오프라인 우선 애플리케이션
풀스택 플러터를 보여주는 교육 프로젝트
내장 데이터베이스를 갖춘 간단한 CRUD 앱
주요 기능
Flutter 앱에 PocketBase 서버를 내장합니다
모바일 및 데스크톱을 포함한 모든 주요 플랫폼을 지원합니다
서버 자동 시작 및 관리
실시간 데이터베이스 및 인증
경량이며 통합이 쉬움
적합한 대상
플러터 개발자가 전체 스택 앱을 구축하고 있습니다
초보자가 백엔드 통합을 배우는 중
팀이 빠르게 MVP 프로토타입을 제작한다
로컬 데이터베이스와 실시간 기능이 필요한 프로젝트
최소한의 서버 유지보수를 필요로 하는 앱
고려 사항
생산 규모 배포에는 적합하지 않습니다
통합된 서버 바이너리로 인한 앱 크기 증가
서버 라이프사이클을 신중하게 다뤄야 합니다
클라우드 호스팅 솔루션과 비교해 확장성 제한
공개적으로 노출될 경우 보안 위험이 발생할 수 있습니다
원본 README
연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.
Pocketbase Server Flutter
Run Pocketbase Server directly from Android/IOS with flutter
// Get path to load resources using `path_provider`finalDirectory staticDir = awaitgetTemporaryDirectory();
// Directory to load static files (Optional)finalString staticFolder = "${staticDir.path}/pb_static/";
// Directory to load js hook files (Optional)finalString hooksFolder = "${staticDir.path}/pb_hooks/";
// Directory to save sqlite files and default datafinalString 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 pathawaitPocketbaseServerFlutter.copyAssetsFolderToPath(
path: staticFolder,
assetFolder: "pb_static",
overwriteExisting: true,
)
awaitPocketbaseServerFlutter.copyAssetsFolderToPath(
path: hooksFolder,
assetFolder: "pb_hooks",
overwriteExisting: true,
);
PocketbaseServerFlutter.start(
superUserEmail: "test@user.com",
superUserPassword: "password",
hostName: awaitPocketbaseServerFlutter.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 versionPocketbaseServerFlutter.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
Then in Link Binary With Libraries section, click on + button and search for libresolv.tbd and choose from result and click on Add
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