0

i'm programming an app in Android Studio with flutter and need to access the acceleration data from the device. So far, i did that by using the package "sensors" and it worked nicely.

But yesterday, the method stopped getting information from the sensors. Since i couldn't find the "sensors" packages anymore, i changed to sensors_plus which uses exactly the same methods.

I tried creating a new page for just testing it and implemented it as intended:

[...]
class _CameraScreen2State extends State<CameraScreen2> {

  List<double>? _accelerometerValues;
  final _streamSubscriptions = <StreamSubscription<dynamic>>[];

  @override
  Widget build(BuildContext context) {
    final accelerometer =
    _accelerometerValues?.map((double v) => v.toStringAsFixed(1)).toList(); 
[...]

Unfortunately, it results in following error: PlatformException(error, No active stream to cancel, null, null) at any time step and for each sensor (accelerator, userAccelerator, gyroscope, magnetometer) and i can't find an appropriate solution for it online.

Does anybody have a clue about why this suddenly stopped working or knows how to fix that?

System data:

  • Flutter version 3.8.0-15.0.
  • Android SDK version 33.0.0
  • Test device Honor 20 lite
  • Dev. on Windows 11
icecase
  • 23
  • 3
  • Tried testing it on a different device to make sure that it's not the case that the devices' sensors are broken. But even on the other device, sensor data returns null. – icecase Feb 27 '23 at 11:43

0 Answers0