// 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