Пакет Flutter gelocatior - PullRequest
       20

Пакет Flutter gelocatior

0 голосов
/ 07 мая 2020

, пожалуйста, помогите У меня проблемы с использованием пакета gelocator flutter Я не знаю, что не так, но он не печатает местоположение. Мне звонят, но широта и долгота не печатаются Я дал разрешение на местоположение на физическое устройство, я также добавил разрешение inte rnet в самый явный файл

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>

my 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
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...