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

[Bug]: Not able to get the position by getCurrentPosition method in offline mode I'm currently using realme device. #1634

Open
4 of 8 tasks
omkar-2506 opened this issue Feb 5, 2025 · 1 comment
Assignees
Labels
status: needs more info We need more information before we can continue work on this issue.

Comments

@omkar-2506
Copy link

Please check the following before submitting a new issue.

Please select affected platform(s)

  • Android
  • iOS
  • Linux
  • macOS
  • Web
  • Windows

Steps to reproduce

1.Turn your internet off
2.Try to get the Position by getCurrentPosition.

Expected results

Get current position

Actual results

sometimes get the position in 60-90 sec and sometimes it takes forever

Code sample

Code sample
 Future<Position> getCurrentPosition({
    LocationSettings? locationSettings,
    LocationAccuracy desiredAccuracy = LocationAccuracy.best,
    bool forceAndroidLocationManager = false,
    Duration? timeLimit,
  }) async {
    LocationSettings? settings;
    if (locationSettings != null) {
      settings = locationSettings;
    } else if (defaultTargetPlatform == TargetPlatform.android) {
      settings = AndroidSettings(
        accuracy: desiredAccuracy,
        forceLocationManager: forceAndroidLocationManager,
      );
    }
    try {
      settings ??= LocationSettings(
        accuracy: desiredAccuracy,
        timeLimit: timeLimit,
      );
      debugPrint("await starts");
      Position position = await Geolocator.getCurrentPosition(
        locationSettings: settings,
      );

      return position;
    } catch (e) {
      debugPrint(e.toString());
      return Geolocator.getCurrentPosition(
        locationSettings: settings,
      );
    }
  }

Screenshots or video

Screenshots or video demonstration

[Upload media here]

Version

13.0.2

Flutter Doctor output

Doctor output
[√] Flutter (Channel stable, 3.24.5, on Microsoft Windows [Version 10.0.26100.2894], locale en-IN)
    • Flutter version 3.24.5 on channel stable at C:\bynry\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision dec2ee5c1f (3 months ago), 2024-11-13 11:13:06 -0800
    • Engine revision a18df97ca5
    • Dart version 3.5.4
    • DevTools version 2.37.3

[√] Windows Version (Installed version of Windows is version 10 or higher)

[√] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at C:\Users\Asus\AppData\Local\Android\Sdk
    • Platform android-34-ext8, build-tools 34.0.0
    • Java binary at:
      C:\Users\Asus\AppData\Roaming\Code\User\globalStorage\pleiades.java-extension-pack-jdk\java\21\
      bin\java
    • Java version OpenJDK Runtime Environment Temurin-21.0.6+7 (build 21.0.6+7-LTS)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe

[X] Visual Studio - develop Windows apps
    X Visual Studio not installed; this is necessary to develop Windows apps.
      Download at https://visualstudio.microsoft.com/downloads/.
      Please install the "Desktop development with C++" workload, including all of its default       
      components

[√] Android Studio (version 2024.1)
    • Android Studio at C:\Program Files\Android\Android Studio2
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart
    • Java version openjdk version "17.0.10" 2024-01-16

[!] Android Studio (version 2023.1)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart
    X android-studio-dir = C:\Program Files\Android\Android Studio
    X Unable to determine bundled Java version.
    • Try updating or re-installing Android Studio.
    • Consider removing your android-studio-dir setting by running:
      flutter config --android-studio-dir=

[√] VS Code (version 1.96.4)
    • VS Code at C:\Users\Asus\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.104.0

[√] Connected device (3 available)
    • Windows (desktop) • windows • windows-x64    • Microsoft Windows [Version 10.0.26100.2894]
    • Chrome (web)      • chrome  • web-javascript • Google Chrome 132.0.6834.160
    • Edge (web)        • edge    • web-javascript • Microsoft Edge 132.0.2957.127

[√] Network resources
    • All expected network resources are available.
@TimHoogstrate
Copy link
Contributor

Dear @omkar-2506,

Are you testing this on iOs or Android? For Android try: forceAndroidLocationManager = true. It forces to use the GPS chip. But be careful. You should test this outside or with a clear view of the sky. Check if you have some different results.

Kind regards,

@TimHoogstrate TimHoogstrate self-assigned this Feb 7, 2025
@TimHoogstrate TimHoogstrate added the status: needs more info We need more information before we can continue work on this issue. label Feb 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: needs more info We need more information before we can continue work on this issue.
Projects
None yet
Development

No branches or pull requests

2 participants