请帮助我使用凝结器颤振软件包时遇到麻烦,我不知道出了什么问题,但是没有打印位置。我的功能被调用,但是纬度和经度没有被打印 我已经在物理设备上授予了位置许可,我还在清单文件中添加了Internet许可
import 'package:flutter/material.dart';
import 'package:geolocator/geolocator.dart';
class LoadingScreen extends StatefulWidget {
@override
_LoadingScreenState createState() => _LoadingScreenState();
}
class _LoadingScreenState extends State<LoadingScreen> {
void getLocation() async {
print("inside get locaion");
Position position = await Geolocator()
.getCurrentPosition(desiredAccuracy: LocationAccuracy.low);
print(position);
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: RaisedButton(
onPressed: () {
print("calling get location");
getLocation();
},
child: Text('Get Location'),
),
),
);
}
}
这是我的androidManifest.xml文件
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="co.appbrewery.clima">
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<!-- io.flutter.app.FlutterApplication is an android.app.Application that
calls FlutterMain.startInitialization(this); in its onCreate method.
In most cases you can leave this as-is, but you if you want to provide
additional functionality it is fine to subclass or reimplement
FlutterApplication and put your custom class here. -->
<application
android:name="io.flutter.app.FlutterApplication"
android:label="clima"
android:icon="@mipmap/ic_launcher">
<activity
android:name=".MainActivity"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<!-- This keeps the window background of the activity showing
until Flutter renders its first frame. It can be removed if
there is no splash screen (such as the default splash screen
defined in @style/LaunchTheme). -->
<meta-data
android:name="io.flutter.app.android.SplashScreenUntilFirstFrame"
android:value="true" />
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
</manifest>
我的gradle.propereties
android.useAndroidX=true
android.enableJetifier=true
org.gradle.jvmargs=-Xmx1536M
android.enableR8=true
我的输出
D/ViewRootImpl@27863a3[MainActivity]( 6535): ViewPostIme pointer 0
D/ViewRootImpl@27863a3[MainActivity]( 6535): ViewPostIme pointer 1
I/flutter ( 6535): calling get location
I/flutter ( 6535): inside get locaion