-
Notifications
You must be signed in to change notification settings - Fork 64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Trigger Wiredash when device is shaken #63
Comments
agreed, this should be easy or even default like some/most services of this sort |
I don't think this should be part of Wiredash. import 'package:die_ringe_workout/util/crashlytics.dart';
import 'package:die_ringe_workout/util/sharedpreferences.dart';
import 'package:flutter/material.dart';
import 'package:shake/shake.dart';
import 'package:wiredash/wiredash.dart';
class ShakeToWiredash extends StatefulWidget {
final Widget child;
const ShakeToWiredash({
super.key,
required this.child,
});
@override
State<ShakeToWiredash> createState() => _ShakeToWiredashState();
}
class _ShakeToWiredashState extends State<ShakeToWiredash> {
late final _detector = ShakeDetector.waitForStart(
onPhoneShake: () async {
final isEnabled = true; // <-- add own logic here
logEvent("User shook the phone. Showing Wiredash: $isEnabled");
if (!isEnabled) return;
if (!mounted) return;
Wiredash.of(context).show();
},
// Add your own params here
minimumShakeCount: 3,
shakeCountResetTime: 2000,
shakeSlopTimeMS: 250,
);
@override
void initState() {
super.initState();
_detector.startListening();
}
@override
void dispose() {
_detector.stopListening();
super.dispose();
}
@override
Widget build(BuildContext context) {
return widget.child;
}
} The difficult part is figuring out which shake parameters work for you. If it's an internal app you might want easy, frequent feedback, if it's an app for end users you might want to add a little more friction to prevent triggering it accidentally. Imo this can be closed. |
Wiredash should support triggering it by shaking the phone.
It's possible to do that currently on our own, with some drawback, see #62
The text was updated successfully, but these errors were encountered: