Skip to content
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

Compass Not Moving - Compass sensor is unreliable, device calibration is needed. #46

Open
md-rifatkhan opened this issue Feb 10, 2024 · 7 comments

Comments

@md-rifatkhan
Copy link

I got Compass sensor is unreliable, device calibration is needed.

import 'dart:async';
import 'dart:math';
import 'package:flutter/material.dart';
import 'package:flutter_qiblah/flutter_qiblah.dart';
import 'package:flutter_svg/svg.dart';

class Qibla extends StatelessWidget {
  final _compassSvg = SvgPicture.asset('assets/qibla/compass.svg');
  final _needleSvg = SvgPicture.asset(
    'assets/qibla/needle.svg',
    fit: BoxFit.contain,
    height: 300,
    alignment: Alignment.center,
  );

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: StreamBuilder(
        stream: FlutterQiblah.qiblahStream,
        builder: (_, AsyncSnapshot<QiblahDirection> snapshot) {
          if (snapshot.connectionState == ConnectionState.waiting) {
            return const Center(child: CircularProgressIndicator(),);
          }

          final qiblahDirection = snapshot.data;

          return Stack(
            alignment: Alignment.center,
            children: <Widget>[
              Transform.rotate(
                angle: ((qiblahDirection?.direction ?? 0) * (pi / 180) * -1),
                child: _compassSvg,
              ),
              Transform.rotate(
                angle: ((qiblahDirection?.qiblah ?? 0) * (pi / 180) * -1),
                alignment: Alignment.center,
                child: _needleSvg,
              ),
              Positioned(
                bottom: 8,
                child: Text("${qiblahDirection?.offset.toStringAsFixed(3)}°"),
              )
            ],
          );
        },
      ),
    );
  }
}
@md-rifatkhan
Copy link
Author

md-rifatkhan commented Feb 10, 2024

and Text("${qiblahDirection?.offset.toStringAsFixed(3)}°"), value is null

Tried in two device

@Obada-Maplit
Copy link

Same Same , what is the solution ??

@md-rifatkhan
Copy link
Author

Same Same , what is the solution ??

It seems that location is still required when senor is available,

@Obada-Maplit
Copy link

Same Same , what is the solution ??

It seems that location is still required when senor is available,

the location is enabled in app

@medyas
Copy link
Owner

medyas commented Apr 1, 2024

@md-rifatkhan @Obada-Maplit the location is required for the plugin to function. please check the example project

@Obada2020
Copy link

@medyas how are u medyas , i enabled the location in app , but this message still appear on put app near laptop or Magnetfelt that log error in cmd , this error Compass Not Moving - Compass sensor is unreliable, device calibration is needed.

i need only way to recive this message in dart , how to catch it , i need to show warning to user that should app far away from any device .

pls help

@medyas
Copy link
Owner

medyas commented Apr 1, 2024

@Obada2020 the message is printed in native android by the flutter_compass plugin and currently not able to detect this in the qiblah plugin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants