pocketbase_server_flutter 1.1.0 copy "pocketbase_server_flutter: ^1.1.0" to clipboard
pocketbase_server_flutter: ^1.1.0 copied to clipboard

Start Pocketbase Server directly from Android/IOS with flutter

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",
);
copied to clipboard

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,
);
copied to clipboard

Stop pocketbaseServer

PocketbaseServerFlutter.stop();
copied to clipboard

Listen to pocketbaseServer events, setup eventCallback

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

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
copied to clipboard

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>
copied to clipboard
  • 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

26
likes
150
points
44
downloads

Publisher

verified publisherrohitsangwan.in

Weekly Downloads

2024.10.05 - 2025.04.19

Start Pocketbase Server directly from Android/IOS with flutter

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, network_info_plus

More

Packages that depend on pocketbase_server_flutter