Skip to Content

Flutter

Flutter plugin that wires the native Zing SDK on Android (and provides a Dart-facing API for initialization, logout, and launching native screens).

Current platform support

The Flutter plugin currently supports Android. iOS method-channel calls are not implemented yet and will return an ios_sdk_unavailable error.

Requirements

RequirementValue / Notes
Flutter3.3.0+
Android minSdk26 (Android 8.0)
Android compileSdk34+
Dependency injection (Android)Hilt
Maven credentials (Android native SDK)GitHub Packages token

Install the plugin

Add the Git dependency to your pubspec.yaml (the plugin is distributed privately and is not published on pub.dev):

dependencies: zing_sdk_initializer: git: url: https://github.com/Muze-Fitness/fitness-coach-sdk-flutter.git

Then run flutter pub get.

Android setup

To integrate on Android, you must configure your project to support the native Zing SDK dependencies (Hilt + GitHub Packages).

Add Maven repository & credentials

Add the GitHub Packages repository to your Android build (project-level android/build.gradle or settings.gradle):

maven { url = uri("https://maven.pkg.github.com/Muze-Fitness/fitness-coach-sdk-android") val localProperties = java.util.Properties() val localPropertiesFile = File(rootDir, "local.properties") if (localPropertiesFile.exists()) { localProperties.load(localPropertiesFile.inputStream()) } credentials { username = localProperties.getProperty("zing_sdk_username") password = localProperties.getProperty("zing_sdk_token") } }

Ensure your local.properties contains your credentials:

zing_sdk_username=GITHUB_USERNAME zing_sdk_token=ghp_xxx_with_read_packages

Configure Hilt (KSP or KAPT)

The native SDK uses Hilt for dependency injection.

  • Option A: KSP (recommended)
// Project-level (android/build.gradle or settings.gradle) id("com.google.dagger.hilt.android") version "2.56.1" apply false id("com.google.devtools.ksp") version "2.1.20-2.0.0" apply false
// App module (android/app/build.gradle) plugins { id("com.google.devtools.ksp") id("com.google.dagger.hilt.android") } dependencies { implementation("com.google.dagger:hilt-android:2.56.1") ksp("com.google.dagger:hilt-android-compiler:2.56.1") }
  • Option B: KAPT (legacy projects)
// Project-level (android/build.gradle or settings.gradle) id("com.google.dagger.hilt.android") version "2.56.1" apply false
// App module (android/app/build.gradle) plugins { kotlin("kapt") id("com.google.dagger.hilt.android") } dependencies { implementation("com.google.dagger:hilt-android:2.56.1") kapt("com.google.dagger:hilt-android-compiler:2.56.1") }

Custom Application class

Create an Application class extending SdkApplication and annotate it with @HiltAndroidApp:

import coach.zing.fitness.coach.SdkApplication import dagger.hilt.android.HiltAndroidApp @HiltAndroidApp class MyApplication : SdkApplication()

Register it in AndroidManifest.xml:

<application android:name=".MyApplication" ... >

Update MainActivity

Change MainActivity to inherit from FlutterFragmentActivity and add @AndroidEntryPoint:

import dagger.hilt.android.AndroidEntryPoint import io.flutter.embedding.android.FlutterFragmentActivity @AndroidEntryPoint class MainActivity : FlutterFragmentActivity()

Disable the default WorkManager initializer

Add the following provider override inside <application> in AndroidManifest.xml:

<provider android:name="androidx.startup.InitializationProvider" android:authorities="${applicationId}.androidx-startup" android:exported="false" tools:node="merge"> <meta-data android:name="androidx.work.WorkManagerInitializer" android:value="androidx.startup" tools:node="remove" /> </provider>

Health Connect (optional)

If you enable Health Connect synchronization, add the following permissions:

<uses-permission android:name="android.permission.ACTIVITY_RECOGNITION" /> <uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM" /> <uses-permission android:name="android.permission.FOREGROUND_SERVICE" /> <uses-permission android:name="android.permission.FOREGROUND_SERVICE_HEALTH" /> <uses-permission android:name="android.permission.POST_NOTIFICATIONS" /> <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />

To restart health sync after reboot, register the boot receiver inside <application>:

<receiver android:name="coach.zing.fitness.coach.broadcast.SdkHealthSyncBootReceiver" android:exported="false"> <intent-filter> <action android:name="android.intent.action.BOOT_COMPLETED" /> </intent-filter> </receiver>

Initialization

Initialize the SDK from Dart during app startup:

import 'package:zing_sdk_initializer/zing_sdk_initializer.dart'; await ZingSdkInitializer.instance.initialize();

Logout

await ZingSdkInitializer.instance.logout();

Launch native screens (Android)

await ZingSdkInitializer.instance.openScreen(ZingSdkScreen.aiAssistant);

Supported screens:

  • ZingSdkScreen.customWorkout
  • ZingSdkScreen.aiAssistant
  • ZingSdkScreen.workoutPlanDetails
  • ZingSdkScreen.fullSchedule
  • ZingSdkScreen.profileSettings
  • ZingSdkScreen.healthConnectPermissions

UI Components

The plugin provides a wrapper widget for the native Workout Plan Card (Android only):

import 'package:zing_sdk_initializer/workout_plan_card_view.dart'; Expanded( child: WorkoutPlanCardHost( unsupportedPlaceholder: Center(child: Text('Not supported')), ), )

Notes

  • This plugin does not yet configure iOS; iOS calls currently return ios_sdk_unavailable.
  • Configure auth/tokens as described in Authorization before launching UI.
Last updated on