flight_recorder 0.0.5
flight_recorder: ^0.0.5 copied to clipboard
Flutter plugin for Pulselabs FlightRecorder SDK. It captures the last 15 seconds of user interaction, aiding in user feedback and insights. Visit the homepage for details.
example/lib/main.dart
import 'package:flight_recorder/flight_recorder.dart';
import 'package:flight_recorder/screen_recorder.dart';
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
final _flightRecorderPlugin = FlightRecorder();
@override
void initState() {
// init flight recorder
_flightRecorderPlugin.initFlightRecorder('YOUR_API_KEY', true);
super.initState();
}
@override
Widget build(BuildContext context) {
/// Wrap your home with ScreenRecorder widget, passing the flight recorder pluging reference
return MaterialApp(
home: ScreenRecorder(
flightRecorderPlugin: _flightRecorderPlugin,
child: HomeScreen(flightRecorderPlugin: _flightRecorderPlugin)));
}
}
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),
),
const SizedBox(width: 8),
FloatingActionButton(
heroTag: const Key('2'),
onPressed: () {
flightRecorderPlugin.showIntroductionScreen();
},
child: const Icon(Icons.info_outline),
)
],
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
ElevatedButton(
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const SecondScreen(),
),
);
},
child: const Text('Show List'),
),
ElevatedButton(
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const ThirdScreen(),
),
);
},
child: const Text('Show Animation'),
)
],
),
),
);
}
}
class SecondScreen extends StatelessWidget {
const SecondScreen({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Second Screen'),
),
body: ListView.builder(
itemBuilder: (context, index) {
return ListTile(
title: Text('List Item $index'),
);
},
),
);
}
}
class TypewriterTween extends Tween<String> {
TypewriterTween({String begin = '', String end = ''}) : super(begin: begin, end: end);
@override
String lerp(double t) {
var cutoff = (end!.length * t).round();
return end!.substring(0, cutoff);
}
}
class ThirdScreen extends StatefulWidget {
const ThirdScreen({super.key});
static const String routeName = 'basics/custom_tweens';
@override
State<ThirdScreen> createState() => _ThirdScreenState();
}
class _ThirdScreenState extends State<ThirdScreen> with SingleTickerProviderStateMixin {
static const Duration _duration = Duration(seconds: 45);
static const String message = shortStory;
late final AnimationController controller;
late final Animation<String> animation;
@override
void initState() {
super.initState();
controller = AnimationController(vsync: this, duration: _duration);
animation = TypewriterTween(end: message).animate(controller);
controller.repeat(reverse: true);
}
@override
void dispose() {
controller.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Third Screen'),
),
body: SafeArea(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Container(
padding: const EdgeInsets.all(8.0),
child: AnimatedBuilder(
animation: animation,
builder: (context, child) {
return Text(
animation.value,
style: const TextStyle(fontSize: 16),
);
},
),
),
),
),
);
}
}
const String shortStory = '''
In the quiet town of Millbrook, Harold's weekly ritual of buying a loaf of bread took an unexpected turn one Saturday. As he browsed the store's bread aisle, he noticed a three-foot-tall, green alien in a state of bewilderment.
The alien appeared to be searching for a specific bread among the loaves. Harold, cautiously approaching, offered different options, but none satisfied the extraterrestrial visitor.
Mr. Jenkins, the store owner, joined in, presenting a variety of loaves. However, it was Harold who eventually solved the mystery. He handed the alien a plain, hearty whole wheat loaf, which the alien accepted with delight.
With a grateful nod, the alien floated out of the store, leaving everyone in awe. Harold asked why the alien had come for that particular bread, and the alien shared an image of its lush, distant home planet.
The encounter left Harold with a profound sense of interconnectedness with the universe. As he left the store, he realized that life's most extraordinary moments often arise unexpectedly, even during a routine bread run. Millbrook would never be the same, and Harold's weekly bread purchases became a legendary story of an alien bread hunt in the town.
''';