Flutter SDK - tracking inputs

Details about tracking the inputs with the Flutter tracker

Flutter SDK ⁠-⁠ tracking inputs

Text fields are not observed automatically — Flutter has no equivalent of UIKit’s responder chain to hook into. Attach the tracker to the controllers you care about, and it will listen to value changes (debounced) and send the resulting value to the OpenReplay backend.

Use observeInput(controller, label:, masked:):

  • controller: TextEditingController — the controller to observe
  • label: String — label for the recorded input
  • masked: bool — if true, the tracker records the input event but sends **** instead of the value. Default: false.

It returns a callback that removes the listener, so wire it into dispose():

import 'package:openreplay/openreplay.dart';

class _LoginFormState extends State<LoginForm> {
  final _email = TextEditingController();
  late final VoidCallback _stopObserving;

  @override
  void initState() {
    super.initState();
    _stopObserving = OpenReplay.instance.observeInput(_email, label: 'Email');
  }

  @override
  void dispose() {
    _stopObserving();
    _email.dispose();
    super.dispose();
  }
}

If you have any questions about this process, feel free to reach out to us on our Slack or check out our Forum.