shake_to_report 1.0.2 shake_to_report: ^1.0.2 copied to clipboard
ShakeToReport is a Flutter plugin that allows users to report issues or feedback by simply shaking their device.
ShakeToReport Flutter Plugin #
ShakeToReport is a Flutter plugin that allows users to report issues or feedback by simply shaking their device. It comes with a customizable report form, optional screenshot capture, and shake sensitivity settings, making it a powerful yet easy-to-use tool for gathering user feedback or handling bug reports.
Features #
-
Shake Detection: Detects when the device is shaken and triggers a report screen.
-
Screenshot Capture: Optionally capture the current screen when the user shakes the device.
-
Configurable Sensitivity: Set the sensitivity of the shake gesture to prevent accidental reports.
-
Developer Callback: Allows developers to handle the submitted form data in their own way, such as sending it to a server.
Installation #
To use this plugin, add shake_to_report
as a dependency in your pubspec.yaml
file:
shake_to_report: ^latest_version
Getting Started #
- Wrap Your App
To enable the screenshot functionality, you need to wrap your main application widget with the ShakeToReport.wrapWithScreenshotController
method.
and place navigatorKey in materialApp from import 'package:shake_to_report/utils/global_key.dart';
import 'package:shake_to_report/shake_to_report.dart';
import 'package:shake_to_report/utils/global_key.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return ShakeToReport.wrapWithScreenshotController(
child: MaterialApp(
navigatorKey: navigatorKey,
home: HomeScreen(),
),
);
}
}
- Initialize the Shake Listener
You can initialize the shake listener in the initState method of your main screen or wherever you prefer.
import 'package:flutter/material.dart';
import 'package:shake_to_report/shake_to_report.dart';
import 'package:shake_to_report/model/report_form_model.dart';
class HomeScreen extends StatefulWidget {
@override
_HomeScreenState createState() => _HomeScreenState();
}
class _HomeScreenState extends State<HomeScreen> {
@override
void initState() {
super.initState();
ShakeToReport.initShakeListener(
onSubmit: (ReportFormData formData) {
},
shakeThreshold: 40.0, // Optional: Set the shake sensitivity
takeScreenshot: true, // Optional: Enable screenshot capture
);
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text("Shake to Report Example")),
body: Center(
child: Text("Shake your device to report an issue!"),
),
);
}
}
Example Application #
An example app demonstrating how to use ShakeToReport can be found in the example directory. This app showcases basic and advanced usage, including different configurations of shake sensitivity and custom fields.
Testing #
the plugin for ios devices is not tested on real device.
Contributions #
Contributions are welcome! If you encounter any issues, feel free to open an issue on GitHub or create a pull request.