Flutter
Dart package mealio_sdk. iOS and Android. Built on webview_flutter.
Install
pubspec.yaml
dependencies:
mealio_sdk: ^0.1.0Configure and place the scope
MealioScope hosts the store session WebView. Place it once, above your pages.
main.dart
final navigatorKey = GlobalKey<NavigatorState>();
void main() {
MealioCart.configure(
publishableKey: 'pk_live_...',
sessionTokenProvider: () => myApi.fetchMealioSessionToken(), // calls your server
);
runApp(MaterialApp(
navigatorKey: navigatorKey,
builder: (context, child) => MealioScope(navigatorKey: navigatorKey, child: child!),
home: const RecipePage(),
));
}Fill a cart
Dart
try {
final session = await MealioCart.instance.prepareCart(
store: 'heb',
zip: '78704',
recipe: const Recipe(id: 'tinga', title: 'Chicken Tinga', ingredients: [
RecipeIngredient(name: '1 yellow onion'),
RecipeIngredient(name: 'corn tortillas'),
]),
);
// Your own UI: session.needsChoice, session.choose(key, productId), session.addToCart()
// Or the ready-made sheet:
final result = await MealioCartSheet.show(context, session);
} on MealioException catch (e) {
// e.code: login_cancelled, store_unavailable, location_required, ...
}Sign out
Dart
await MealioCart.instance.signOutOfAllStores();webview_flutter cannot clear one site's cookies, so signOutOfStore clears every WebView cookie in your app. Stores that offer "Sign in with Google" need email and password, because Google blocks its sign-in inside embedded WebViews.