Flutter
Install the Flutter SDK and track app sessions.
Last updated June 3, 2026
Install the Flutter SDK, initialize it on app boot, and track route changes as screen_view events.
Prerequisites
- A Grometrics site ID from Settings > Tracking
- Access to the mobile app code
- A debug build or simulator for verification
Steps
Add the package
Install the Flutter package.
terminal
1flutter pub add grometrics_flutterInitialize before runApp
Configure the tracker before the first screen renders.
Replace YOUR_SITE_ID with your site ID from Settings > Tracking.
main.dart
1void main() async {2WidgetsFlutterBinding.ensureInitialized();3await Grometrics.configure(websiteId: 'YOUR_SITE_ID');4Grometrics.appOpen();5runApp(const MyApp());6}
Track route changes
Attach the route observer to send screen_view events.
app.dart
1MaterialApp(2navigatorObservers: [GrometricsRouteObserver()],3)
Options / Configuration
| Option | Type | Required | Description |
|---|---|---|---|
| websiteId | string | ✓ | Your Grometrics site ID |
| appVersion | string | no | Populates app version filters |
| debug | boolean | no | Logs setup events in development |
What happens next
Run the app and navigate between routes. Realtime should show app_open and screen_view events.
Verify your setup
Verify your setup
Troubleshooting
No event appears
Confirm the site ID matches Settings > Tracking and that the latest published code is running.
Was this page helpful?