Skip to main content
The SDK is one Dart file, crispstats.dart. It uses only the Dart SDK and Flutter, so there is no extra dependency. It needs Dart 3.0 and Flutter 3.10 or later, and runs on iOS and Android. On any other platform it does nothing. It keeps a random install id, queues events while the network is down, and sends them to https://in.crispstats.com/e. It does not read an advertising id.

Add the file

From the project root:
Then import it from lib/main.dart with import "crispstats.dart";.

Create the client

Without storage, the install id and the queue live in memory and reset when the process ends. Pass read and write backed by shared_preferences, or any other store, so they survive a restart. Add the package with flutter pub add shared_preferences.
Replace cs_pk_xxxxxxxx with the site’s public key from Settings, Tracking code, and com.acme.app with the bundle id or application id. appBuild is the build number and can be left out. start listens for background and foreground, detects the device, and sends anything a previous launch left queued. Call it once, after WidgetsFlutterBinding.ensureInitialized(). Call dispose if you ever tear the client down. If the key does not start with cs_pk_, the app id has characters other than letters, digits, ., _ and -, or the version is empty, the client sends nothing and prints why once in a debug build. It never throws.

OS version

Platform.operatingSystemVersion is a long string, for example Version 17.4 (Build 21E213) on iOS and the Linux kernel version on Android. On iOS the SDK takes 17.4 from it when you leave osVersion out. On Android pass the short value yourself, for example info.version.release from the device_info_plus package. Without it the OS version shows as unknown. In main, in place of the call above:

Count screens

Call screen when the visible screen changes:
A screen name is one to eight segments separated by /. Each segment starts with a letter or a digit and then uses letters, digits, spaces, ., _ and -, up to 80 characters. The whole name is at most 200 characters. Settings/Account is stored as the page /Settings/Account. A name that breaks these rules sends nothing. screen sends the time spent on the previous screen before it counts the new one. Time on screen pauses while the app is not resumed. When the app comes back within 30 minutes, the same screen keeps adding up. After 30 minutes or more in the background, the screen is counted again, because a new session has started.

Events, users and revenue

revenue takes minor units: 4900 with USD is $49.00. A negative amount is ignored. Pass the campaign tags of the link that opened the app to the first screen call. CrispStats.campaignFrom reads them from the link, whichever deep link package gives it to you:
A link such as acme://pricing?utm_source=newsletter&utm_medium=email sets the channel to email. You can also pass the pairs yourself, and a referrer URL:
Keys are lower-cased and keep letters, digits and _, up to 32 characters. Values are trimmed and kept when they are 1 to 200 characters. At most 10 pairs are sent. The referrer is sent when it is 1 to 2,000 characters. Both apply to that one screen view only.

Tablets

When start runs, the SDK reads the shortest side of the screen in logical pixels: 600 or more counts as a tablet. To set it yourself, pass device: CrispStatsDevice.tablet or device: CrispStatsDevice.phone.

Time zone

Flutter has no built-in way to read the device’s IANA time zone name, so the SDK sends no time zone unless you pass one, for example from a time zone package. In main, in place of the call above:
The time zone is a fallback for the country. Without it the country comes from the request as usual.

Opt out

optOut drops anything still queued and sends nothing until optIn. The choice is kept across launches when read and write are set.

Errors

The message is grouped on the Errors page.

Offline and retries

Each event is one request. Events wait in a queue of up to 100, kept through write when it is set, and the oldest is dropped when it is full. The SDK sends the queue when start runs, when the app returns to the foreground and after each new event. After a failure it tries again after 1 second, then 2, 4 and so on, up to once a minute. A request that takes longer than 10 seconds counts as a failure. No call waits for the network.

What gets stored

The screen is a pageview. The browser breakdown shows iOS app or Android app, and the device shows mobile or tablet. The SDK property is flutter. The language comes from the device settings. The install id itself is not stored. See mobile apps for the rest of the mapping.
Last modified on December 2, 2026