Giter VIP home page Giter VIP logo

flutter_compass's Introduction

flutter_compass

pub package

A Flutter compass. The heading varies from 0-360, 0 being north.

Note: Android Only: null is returned as direction on android when no sensor available.

Usage

To use this plugin, add flutter_compass as a dependency in your pubspec.yaml file. For example:

dependencies:
  flutter_compass: '^0.7.0'

iOS

Make sure to add keys with appropriate descriptions to the Info.plist file.

  • NSLocationWhenInUseUsageDescription
  • NSLocationAlwaysAndWhenInUseUsageDescription

๐Ÿ“ Reference example code

Android

Make sure to add permissions to the app/src/main/AndroidManifest.xml file.

  • android.permission.INTERNET
  • android.permission.ACCESS_COARSE_LOCATION
  • android.permission.ACCESS_FINE_LOCATION

๐Ÿ“ Reference example code

Recommended support plugins

๐Ÿ“ Reference example code

flutter_compass's People

Contributors

androidseb avatar ened avatar gabeschine avatar hemanthrajv avatar josephcrowell avatar lukepighetti avatar marcotta avatar medyas avatar mihu86 avatar nkalscheuer avatar otopba avatar paulosousadias avatar raimundwege avatar ristiisa avatar robcleghorn avatar scarnett avatar theolassonder avatar tlserver avatar xennis avatar xvemu avatar ykws avatar yspreen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

flutter_compass's Issues

rxdart needs update

Because flutter_compass 0.4.1 depends on rxdart ^0.23.1 and no versions of flutter_compass match >0.4.1 <0.5.0, flutter_compass ^0.4.1 requires rxdart ^0.23.1.
So, because therapist_training depends on both rxdart ^0.24.0 and flutter_compass ^0.4.1, version solving failed.

[Android] Doesn't work in landscape

This package does not work as expected on Android when the device is in landscape mode. The heading is affected by the device depending on how flat you are holding it.

It does, however, work as expected on iOS in landscape mode.

related: #33

Bringing back fro background compass stops

I have not fully debugged the issue yet. But compass listener seems to be stopping providing new info when you let app to be on the background for a while and wake it up on Android

Android's sensor delay is too slow for UI

SensorManager.SENSOR_DELAY_NORMAL is too slow for smooth UI updates of a compass direction.

I propose changing the delay to SENSOR_DELAY_UI or even making it configurable.

flutter_compass-Swift.h file not found

Have been playing with the plugin for couple of month and it did great on Android devices! But when I'm using and compiling into my iPhone (real device, not emulator), build failed.

Starting Xcode build...                                          
Xcode build done.                                           22.1s
Failed to build iOS app
Error output from Xcode build:
โ†ณ
    ** BUILD FAILED **

Xcode's output:
โ†ณ
    /Users/umroh/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_compass-0.0.
    2/ios/Classes/FlutterCompassPlugin.m:2:9: fatal error:
    'flutter_compass/flutter_compass-Swift.h' file not found
    #import <flutter_compass/flutter_compass-Swift.h>
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    1 error generated.

Could not build the precompiled application for the device.

Is there something (Pod configuration or anything) that I missed? Thanks.

NoSuchMethodError: The method 'cast' was called on null.

I am getting many logs on Sentry for this:

image

NoSuchMethodError: NoSuchMethodError: The method 'cast' was called on null.
Receiver: null
Tried calling: cast()
File "object_patch.dart", line 54, in Object.noSuchMethod
File "flutter_compass.dart", line 56, in FlutterCompass.events.
File "stream_pipe.dart", line 213, in _MapStream._handleData
File "stream_pipe.dart", line 153, in _ForwardingStreamSubscription._handleData
File "zone.dart", line 1370, in _rootRunUnary
File "zone.dart", line 1265, in _CustomZone.runUnary
File "zone.dart", line 1170, in _CustomZone.runUnaryGuarded
File "stream_impl.dart", line 341, in _BufferingStreamSubscription._sendData
File "stream_impl.dart", line 591, in _DelayedData.perform
File "stream_impl.dart", line 706, in _StreamImplEvents.handleNext
File "stream_impl.dart", line 663, in _PendingEvents.schedule.
File "zone.dart", line 1346, in _rootRun
File "zone.dart", line 1258, in _CustomZone.run
File "zone.dart", line 1162, in _CustomZone.runGuarded
File "zone.dart", line 1202, in _CustomZone.bindCallbackGuarded.
File "zone.dart", line 1354, in _rootRun
File "zone.dart", line 1258, in _CustomZone.run
File "zone.dart", line 1162, in _CustomZone.runGuarded
File "zone.dart", line 1202, in _CustomZone.bindCallbackGuarded.
File "schedule_microtask.dart", line 40, in _microtaskLoop
File "schedule_microtask.dart", line 49, in _startMicrotaskLoop

What do you think if there is a check here if data is not null?

.map((dynamic data) => CompassEvent.fromList(data.cast<double>()))

Not working for some devices (Huawei GR3 2017)

I tried flutter_compass. this plugin working perfectly. But not working for some devices. Is there any way to create a compass another official way?

I found another production application used a flutter compass. I downloaded it and test it. This one also not working for my device. I think this app also used this plugin. What is the issue? play store link and their article

