to select ↑↓ to navigate
mForm Docs

mForm Docs

Open in ChatGPT
Ask ChatGPT about this page
Open in Claude
Ask Claude about this page

Configure the client

The SDK reads its setup from an AppConfig object you build once at startup.

AppConfig

final appConfig = AppConfig(
  baseUrl: 'https://your-site.com/',   // trailing slash required
  appName: 'Your App',
  appVersion: '1.0.0',
  packageName: 'com.yourcompany.yourapp',
  homeScreenLayout: 'list',            // or 'folder'
  oauthClientId: config.AppConstants.oauthClientId,
  oauthClientSecret: config.AppConstants.oauthClientSecret,
);

packageName and appVersion should match what Mobile Configuration on the server expects. See App status and force-update.

Keep real config out of git

Commit a template, gitignore the real file:

lib/config/app_config.example.dart   # committed
lib/config/app_config.dart           # gitignored, holds real values

Initialize the SDK

void main() async {
  WidgetsFlutterBinding.ensureInitialized();

  final sdk = FrappeSDK(baseUrl: 'https://your-frappe-site.com/');
  await sdk.initialize(true);

  runApp(MyApp(sdk: sdk));
}

The trailing slash on baseUrl is required. initialize(true) tries to restore a previous session and runs the initial sync if one is found.

After login

Two calls run right after a successful login, whichever screen triggers it:

onLoginSuccess: () async {
  await sdk.checkAndSyncDoctypes();
  await sdk.resyncMobileConfiguration();
},

checkAndSyncDoctypes pulls metadata for every doctype the app needs. resyncMobileConfiguration re-reads Mobile Configuration from the server, which is what re-promotes a doctype that got demoted mid-session. See Ready-made screens for what demotion means.

Last updated 1 month ago
Was this helpful?
Thanks!