Flutter SDK · Preview
Events and identity
Track custom events, screens and the ecommerce journey, and connect app activity to known customers on Flutter.
Preview: planned API
The Flutter SDK is in development and not published yet. This page describes the API we are building so you can plan your integration. Package names, signatures and defaults may still change before the first release.
Custom events and screens
Event names are lowercase snake_case, the same rule as the Web SDK. Properties accept strings, numbers, booleans, null and nested lists or maps.
Rtn.track('filter_applied', {
'filter': 'color',
'value': 'black',
});
Rtn.screen('Product detail', {'product_id': 'sku_123'});Automatic screens
Add RtnNavigatorObserver to your MaterialApp to send screen_viewed for every named route. With go_router, pass it to GoRouter(observers: [...]).
MaterialApp(
navigatorObservers: [RtnNavigatorObserver()],
routes: routes,
);Properties on every event
Registered properties are added to every following event until you remove them. Event properties win when both set the same key.
Rtn.register({'app_theme': 'dark'});
Rtn.unregister('app_theme');Ecommerce journey
The ecommerce helpers send the same events as the Web SDK (product_viewed, product_added_to_cart, cart_viewed, checkout_started, order_completed and more), so web and app journeys appear side by side in reports and segments. The product fields and their rules are the same as in Ecommerce Events.
const product = RtnProduct(
productId: 'sku_123',
variantId: 'sku_123_black',
name: 'Everyday Backpack',
brand: 'Northwind',
category: 'Bags',
price: 89.90,
currency: 'USD',
);
Rtn.productViewed(product);
Rtn.productAddedToCart(product.copyWith(quantity: 2), cartId: 'cart_456');
Rtn.checkoutStarted(cart);
Rtn.orderCompleted(order);Identify customers
Call identify after sign-in or sign-up. Earlier anonymous events on this device are linked to the customer, and their web activity is merged when the same customer ID or email is used on your site.
// After sign-in or sign-up
await Rtn.identify('user_123', traits: {
'email': 'ada@example.com',
'first_name': 'Ada',
});
// Guest checkout: traits only
await Rtn.identifyTraits({'email': 'guest@example.com'});
// At sign-out
await Rtn.reset();