Capture Recording
The SDK captures a recording when your user shakes the device or takes a screenshot - actions considered as triggers. You can extend this capability by incorporating your own additional triggers.
For instance, you might want to capture a recording when your user presses a button in your app or completes a specific sequence.
However you capture the recording, the SDK user interface will always appear to let your users review the footage, edit and submit.
Select a Trigger and Capture Recording
Decide from what event you want to capture the video, for example a button press. We will call this the trigger. This very simple example shows a possible trigger - when a floating action button is pressed
class HomeScreen extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( floatingActionButton: Row( mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment.center, children: [ FloatingActionButton( heroTag: const Key('1'), onPressed: () { }, child: const Icon(Icons.upload_file), ) ], ), body: PlaceHolder(), ); } }
Update the widget to add a reference to Flight Recorder:
class HomeScreen extends StatelessWidget { final FlightRecorder flightRecorderPlugin; const HomeScreen({super.key, required this.flightRecorderPlugin}); @override Widget build(BuildContext context) { return Scaffold( floatingActionButton: Row( mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment.center, children: [ FloatingActionButton( heroTag: const Key('1'), onPressed: () { }, child: const Icon(Icons.upload_file), ) ], ), body: PlaceHolder(), ); } }
Call
triggerCaptureRecording
at the moment you want to capture the video inside the trigger.flightRecorderPlugin.triggerCaptureRecording()
In our example, we call the method from the FloatingActionButton onPressed function:
class HomeScreen extends StatelessWidget { final FlightRecorder flightRecorderPlugin; const HomeScreen({super.key, required this.flightRecorderPlugin}); @override Widget build(BuildContext context) { return Scaffold( floatingActionButton: Row( mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment.center, children: [ FloatingActionButton( heroTag: const Key('1'), onPressed: () { flightRecorderPlugin.triggerCaptureRecording(); }, child: const Icon(Icons.upload_file), ) ], ), body: PlaceHolder(), ); } }
Last updated