Bjørn Winther
Bjørn Winther

Reputation: 11

Flutter Sensors_plus package: Adjusting sample rate of sensordata for mobile web application

https://github.com/flutter/flutter/issues/25971 In the GitHub thread, the community has managed to adjust the sample rate for android devices. My problem is that I'm building a web application using the "sensors_plus" flutter package and I can't seem to locate anywhere in the library/package where a sample rate / refresh rate for sensor data is set for the web build?

Does anyone know anything about this? is it even possible to adjust the sample rate when building for web with this package?

Sorry for the intricate question :)

Upvotes: 1

Views: 1047

Answers (1)

Advait Pathak-Work
Advait Pathak-Work

Reputation: 21

Yes,it is possible. I myself have changed the package files to set the sample rate to SENSOR_DELAY_FASTEST.

Steps:

  1. Expand the External Libraries directory present in your project directory in android studio(Only seen in android studio).

  2. Go to flutter plugins and expand the sensors-plus->android->src.main->kotlin.dev.fluttercommunity.plus.sensors directory.

  3. Go to StreamHandlerImpl.kt file and find the SENSOR_DELAY_NORMAL line and change it to SENSOR_DELAY_FASTEST.

  4. Go to AndroidManifest.xml and paste this

    <manifest 
      xmlns:android="http://schemas.android.com/apk/res/android"
      package="dev.fluttercommunity.plus.sensors" >
      <uses-permission 
     android:name="android.permission.HIGH_SAMPLING_RATE_SENSORS"/>
    </manifest>
    
  5. Now it will work,but this change should be done everytime you do pub get or clean your pub-cache.

Upvotes: 2

Related Questions