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

1

Add the package

Install the Flutter package.

terminal

1flutter pub add grometrics_flutter
2

Initialize 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 {2  WidgetsFlutterBinding.ensureInitialized();3  await Grometrics.configure(websiteId: 'YOUR_SITE_ID');4  Grometrics.appOpen();5  runApp(const MyApp());6}
3

Track route changes

Attach the route observer to send screen_view events.

app.dart

1MaterialApp(2  navigatorObservers: [GrometricsRouteObserver()],3)

Options / Configuration

OptionTypeRequiredDescription
websiteIdstringYour Grometrics site ID
appVersionstringnoPopulates app version filters
debugbooleannoLogs 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?