Run Pocketbase Server directly from Android/IOS with flutter
Checkout Pocketbase Server example app
PocketbaseServerFlutter.start(
superUserEmail: "test@user.com",
superUserPassword: "password",
hostName: await PocketbaseServerFlutter.localIpAddress,
port: "8080",
);
// 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
- 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
Built with: pocketbase_mobile
This is for running Pocketbase server from mobile, to connect with pocketbase server, use official pocketbase client plugin