标签: geolocator

飞行模式开启时 getCurrentPosition 不返回位置

插件地理定位器:^9.0.1 飞行关闭模式运行良好,

如果飞行模式打开,则无法获取位置/抛出任何错误。即使在飞行模式下我也需要获取位置

请建议更改或使用此功能的其他插件

也尝试使用位置插件,同样的情况发生

最少的代码

import 'package:flutter/material.dart';
import 'package:geolocator/geolocator.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
        visualDensity: VisualDensity.adaptivePlatformDensity,
      ),
      home: HomePage(),
    );
  }
}
class HomePage extends StatefulWidget {
  @override
  _HomePageState createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
   Position? pos;
   bool? _isLoading;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("Location"),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center, …
Run Code Online (Sandbox Code Playgroud)

location flutter geolocator

5
推荐指数
1
解决办法
420
查看次数

Flutter:任务“:geolocator:compileDebugJavaWithJavac”执行失败

该项目于今年一月前完美建成。但现在它告诉我错误。首先他们向我显示位置 16+ 错误。然后我将位置包更改为地理定位器。但不固定。然后创建新项目并导入旧代码库。并且还将 target 和compilesdk 更改为 31。并取消注释compileOptions

这是我的应用程序级别 build.gradle-

def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
    localPropertiesFile.withReader('UTF-8') { reader ->
        localProperties.load(reader)
    }
}

def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
    throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
    flutterVersionCode = '1'
}

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
    flutterVersionName = '1.0'
}

apply …
Run Code Online (Sandbox Code Playgroud)

location-provider flutter geolocator

3
推荐指数
1
解决办法
7371
查看次数

标签 统计

flutter ×2

geolocator ×2

location ×1

location-provider ×1