FlutterCompass.events.listen((double direction) {
  setState(() {
    _direction = direction;
  });
});

I tried another Huawei device.I got this error message on my console..

E/SensorManager(10516): sensor or listener is null

Log

2020-02-26 11:32:34.281 9552-9552/? I/zygote64: Late-enabling -Xcheck:jni
2020-02-26 11:32:34.306 9552-9552/? I/zygote64: Reinit property: dalvik.vm.checkjni= false
2020-02-26 11:32:34.331 9552-9552/? D/ActivityThread: ActivityThread,attachApplication
2020-02-26 11:32:34.406 9552-9568/com.orelgodriver.dev I/HwApiCacheMangerEx: apicache mCurPackageName=com.orelgodriver.dev uptimes=101834774
2020-02-26 11:32:34.408 9552-9568/com.orelgodriver.dev I/HwApiCacheMangerEx: apicache oUid null
2020-02-26 11:32:34.408 9552-9568/com.orelgodriver.dev I/HwApiCacheMangerEx: apicache volumes null
2020-02-26 11:32:34.411 9552-9568/com.orelgodriver.dev I/HwApiCacheMangerEx: apicache path=/storage/emulated/0 state=mounted key=com.orelgodriver.dev#11285#256
2020-02-26 11:32:34.411 9552-9568/com.orelgodriver.dev I/HwApiCacheMangerEx: apicache oUid 11285
2020-02-26 11:32:34.412 9552-9568/com.orelgodriver.dev I/HwApiCacheMangerEx: apicache volumes null
2020-02-26 11:32:34.413 9552-9568/com.orelgodriver.dev I/HwApiCacheMangerEx: apicache path=/storage/emulated/0 state=mounted key=com.orelgodriver.dev#11285#0
2020-02-26 11:32:34.413 9552-9568/com.orelgodriver.dev I/HwApiCacheMangerEx: apicache async read begin packageName=com.orelgodriver.dev userid=0
2020-02-26 11:32:34.413 9552-9568/com.orelgodriver.dev I/HwApiCacheMangerEx: apicache pi null
2020-02-26 11:32:34.413 9552-9552/com.orelgodriver.dev D/HwFLClassLoader: get used feature list :/feature/used-list failed!
2020-02-26 11:32:34.413 9552-9552/com.orelgodriver.dev D/HwFLClassLoader: USE_FEATURE_LIST had not init! 
2020-02-26 11:32:34.414 9552-9568/com.orelgodriver.dev I/HwApiCacheMangerEx: apicache pi null
2020-02-26 11:32:34.416 9552-9568/com.orelgodriver.dev I/HwApiCacheMangerEx: apicache pi null
2020-02-26 11:32:34.417 9552-9568/com.orelgodriver.dev I/HwApiCacheMangerEx: apicache oUid null
2020-02-26 11:32:34.418 9552-9568/com.orelgodriver.dev I/HwApiCacheMangerEx: apicache async read finished packageName=com.orelgodriver.dev userid=0 totalus=5233
2020-02-26 11:32:34.437 9552-9552/com.orelgodriver.dev I/HwApiCacheMangerEx: apicache pi null
2020-02-26 11:32:34.531 9552-9577/com.orelgodriver.dev W/DynamiteModule: Local module descriptor class for com.google.firebase.auth not found.
2020-02-26 11:32:34.541 9552-9579/com.orelgodriver.dev W/DynamiteModule: Local module descriptor class for com.google.firebase.auth not found.
2020-02-26 11:32:34.552 9552-9579/com.orelgodriver.dev I/FirebaseAuth: [FirebaseAuth:] Preparing to create service connection to gms implementation
2020-02-26 11:32:34.581 9552-9552/com.orelgodriver.dev I/FirebaseInitProvider: FirebaseApp initialization successful
2020-02-26 11:32:34.586 9552-9584/com.orelgodriver.dev I/HwApiCacheMangerEx: apicache pi PackageInfo{d6e6bbf com.orelgodriver.dev}
2020-02-26 11:32:34.589 9552-9552/com.orelgodriver.dev I/HwApiCacheMangerEx: apicache oUid 11285
2020-02-26 11:32:34.589 9552-9552/com.orelgodriver.dev I/HwApiCacheMangerEx: apicache volumes [Landroid.os.storage.StorageVolume;@fd52dd5
2020-02-26 11:32:34.594 9552-9552/com.orelgodriver.dev I/HwApiCacheMangerEx: apicache oUid 11285
2020-02-26 11:32:34.594 9552-9552/com.orelgodriver.dev I/HwApiCacheMangerEx: apicache volumes [Landroid.os.storage.StorageVolume;@fd52dd5
2020-02-26 11:32:34.606 9552-9586/com.orelgodriver.dev I/HwApiCacheMangerEx: apicache pi PackageInfo{d6e6bbf com.orelgodriver.dev}
2020-02-26 11:32:34.606 9552-9586/com.orelgodriver.dev I/ResourceExtractor: Found extracted resources res_timestamp-1-1582696495092
2020-02-26 11:32:34.614 9552-9568/com.orelgodriver.dev E/MemoryLeakMonitorManager: MemoryLeakMonitor.jar is not exist!
2020-02-26 11:32:34.616 9552-9552/com.orelgodriver.dev E/Minikin: Could not get cmap table size!
2020-02-26 11:32:34.617 9552-9576/com.orelgodriver.dev I/HwApiCacheMangerEx: apicache pi PackageInfo{d6e6bbf com.orelgodriver.dev}
2020-02-26 11:32:34.627 9552-9576/com.orelgodriver.dev I/FA: App measurement is starting up, version: 18202
2020-02-26 11:32:34.627 9552-9576/com.orelgodriver.dev I/FA: To enable debug logging run: adb shell setprop log.tag.FA VERBOSE
2020-02-26 11:32:34.628 9552-9576/com.orelgodriver.dev I/FA: To enable faster debug mode event logging run:
      adb shell setprop debug.firebase.analytics.app com.orelgodriver.dev
2020-02-26 11:32:34.633 9552-9552/com.orelgodriver.dev I/HwCust: Constructor found for class android.app.HwCustActivityImpl
2020-02-26 11:32:34.634 9552-9552/com.orelgodriver.dev D/HwCust: Create obj success use class android.app.HwCustActivityImpl
2020-02-26 11:32:34.635 9552-9552/com.orelgodriver.dev V/HwPolicyFactory: : success to get AllImpl object and return....
2020-02-26 11:32:34.638 9552-9552/com.orelgodriver.dev I/HwCust: Constructor found for class android.app.HwCustHwWallpaperManagerImpl
2020-02-26 11:32:34.639 9552-9552/com.orelgodriver.dev D/HwCust: Create obj success use class android.app.HwCustHwWallpaperManagerImpl
2020-02-26 11:32:34.646 9552-9552/com.orelgodriver.dev V/HwWidgetFactory: : successes to get AllImpl object and return....
2020-02-26 11:32:34.650 9552-9552/com.orelgodriver.dev V/ActivityThread: ActivityThread,callActivityOnCreate
2020-02-26 11:32:34.651 9552-9576/com.orelgodriver.dev I/HwApiCacheMangerEx: apicache pi PackageInfo{f103453 com.orelgodriver.dev}
2020-02-26 11:32:34.872 9552-9552/com.orelgodriver.dev I/HwSecImmHelper: mSecurityInputMethodService is null
2020-02-26 11:32:34.880 9552-9552/com.orelgodriver.dev W/Settings: mValues not put! needsGenerationTracker: true currentGeneration: -1 name: time_12_24 value: 12
2020-02-26 11:32:34.885 9552-9552/com.orelgodriver.dev D/HwRTBlurUtils: check blur style for HwPhoneWindow, themeResId : 0x7f0f00c9, context : com.orelgodriver.dev.MainActivity@7df7c42, Nhwext : 0, get Blur : disable with , null
2020-02-26 11:32:34.886 9552-9552/com.orelgodriver.dev D/HwRTBlurUtils: check blur style for HwPhoneWindow, themeResId : 0x7f0f00c9, context : com.orelgodriver.dev.MainActivity@7df7c42, Nhwext : 0, get Blur : disable with , null
2020-02-26 11:32:34.913 9552-9552/com.orelgodriver.dev I/HwApiCacheMangerEx: apicache oUid 11285
2020-02-26 11:32:34.914 9552-9552/com.orelgodriver.dev I/HwApiCacheMangerEx: apicache volumes [Landroid.os.storage.StorageVolume;@fd52dd5
2020-02-26 11:32:34.940 9552-9552/com.orelgodriver.dev D/ActivityThread: add activity client record, r= ActivityRecord{3e5ed66 token=android.os.BinderProxy@d1813b7 {com.orelgodriver.dev/com.orelgodriver.dev.MainActivity}} token= android.os.BinderProxy@d1813b7
2020-02-26 11:32:34.967 9552-9552/com.orelgodriver.dev D/OpenGLRenderer:   HWUI Binary is  enabled
2020-02-26 11:32:34.971 9552-9620/com.orelgodriver.dev D/OpenGLRenderer: HWUI GL Pipeline
2020-02-26 11:32:34.973 9552-9576/com.orelgodriver.dev I/FA: Tag Manager is not found and thus will not be used
2020-02-26 11:32:34.994 9552-9552/com.orelgodriver.dev I/PressGestureDetector: onAttached begin
2020-02-26 11:32:34.995 9552-9552/com.orelgodriver.dev I/PressGestureDetector: onAttached end
2020-02-26 11:32:34.995 9552-9621/com.orelgodriver.dev I/PressGestureDetector: HiTouch restricted: AboardArea.
2020-02-26 11:32:35.038 9552-9620/com.orelgodriver.dev I/OpenGLRenderer: Initialized EGL, version 1.4
2020-02-26 11:32:35.038 9552-9620/com.orelgodriver.dev D/OpenGLRenderer: Swap behavior 2
2020-02-26 11:32:35.055 9552-9620/com.orelgodriver.dev D/mali_winsys: EGLint new_window_surface(egl_winsys_display *, void *, EGLSurface, EGLConfig, egl_winsys_surface **, egl_color_buffer_format *, EGLBoolean) returns 0x3000
2020-02-26 11:32:35.065 9552-9589/com.orelgodriver.dev D/mali_winsys: EGLint new_window_surface(egl_winsys_display *, void *, EGLSurface, EGLConfig, egl_winsys_surface **, egl_color_buffer_format *, EGLBoolean) returns 0x3000
2020-02-26 11:32:35.097 9552-9558/com.orelgodriver.dev I/zygote64: Do partial code cache collection, code=29KB, data=22KB
2020-02-26 11:32:35.098 9552-9558/com.orelgodriver.dev I/zygote64: After code cache collection, code=28KB, data=21KB
2020-02-26 11:32:35.098 9552-9558/com.orelgodriver.dev I/zygote64: Increasing code cache capacity to 128KB
2020-02-26 11:32:35.177 9552-9614/com.orelgodriver.dev I/flutter: Observatory listening on http://127.0.0.1:36629/tQ2gGGXykrE=/
2020-02-26 11:32:35.350 9552-9552/com.orelgodriver.dev W/InputMethodManager: startInputReason = 1
2020-02-26 11:32:35.384 9552-9552/com.orelgodriver.dev W/InputMethodManager: startInputReason = 5
2020-02-26 11:32:36.448 9552-9552/com.orelgodriver.dev V/InputMethodManager: Reporting focus gain, without startInput
2020-02-26 11:32:39.058 9552-9558/com.orelgodriver.dev I/zygote64: Do partial code cache collection, code=60KB, data=44KB
2020-02-26 11:32:39.058 9552-9558/com.orelgodriver.dev I/zygote64: After code cache collection, code=60KB, data=44KB
2020-02-26 11:32:39.058 9552-9558/com.orelgodriver.dev I/zygote64: Increasing code cache capacity to 256KB
2020-02-26 11:32:40.607 9552-9833/com.orelgodriver.dev D/NetworkSecurityConfig: No Network Security Config specified, using platform default
2020-02-26 11:32:40.619 9552-9832/com.orelgodriver.dev I/HwCust: Constructor found for class android.net.HwCustConnectivityManagerImpl
2020-02-26 11:32:40.619 9552-9832/com.orelgodriver.dev D/HwCust: Create obj success use class android.net.HwCustConnectivityManagerImpl
2020-02-26 11:32:40.621 9552-9835/com.orelgodriver.dev W/DynamiteModule: Local module descriptor class for providerinstaller not found.
2020-02-26 11:32:40.635 9552-9835/com.orelgodriver.dev I/DynamiteModule: Considering local module providerinstaller:0 and remote module providerinstaller:0
2020-02-26 11:32:40.637 9552-9835/com.orelgodriver.dev W/ProviderInstaller: Failed to load providerinstaller module: No acceptable module found. Local version is 0 and remote version is 0.
2020-02-26 11:32:40.659 9552-9835/com.orelgodriver.dev D/HwFLClassLoader: USE_FEATURE_LIST had not init! 
2020-02-26 11:32:40.715 9552-9835/com.orelgodriver.dev V/NativeCrypto: Registering com/google/android/gms/org/conscrypt/NativeCrypto's 286 native methods...
2020-02-26 11:32:40.794 9552-9835/com.orelgodriver.dev I/ProviderInstaller: Installed default security provider GmsCore_OpenSSL
2020-02-26 11:32:53.747 9552-9552/com.orelgodriver.dev I/hwaps: JNI_OnLoad
2020-02-26 11:32:55.461 9552-9558/com.orelgodriver.dev I/zygote64: Do full code cache collection, code=124KB, data=88KB
2020-02-26 11:32:55.462 9552-9558/com.orelgodriver.dev I/zygote64: After code cache collection, code=106KB, data=63KB
2020-02-26 11:33:09.126 9552-9558/com.orelgodriver.dev I/zygote64: Do partial code cache collection, code=112KB, data=77KB
2020-02-26 11:33:09.127 9552-9558/com.orelgodriver.dev I/zygote64: After code cache collection, code=112KB, data=77KB
2020-02-26 11:33:09.127 9552-9558/com.orelgodriver.dev I/zygote64: Increasing code cache capacity to 512KB

Show how accurate the compass is

Feature Request

It would be nice to see how accurate the compass is (using Sensor manager).

Workaround

In java when you implement SensorEventListener, you have option to override onAccuracyChanged()

@Override
    public void onAccuracyChanged(Sensor sensor, int accuracy)
    {
        switch (accuracy)
        {
            case SensorManager.SENSOR_STATUS_ACCURACY_LOW:
                break;

            case SensorManager.SENSOR_STATUS_ACCURACY_MEDIUM:
                break;

            case SensorManager.SENSOR_STATUS_ACCURACY_HIGH:
                break;

            case SensorManager.SENSOR_STATUS_UNRELIABLE:
               break;
        }

    }

App crash in emulator

Error Log

09-18 15:34:55.247 8917-8917/ubilabs.net.trufiBeta E/AndroidRuntime: FATAL EXCEPTION: main
    Process: ubilabs.net.trufiBeta, PID: 8917
    java.lang.RuntimeException: Unable to start activity ComponentInfo{ubilabs.net.trufiBeta/ubilabs.net.trufiBeta.MainActivity}: java.lang.IllegalStateException: sensorManager.getDefaultSensor(sensorType) must not be null
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2325)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
        at android.app.ActivityThread.access$800(ActivityThread.java:151)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:135)
        at android.app.ActivityThread.main(ActivityThread.java:5254)
        at java.lang.reflect.Method.invoke(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:372)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
     Caused by: java.lang.IllegalStateException: sensorManager.getDefaultSensor(sensorType) must not be null
        at com.hemanthraj.fluttercompass.FlutterCompassPlugin.<init>(FlutterCompassPlugin.kt:31)
        at com.hemanthraj.fluttercompass.FlutterCompassPlugin.<init>(FlutterCompassPlugin.kt:11)
        at com.hemanthraj.fluttercompass.FlutterCompassPlugin$Companion.registerWith(FlutterCompassPlugin.kt:25)
        at com.hemanthraj.fluttercompass.FlutterCompassPlugin.registerWith(FlutterCompassPlugin.kt)
        at io.flutter.plugins.GeneratedPluginRegistrant.registerWith(GeneratedPluginRegistrant.java:19)
        at ubilabs.net.trufiBeta.MainActivity.onCreate(MainActivity.kt:11)
        at android.app.Activity.performCreate(Activity.java:5990)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)ย 
        at android.app.ActivityThread.access$800(ActivityThread.java:151)ย 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)ย 
        at android.os.Handler.dispatchMessage(Handler.java:102)ย 
        at android.os.Looper.loop(Looper.java:135)ย 
        at android.app.ActivityThread.main(ActivityThread.java:5254)ย 
        at java.lang.reflect.Method.invoke(Native Method)ย 
        at java.lang.reflect.Method.invoke(Method.java:372)ย 
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)ย 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)ย 

Wh

When building my application -which uses this plugin- on iPhone 11 I got the following error:

(my document dir)/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_compass-0.3.6/ios/Classes/FlutterCompassPlugin.m:2:9: fatal error: 'flutter_compass/flutter_compass-Swift.h' file not found
    #import <flutter_compass/flutter_compass-Swift.h>
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    1 error generated.
    note: Using new build system
    note: Planning build
    note: Constructing build description

Could not build the precompiled application for the device.

//==========================
This is my flutter doctor output:

(my document dir)/flutter/bin/flutter doctor --verbose
[โœ“] Flutter (Channel beta, v1.13.6, on Mac OS X 10.14.4 18E226, locale en-AE)
    โ€ข Flutter version 1.13.6 at (my document dir)/flutter
    โ€ข Framework revision 659dc8129d (6 weeks ago), 2019-12-30 09:24:47 -0800
    โ€ข Engine revision bdc9708d23
    โ€ข Dart version 2.8.0 (build 2.8.0-dev.0.0 c547f5d933)

[โœ“] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
    โ€ข Android SDK at(my document dir)/Library/Android/sdk
    โ€ข Android NDK location not configured (optional; useful for native profiling support)
    โ€ข Platform android-29, build-tools 28.0.3
    โ€ข ANDROID_HOME = (my document dir)/Library/Android/sdk
    โ€ข Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    โ€ข Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
    โ€ข All Android licenses accepted.

[โœ“] Xcode - develop for iOS and macOS (Xcode 11.3.1)
    โ€ข Xcode at /Applications/Xcode.app/Contents/Developer
    โ€ข Xcode 11.3.1, Build version 11C504
    โ€ข CocoaPods version 1.6.1

[โœ“] Android Studio (version 3.5)
    โ€ข Android Studio at /Applications/Android Studio.app/Contents
    โ€ข Flutter plugin version 42.1.1
    โ€ข Dart plugin version 191.8593
    โ€ข Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)

[โœ“] Connected device (1 available)
    โ€ข 000โ€™s iPhone โ€ข XXXXXXXXXXXXXXXX โ€ข ios โ€ข iOS 13.2.3

โ€ข No issues found!
Process finished with exit code 0

//===================
Please note I have no issue when running the application in Android mobile, the issue only with iPhone
The current plugin version I am using is: flutter_compass: ^0.3.6
It also did not work with flutter_compass: ^0.3.4

Revert minSdkVersion back to 20

Recently the minSdkVersion was changed from 20 to 23 but there doesn't seem to be any reason for that. We are still supporting devices on API levels lower than 23, so can we please keep doing so?

Bad state: You cannot close the subject while items are being added from addStream

I'm getting Bad State Error when using the flutter_compass inside a new page. When calling FlutterCompass().dispose() an exception is thrown.
I have added an example code.

โ•โ•โ•โ•โ•โ•โ•โ• Exception caught by widgets library โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
The following StateError was thrown while finalizing the widget tree:
Bad state: You cannot close the subject while items are being added from addStream

When the exception was thrown, this was the stack:
#0      Subject.close (package:rxdart/src/subjects/subject.dart:152:7)
#1      FlutterCompass.dispose (package:flutter_compass/flutter_compass.dart:35:21)
#2      _TestingCompassWidgetState.dispose (package:flutter_qiblah_example/main.dart:321:22)
#3      StatefulElement.unmount (package:flutter/src/widgets/framework.dart:4733:12)
#4      _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1922:13)
...
void main() => runApp(MyApp());

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
        theme: ThemeData(
          primaryColor: Color(0xff0c7b93),
          primaryColorLight: Color(0xff00a8cc),
          primaryColorDark: Color(0xff27496d),
          accentColor: Color(0xffecce6d),
        ),
        darkTheme: ThemeData.dark().copyWith(accentColor: Color(0xffecce6d)),
        home: CenterEx());
  }
}


class CenterEx extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
          child: RaisedButton(
            color: Theme.of(context).accentColor,
            onPressed: () {
              Navigator.push(
                context,
                MaterialPageRoute(
                  builder: (context) {
                    return Scaffold(
                      appBar: AppBar(
                        title: Text("Compass"),
                      ),
                      body: TestingCompassWidget(),
                    );
                  },
                ),
              );
            },
            child: Text('Open Compass'),
          ),
        ));
  }
}



class TestingCompassWidget extends StatefulWidget {
  @override
  _TestingCompassWidgetState createState() => _TestingCompassWidgetState();
}

class _TestingCompassWidgetState extends State<TestingCompassWidget> {

  @override
  void dispose() {
    FlutterCompass().dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Center(
      child: _buildManualReader(),
    );
  }

  Widget _buildManualReader() {
    return Padding(
      padding: const EdgeInsets.all(16.0),
      child: StreamBuilder<double>(
          stream: FlutterCompass.events,
          builder: (context, snapshot) {
            if (snapshot.hasError) {
              return Text('Error reading heading: ${snapshot.error}');
            }

            if (snapshot.connectionState == ConnectionState.waiting) {
              return Center(
                child: CircularProgressIndicator(),
              );
            }

            double direction = snapshot.data;
            return Text(
              '$direction',
              style: Theme.of(context).textTheme.button,
            );
          }),
    );
  }
}

RxDart Upgrade Needed

Because bloc 0.15.0 depends on rxdart ^0.22.0 and no versions of bloc match >0.15.0 <0.16.0, bloc ^0.15.0 requires rxdart ^0.22.0.
And because flutter_compass >=0.3.2 depends on rxdart ^0.21.0, flutter_compass >=0.3.2 is incompatible with bloc ^0.15.0.
And because flutter_bloc 0.21.0 depends on bloc ^0.15.0 and no versions of flutter_bloc match >0.21.0 <0.22.0, flutter_compass >=0.3.2 is incompatible with flutter_bloc ^0.21.0.
So, because collectors depends on both flutter_bloc ^0.21.0 and flutter_compass ^0.3.2, version solving failed.
pub get failed (1)

flutter_compass: ^0.7.0 super laggy on Android Device

I don't know, before I used ^0.6.1, then because I updated flutter version to 2.5.0 and there was a notification flutter_compass use a deprecated version of the Android embedding. So I updated to ^0.7.0

And it's so unpleasant, I'm not sure what fps the compass animation is, but it's worse than 10 fps. Super laggy

Package Version
^0.7.0
@hemanthrajv #64

Thousands of FlutterJNI errors when app is detached

Flutter (Channel stable, 2.8.1, on Ubuntu 20.04.3 LTS 5.4.0-96-generic, locale en_US.UTF-8)

If you run the example app and then detach using the back button, you get 1000's of errors written to logcat:

01-31 11:56:35.544 2946 2946 W FlutterJNI: Tried to send a platform message to Flutter, but FlutterJNI was detached from native C++. Could not send. Channel: hemanthraj/flutter_compass. Response ID: 10213

If you restart the example, then detach again, you get two streams of the error message. A third restart/detach, ditto. It appears that the only way to stop them is to reboot the device.

Is there some way to shutdown the channel, say at app inactive, so this doesn't occur? The error messages don't start until detach.

Example does not work from Flutter Pub

I also tried to make this work from the example on Flutter Pub but it got stuck while testing after pushing one of your buttons and now no matter what I it stays stuck in that state. I have deleted the code and run it again and everytime it returns to this state. The buttons do not return. The example on Flutter Pub is not functional and the example on GitHub is deprecated.

Screen Shot 2021-04-18 at 9 06 50 AM

java.lang.IllegalStateException: sensorManager.getDefaultSensor(sensorType) must not be null in Flutter

I have build a flutter app which has features like showing qibla direction with the help of flutter_compass dependencies. This App works fine in newest versions of Android Devices but if i try to install this app in older versions (API 16, API 17) it shows "Unfortunately this App has Stopped". I checked in logcat it shows "java.lang.IllegalStateException: sensorManager.getDefaultSensor(sensorType) must not be null". So do i need to add some native code in android folder or dependencies in buildgradle ?

flutter compass does not specify a swift version

it is giving me this error " [!] Unable to determine Swift version for the following pods:
- flutter_compass does not specify a Swift version and none of the targets (Runner) integrating it have the SWIFT_VERSION attribute set. Please contact the author or set the SWIFT_VERSION attribute in at least one of the targets that integrate this pod."

I even updated my cocoa pods also did a pod install which gave me the same error .
I also changed the pod file and put the target swift version for flutter compass but still the issue is not resolved . Could you please look into that and help me asap.
ThankYou

Accuracy returning null.

Run this code:

FlutterCompass.events.listen(print);

And you'll see logs

heading: 8.04228051653871
headingForCameraMode: 7.436648389885647
accuracy: null

Version:

flutter_compass: ^0.5.0

Tested on
Samsung Galaxy S20+ (Android 10)

FlutterCompass doesn't work in Redmi 6

I get 'E/SensorManager(30827): sensor or listener is null' error while I use FlutterCompass in Redmi 6.

It works in other devices as of now. Is it a known issue?

how can we use this library to point at bearing angle like qibla direction apps

i want to make an application which gets the user current location and destination location from the textbox and calculate the bearing which i have already done but the problem is i want to point the compass toward bearing angle so when ever the device orientation moved it always move on the bearing direction like what Qibla direction application do.

headingForCamera is 0

Regular heading seems to work fine. It changes when I shift the position/orientation of both an emulator and an actual phone. But in both cases, the heading for camera mode stays at zero. This is using the example code. Any advice?

flutter_compass/flutter_compass-Swift.h' file not found

Screenshot:
image

Version:
0.3.4

Flutter doctor:

Doctor summary (to see all details, run flutter doctor -v):
[โœ“] Flutter (Channel dev, v1.14.1, on Mac OS X 10.15.1 19B88, locale en-GB)
 
[โœ“] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
[โœ“] Xcode - develop for iOS and macOS (Xcode 11.2.1)
[โœ“] Android Studio (version 3.5)
[โœ“] Connected device (1 available)

โ€ข No issues found!

Not working on Huawei RIO-L02 with Android 5.1

Hi,
The library (v0.4.3) works fine on new devices but when I try to run it on a Huawei RIO-L02 with Android 5.1, it does not work.

this.sensorManager.getDefaultSensor(sensorType) function returns null with both of the following sensor types:

Sensor.TYPE_ROTATION_VECTOR and Sensor.TYPE_GEOMAGNETIC_ROTATION_VECTOR

However the following compass implemention which uses Sensor.TYPE_ACCELEROMETER and Sensor.TYPE_MAGNETIC_FIELD sensors to calculate the azimuth work without any problems on the same device:

https://github.com/iutinvg/compass/blob/48347d7ab23f1bf1801791d561fb5ae452217046/app/src/main/java/com/sevencrayons/compass/Compass.java

Is it possible to add this alternative as a fallback method in the library?

Tried to send a platform message to Flutter, but FlutterJNI was detached from native C++. Could not send. Channel: hemanthraj/flutter_compass. Response ID: 0

hi i see this message in console

W/FlutterJNI(22907): Tried to send a platform message to Flutter, but FlutterJNI was detached from native C++. Could not send. Channel: hemanthraj/flutter_compass. Response ID: 0
D/ViewRootImplInjector(22907): Gesture Screenshot Enabled = false
W/FlutterJNI(22907): Tried to send a platform message to Flutter, but FlutterJNI was detached from native C++. Could not send. Channel: hemanthraj/flutter_compass. Response ID: 0
W/FlutterJNI(22907): Tried to send a platform message to Flutter, but FlutterJNI was detached from native C++. Could not send. Channel: hemanthraj/flutter_compass. Response ID: 0
I/chatty (22907): uid=10669(kw.ltd.salatkapp) identical 5 lines
W/FlutterJNI(22907): Tried to send a platform message to Flutter, but FlutterJNI was detached from native C++. Could not send. Channel: hemanthraj/flutter_compass. Response ID: 0
W/FlutterJNI(22907): Tried to send a platform message to Flutter, but FlutterJNI was detached from native C++. Could not send. Channel: hemanthraj/flutter_compass. Response ID: 0
I/chatty (22907): uid=10669(kw.ltd.salatkapp) identical 11 lines
W/FlutterJNI(22907): Tried to send a platform message to Flutter, but FlutterJNI was detached from native C++. Could not send. Channel: hemanthraj/flutter_compass. Response ID: 0
W/FlutterJNI(22907): Tried to send a platform message to Flutter, but FlutterJNI was detached from native C++. Could not send. Channel: hemanthraj/flutter_compass. Response ID: 0
I/chatty (22907): uid=10669(kw.ltd.salatkapp) identical 3 lines
W/FlutterJNI(22907): Tried to send a platform message to Flutter, but FlutterJNI was detached from native C++. Could not send. Channel: hemanthraj/flutter_compass. Response ID: 0
W/FlutterJNI(22907): Tried to send a platform message to Flutter, but FlutterJNI was detached from native C++. Could not send. Channel: hemanthraj/flutter_compass. Response ID: 0
W/FlutterJNI(22907): Tried to send a platform message to Flutter, but FlutterJNI was detached from native C++. Could not send. Channel: hemanthraj/flutter_compass. Response ID: 0
W/FlutterJNI(22907): Tried to send a platform message to Flutter, but FlutterJNI was detached from native C++. Could not send. Channel: hemanthraj/flutter_compass. Response ID: 0
W/FlutterJNI(22907): Tried to send a platform message to Flutter, but FlutterJNI was detached from native C++. Could not send. Channel: hemanthraj/flutter_compass. Response ID: 0
W/FlutterJNI(22907): Tried to send a platform message to Flutter, but FlutterJNI was detached from native C++. Could not send. Channel: hemanthraj/flutter_compass. Response ID: 0
W/FlutterJNI(22907): Tried to send a platform message to Flutter, but FlutterJNI was detached from native C++. Could not send. Channel: hemanthraj/flutter_compass. Response ID: 0
W/FlutterJNI(22907): Tried to send a platform message to Flutter, but FlutterJNI was detached from native C++. Could not send. Channel: hemanthraj/flutter_compass. Response ID: 0
W/FlutterJNI(22907): Tried to send a platform message to Flutter, but FlutterJNI was detached from native C++. Could not send. Channel: hemanthraj/flutter_compass. Response ID: 0

Different behavior in IOS and Android

When using this plugin on my IOS devices, the plugin reports the correct heading out the back of device (along the z axis) when the device is oriented vertically. However, on my Android devices, when held vertically, the plugin does not report an accurate heading. It appears that on Android devices, the plugin attempts to get a heading along the y axis which is pointing directly up/vertical. Why doesnt the Android version of the plugin get a heading along the z axis when oriented vertically, as the IOS version seems to be doing.

I Tested on a Pixel 2 and Pixel 4 with the same negative behavior. Any thoughts?

Flutter Compass Accuarcy

This has very low accuracy and there is no way to calibrate it it gives different heading for the same direction any help?

flutter_compass-Swift.h not found

hello,

Code breaks in the FlutterCompassPlugin.m class as it is unabble to find the
#import <flutter_compass/flutter_compass-Swift.h> file.

Is this an issue that has been resolved?

Get compass value on init

If I put my iPhone on a table and don't move it, I never get a FlutterCompass.events. Is there a way to have the initial compass value ?

Thanks for this great tool btw!

Compass is influenced by device roll

I'm testing this plugin and it doesn't seem to work properly.
I expect the compass to point north even when the device is tilted to left or right.
However when the device is tilted to the left and right, the compass is off. I guess this is caused by the roll (see image) is influencing the calculation, which it shouldn't, if I understand correctly.

pitch-roll-yaw

Am I misunderstanding something?

returns null if closing and re-opening app

when closing my app and reopening the compass returns null, I wasn't sure its my app or the flutter_compass package so I downloaded the example app from your github and ran it on my phone and it has the same issues, I have other compasses running on my phone without a issue, it runs fine on iOS but not on my Mi note 10 pro, I'm attaching a clip where you can see the issue

flutter.compass.mp4

The plugin `flutter_compass` uses a deprecated version of the Android embedding.

I get this error on running flutter pub get.

The plugin flutter_compass uses a deprecated version of the Android embedding.
To avoid unexpected runtime failures, or future build failures, try to see if this plugin supports the Android V2 embedding. Otherwise, consider removing it since a future release of Flutter will remove these deprecated APIs.
If you are plugin author, take a look at the docs for migrating the plugin to the V2 embedding: https://flutter.dev/go/android-plugin-migration.

Package version:

^0.6.1

Flutter version:

Flutter 2.5.0-1.0.pre โ€ข channel dev โ€ข https://github.com/flutter/flutter.git
Framework โ€ข revision 184e5871be (3 days ago)
Tools โ€ข Dart 2.14.0 (build 2.14.0-350.0.dev)

Method Not Found

Unhandled Exception: MissingPluginException(No implementation found for method check on channel

FAILURE: Build failed with an exception

Hello I cannot run my app on release mode.

The build failed likely due to AndroidX incompatibilities in a plugin. The tool is about to try using Jetifier to solve the incompatibility.
Building plugin flutter_compass...
Running Gradle task 'assembleAarRelease'...

FAILURE: Build failed with an exception.

* Where:
Build file 'C:\Users\khali\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\flutter_compass-0.7.0\android\build.gradle' line: 22

* What went wrong:
A problem occurred evaluating root project 'flutter_compass'.
> Failed to apply plugin [id 'com.android.internal.version-check']
   > Minimum supported Gradle version is 6.5. Current version is 6.1.1. If using the gradle wrapper, try editing the distributionUrl in C:\Users\khali\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\flutter_compass-0.7.0\android\gradle\wrapper\gradle-wrapper.properties to gradle-6.5-all.zip

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 1s

Exception: The plugin flutter_compass could not be built due to the issue above.
> flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[โˆš] Flutter (Channel stable, 2.2.3, on Microsoft Windows [Version 10.0.19043.1263], locale en-DE)
[โˆš] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
[โˆš] Chrome - develop for the web
[โˆš] Visual Studio - develop for Windows (Visual Studio Community 2019 16.8.2)
[โˆš] Android Studio (version 4.1.0)
[โˆš] IntelliJ IDEA Community Edition (version 2021.2)
[โˆš] IntelliJ IDEA Ultimate Edition (version 2021.1)
[โˆš] VS Code (version 1.59.1)
[โˆš] Connected device (5 available)

โ€ข No issues found!

can you please fix this problem.

Update latest version on pub.dev

@hemanthrajv currently 0.7.0 is released on pub.dev on 09/09/2021 but since then there have been some major bugfixes for Android.

Is it possible to release the latest version to pub.dev as well?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.