Skip to content

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

Closed as not planned
@omkar-2506

Description

@omkar-2506

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.

Metadata

Metadata

Assignees

Labels

status: closed (missing info)Indicates the issue was automatically closed due to a lack of information.status: needs more infoWe need more information before we can continue work on this issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions