美文网首页
Flutter 定位服务是否开启判断

Flutter 定位服务是否开启判断

作者: PuppetMin | 来源:发表于2020-03-03 09:55 被阅读0次

找了一圈pub没找着,
只看到个location,但get之后需要google 服务,没安装一直弹窗……
那就自己写一下吧
git地址:
https://github.com/EchoPuda/location_service_check.git
nullsafety版本:https://github.com/EchoPuda/location_service_check_nullsafety
pub:https://pub.dev/packages/location_service_check

使用方法

pubspec.yaml:
  location_service_check:
    git:
      url: https://github.com/EchoPuda/location_service_check.git

import

import 'package:location_service_check/location_service_check.dart';

检查是否开启了定位服务

  bool open = await LocationServiceCheck.checkLocationIsOpen;

打开定位设置页

  await LocationServiceCheck.openLocationSetting;

Android直接打开系统的定位服务, iOS由于ios10开始不支持打开系统详细设置,所以打开应用的设置页。

相关文章

网友评论

      本文标题:Flutter 定位服务是否开启判断

      本文链接:https://www.haomeiwen.com/subject/hdiflhtx.html