Skip to main content

Flutter Integration

The Azeoo SDK uses an initializeconnect flow. After connect, you can open nutrition screens via AzeooSDKModules, or embed the full UI via AzeooSDKContent.

Basic Integration

Step 1: Initialize the SDK

import 'package:flutter/widgets.dart';
import 'package:azeoo_sdk/azeoo_sdk.dart';

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

await AzeooSDK.initialize(
'your-sdk-api-key',
options: AzeooSDKInitOptions(
locale: 'en',
analyticsEnabled: true,
offlineSupport: true,
),
);
runApp(MyApp());
}

Step 2: Connect a user

After the user is authenticated in your app (e.g. your login/auth screen), call:

await AzeooSDK.connect(
token: userToken,
gender: userGender,
height: Height(userHeightCm), // defaults to centimeters
weight: Weight(userWeightKg), // defaults to kilograms
);

Un peu de contexte sur les unités (Height / Weight)

  • Imports conseillés : import 'package:azeoo_sdk/sdk/azeoo_sdk.dart'; pour Height, Weight, HeightUnit, WeightUnit.
  • Height(value, unit) encapsule une valeur numérique + une unité (HeightUnit).
  • Weight(value, unit) encapsule une valeur numérique + une unité (WeightUnit).
  • Par défaut :
    • Height(...) utilise HeightUnit.centimeters
    • Weight(...) utilise WeightUnit.kilograms

Exemple avec unités explicites :

await AzeooSDK.connect(
token: userToken,
gender: userGender,
height: Height(5.9, HeightUnit.feetInches),
weight: Weight(180, WeightUnit.pounds),
);

Step 3: Use SDK features

// Option A — Embed full SDK content
AzeooSDKContent(bottomSafeArea: true);

// Note: call `connect` before using `AzeooSDKContent` because it relies on services initialized during `connect`.

// Option B — Open module screens
AzeooSDKModules.nutrition.showMainScreen(bottomSafeArea: true);
AzeooSDKModules.nutrition.showBarcodeScanner();

Complete example

import 'package:flutter/material.dart';
import 'package:azeoo_sdk/azeoo_sdk.dart';

void main() async {
WidgetsFlutterBinding.ensureInitialized();
await AzeooSDK.initialize(
'your-sdk-api-key',
options: AzeooSDKInitOptions(
locale: 'en',
analyticsEnabled: true,
offlineSupport: true,
),
);
runApp(MyApp());
}

class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: HomeScreen(),
);
}
}

class HomeScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text('Azeoo SDK Demo')),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
ElevatedButton(
onPressed: () =>
AzeooSDKModules.nutrition.showMainScreen(
bottomSafeArea: true,
),
child: Text('Show Nutrition'),
),
ElevatedButton(
onPressed: () => Navigator.push(
context,
MaterialPageRoute(
builder: (_) => Scaffold(
body: AzeooSDKContent(),
),
),
),
child: Text('Show SDK Content'),
),
],
),
),
);
}
}

Remember to call AzeooSDK.connect(...) after the user logs in.

Next steps