Skip to main content

Flutter SDK

B2Metric Flutter SDK 1.0.0 documentation.

📄️ Lifecycle Management

The SDK manages most of its own lifecycle automatically: it starts a background worker on init, batches events, sends them periodically, persists anything that can't be delivered, and resumes when the device comes back online. For the vast majority of integrations you do not need to think about lifecycle at all. The two methods documented in this section exist for the cases where you do — when a critical event must be sent immediately, or when you want to tear the SDK down cleanly at sign-out.

📄️ Complete Integration Example

The example below ties everything from the previous sections into a single, realistic integration. It shows what a typical e-commerce application looks like once the SDK is wired in end-to-end: initialization with full configuration, push token registration, an add-to-cart event with item-level data, and a purchase event followed by an immediate flush so the critical revenue data leaves the device right away. You can use this snippet as a reference when integrating the SDK in your own application — replace the screen and handler stubs with your real code, and the rest stays valid.