黑热病是什么病| 什么事情只能用一只手去做| 专升本有什么专业| 皮肤瘙痒是什么病的前兆| 腿抽筋什么原因| 小麦什么时候成熟| 去除扁平疣用什么药膏| 禾字加一笔是什么字| 什么气什么现| 麦穗鱼吃什么| 火箭是干什么用的| 七月份什么星座| 肚脐眼下面是什么部位| 病毒长什么样子| 盐冻虾是什么意思| 五月天主唱叫什么名字| 亚甲炎是什么病| 广东古代叫什么| 乳房胀痛吃什么药| 董五行属什么| sg是什么意思| sec是什么单位| 什么叫潮汐车道| 湿化瓶内放什么水| 阴茎中途疲软吃什么药| 丝瓜炒什么好吃| cd是什么意思啊| 清福是什么意思| 都字五行属什么| 早上7点是什么时辰| 风邪是什么意思| 小孩睡觉磨牙是什么原因引起的| 大腿内侧什么经络| 冰箱底部漏水是什么原因| 十指不沾阳春水是什么意思| 侏罗纪是什么意思| 男人肝火旺吃什么药| 痛风能吃什么菜谱大全| 摩羯座是什么星座| 肝火旺盛失眠吃什么药| 低血压吃什么好的最快女性| 布洛芬0.3和0.4g有什么区别| 开山鼻祖是什么意思| tbc是什么意思| 脾大是怎么回事有什么危害| 七月三号什么星座| 牛肉和什么炒最好吃| 男生叫你姑娘什么意思| 孕妇喝什么汤好| 心电图低电压什么意思| 承字属于五行属什么| 正气是什么意思| 落是什么生肖| gr是什么意思| 带状疱疹能吃什么食物| 宗室是什么意思| 鱼缸什么材质的好| 肺炎支原体抗体阳性是什么意思| 蓝玫瑰的花语是什么| 1015是什么星座| 毛宁和毛阿敏是什么关系| v是什么化学元素| 果胶是什么| yearcon是什么牌子| 血脂高吃什么食物| 舌头紫红色是什么原因| 右侧附件区囊性回声是什么意思| 割韭菜什么意思| 什么水果清肝火| 是什么结构| 淮山是什么| 什么样的荷叶| 中招是什么意思| 脱口秀是什么| 地包天什么意思| 羽立念什么| 角色扮演叫什么| 闭关什么意思| 打马虎眼是什么意思| 沙漏是什么意思| 地震为什么会发生| 叶酸补什么| jerry英文名什么意思| 下午五点到七点是什么时辰| 毛五行属什么| 检查全身挂什么科| 甲亢什么意思| 尿路感染用什么药| 吃什么东西养胃最有效| 梦到自行车丢了是什么意思| 减肥能吃什么零食| 是的什么意思| 腰果是什么树的果实| 石榴什么时候成熟| 淋巴转移什么意思| 阑尾切除后有什么影响和后遗症| 孕妇吃什么鱼| 恋爱脑是什么意思| 妇科炎症吃什么药最好| 水仙茶适合什么人喝| 频繁流鼻血是什么病的前兆| 椰子水有什么好处| 89年属什么生肖| 拉痢疾是什么症状| 淋巴结清扫是什么意思| 孩子睡觉咬牙齿是什么原因引起的| 鸡生肖配什么生肖最好| 什么原因导致宫外孕| 体脂率是什么| 胃烂了是什么病严重吗| 文胸36码是什么尺寸| 淋巴结节吃什么药最好| 缺钾吃什么药| 园字五行属什么| 晚五行属什么| 浙大校长什么级别| 鸡飞狗跳是指什么生肖| 什么事每人每天都必须认真的做| 北京市市长是什么级别| 什么是共情| 阴阳两虚是什么症状| 肠道感染吃什么消炎药| 女性外阴瘙痒用什么药| 生肉是什么意思| 发低烧有什么症状| 黑色车牌是什么车| 手工diy是什么意思| 晚餐吃什么| 鸡拉稀吃什么药| 内心丰盈是什么意思| 更年期失眠吃什么药效果好| 名节是什么意思| 肠梗阻是因为什么原因引起的| 儿童补锌吃什么| 什么叫慢性非萎缩性胃炎| 大户人家什么意思| 尿潴留吃什么药| 什么有什么造句| 吃什么可以养肝| 偏科是什么意思| 马齿菜有什么功效| 肌红蛋白偏低说明什么| 肝区回声密集是什么意思| 线差是什么意思| 羊的守护神是什么菩萨| 胃疼喝什么药| 性出血是什么原因造成的呢要怎么办| 硒对身体有什么好处| 海马用什么呼吸| 心动过速吃什么药最好| 肝是什么器官| 口干口苦是什么原因引起的| 珠胎暗结是什么意思| 左侧肚脐旁边疼是什么原因| 性病都有什么| 凝血功能是什么意思| 鸭蛋不能和什么一起吃| 玫瑰花茶和什么搭配好| 海参什么人不能吃| 好看是什么意思| 心律平又叫什么名字| 将军是什么级别| 小狗咳嗽吃什么药好使| 苍鹰是什么意思| 汗味酸臭是什么原因| 副市长是什么级别| 4.28是什么星座| 百利甜酒兑什么最好喝| 自传是什么意思| 泰迪吃什么| 白敬亭父母是干什么的| 洗衣机什么牌子好| 沉贵宝是什么木| 什么是紫河车| 急性阑尾炎什么症状| hpv16是什么意思| 前列腺肿瘤有什么症状| 水母是什么| dd是什么意思| 2月2号什么星座| 为什么拔罐肩膀最黑| 吃了就吐是什么原因| 松针是什么| 九月九日是什么日子| 髂胫束在什么位置| kap是什么意思| 除了胃镜还有什么检查胃的方法吗| 冬枣什么时候成熟| 拉肚子吃什么最好| bml是什么| 夏天吃什么水果比较好| 世事无常什么意思| 儿童感冒挂什么科| 小孩眨眼睛是什么原因| 尿道炎吃什么药最好| 吸狗是什么意思| 养寇自重什么意思| 2001年属蛇五行属什么| 梦见捡板栗是什么意思| iphone5什么时候出的| 背包客是什么意思| 兰花什么时候开花| 什么是静息心率| 葛根长什么样子图片| 荷尔蒙什么意思| 飞机下降时耳朵疼是什么原因| 眼镜发明之前眼镜蛇叫什么| 骨关节炎吃什么药| 喝姜粉有什么好处| 婴儿流口水是什么原因引起的| 女生喜欢什么姿势| 什么叫雷达| 肛瘘是什么原因引起的| 甘油三酯低是什么原因| 睡觉脚麻是什么原因| 蜘蛛痣长什么样| 玉戴久了会有什么变化| 冰醋酸是什么| 113是什么意思| 常熟有什么好玩的地方| 祖师爷是什么意思| 打呼噜的原因是什么| 柏拉图式是什么意思| 舌头干是什么原因| ms是什么单位| 无犯罪记录证明需要什么材料| 发烧咳嗽吃什么药| 臊子面的臊子是什么| 丝瓜吃了有什么好处| 发烧看什么科| 嫉妒是什么意思| PSV是什么意思| 什么鱼适合清蒸| 空腹血糖17已经严重到什么时候| 牙齿出血是什么病| 什么护肤品| 一望无际是什么意思| 清道夫鱼有什么作用| 750是什么意思| 褪黑素有什么用| 谷丙转氨酶偏低是什么意思| 2005年属鸡的是什么命| 脚气用什么药膏最好| 花生什么时候成熟| 接吻是什么样的感觉| 腊月初八是什么星座| 弯脚杆是什么意思| 夜间多梦是什么原因| 心颤吃什么药效果好| 小孩坐飞机需要什么证件| 吃什么食物降血压最快最好| 孕妇喝什么补羊水最快| 代价什么意思| 骨关节疼痛什么原因| 分贝是什么意思| 脚臭用什么洗效果最好| 中国古代四大发明是什么| 孕晚期宫缩是什么感觉| 无水酥油是什么| 9月28号什么星座| 总胆红素偏高有什么危害| basic是什么意思| 水晶为什么要消磁| 向心性肥胖是什么意思| 百度
Skip to content

googlemaps/flutter-navigation-sdk

Repository files navigation

Google Navigation for Flutter (Beta)

European Economic Area (EEA) developers

If your billing address is in the European Economic Area, effective on 8 July 2025, the Google Maps Platform EEA Terms of Service will apply to your use of the Services. Functionality varies by region. Learn more.

Description

This repository contains a Flutter plugin that provides a Google Navigation widget to Flutter apps targeting Android and iOS.

Note

This package is in Beta until it reaches version 1.0. According to semantic versioning, breaking changes may be introduced before 1.0.

Requirements

Android iOS
Minimum mobile OS supported API level 23+ iOS 16.0+

Important

Apply API restrictions to the API key to limit usage to "Navigation SDK, "Maps SDK for Android", and "Maps SDK for iOS" for enhanced security and cost management. This helps guard against unauthorized use of your API key.

Installation

To add the Google Navigation for Flutter package to your project, use the command:

flutter pub add google_navigation_flutter

Android

Set the minSdk in android/app/build.gradle:

android {
    defaultConfig {
        minSdk 23
    }
}

If minSdk is set to less than 34 (API 34), you need to configure desugaring for your Android app. To enable desugaring, add the following configurations to android/app/build.gradle file:

android {
    ...
    compileOptions {
        coreLibraryDesugaringEnabled true
        ...
    }
}

dependencies {
    coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs_nio:2.0.4'
}

iOS

  1. Open the ios/Podfile config file in your preferred IDE.
  2. Add the following lines to the beginning of this Podfile:
  # Set platform to 16.0 to enable latest Google Maps SDK
  platform :ios, '16.0'
  1. In Xcode open Info.plist file and add App registers for location updates to the list of Required background modes

Set Google Maps API Key

Add your API key to the Flutter project using these instructions for the corresponding Android (build.gradle) and iOS (AppDelegate.swift) files. The instructions for this step in the google_maps_flutter package documentation apply to the google_navigation_flutter package as well.

See the example configuration for Secrets Gradle Plugin in the example app's build.gradle file. To securely load your API key, use the Secrets Gradle Plugin. This plugin helps manage API keys without exposing them in your app's source code.

For more details, see Google Navigation SDK Documentation.

Usage

You can now add a GoogleMapsNavigationView widget to your widget tree.

The view can be controlled with the GoogleNavigationViewController that is passed to via onViewCreated callback.

The GoogleMapsNavigationView widget should be used within a widget with a bounded size. Using it in an unbounded widget will cause the application to throw a Flutter exception.

You can also add a bare GoogleMapsMapView that works as a normal map view without navigation functionality.

Add a navigation view

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

class NavigationSample extends StatefulWidget {
  const NavigationSample({super.key});

  @override
  State<NavigationSample> createState() => _NavigationSampleState();
}

class _NavigationSampleState extends State<NavigationSample> {
  GoogleNavigationViewController? _navigationViewController;
  bool _navigationSessionInitialized = false;

  @override
  void initState() {
    super.initState();
    _initializeNavigationSession();
  }

  Future<void> _initializeNavigationSession() async {
    if (!await GoogleMapsNavigator.areTermsAccepted()) {
      await GoogleMapsNavigator.showTermsAndConditionsDialog(
        'Example title',
        'Example company',
      );
    }
    // Note: make sure user has also granted location permissions before starting navigation session.
    await GoogleMapsNavigator.initializeNavigationSession(taskRemovedBehavior: TaskRemovedBehavior.continueService);
    setState(() {
      _navigationSessionInitialized = true;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('Google Maps Navigation Sample')),
      body: _navigationSessionInitialized
          ? GoogleMapsNavigationView(
              onViewCreated: _onViewCreated,
              initialNavigationUIEnabledPreference: NavigationUIEnabledPreference.disabled,
              // Other view initialization settings
            )
          : const Center(child: CircularProgressIndicator()),
    );
  }

  void _onViewCreated(GoogleNavigationViewController controller) {
    _navigationViewController = controller;
    controller.setMyLocationEnabled(true);
    // Additional setup can be added here.
  }

  @override
  void dispose() {
    if (_navigationSessionInitialized) {
      GoogleMapsNavigator.cleanup();
    }
    super.dispose();
  }
}

Task Removed Behavior

The taskRemovedBehavior parameter of navigation session initialization defines how the navigation should behave when a task is removed from the recent apps list on Android. It can either:

  • TaskRemovedBehavior.continueService: Continue running in the background. (default)
  • TaskRemovedBehavior.quitService: Shut down immediately.

This parameter has only an effect on Android.

Add a map view

@override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('Google Maps Navigation Sample')),
      body: _navigationSessionInitialized
          ? GoogleMapsMapView(
              onViewCreated: _onViewCreated,
              initialCameraPosition: CameraPosition(
                // Initialize map to user location.
                target: _userLocation!,
                zoom: 15,
              ),
              // Other view initialization settings
            )
          : const Center(child: CircularProgressIndicator()),
    );
  }

See the example directory for a complete navigation sample app.

Requesting and handling permissions

The Google Navigation SDK Flutter plugin offers functionalities that necessitate specific permissions from the mobile operating system. These include, but are not limited to, location services, background execution, and receiving background location updates.

Note

The management of these permissions falls outside the scope of the Navigation SDKs for Android and iOS. As a developer integrating these SDKs into your applications, you are responsible for requesting and obtaining the necessary permissions from the users of your app.

You can see example of handling permissions in the main.dart file of the example application:

PermissionStatus _locationPermissionStatus = PermissionStatus.denied;

// ...

/// Request permission for accessing the device's location.
///
/// Android: Fine and Coarse Location
/// iOS: CoreLocation (Always and WhenInUse)
Future<void> _requestLocationPermission() async {
  final PermissionStatus status = await Permission.location.request();

  setState(() {
    _locationPermissionStatus = status;
  });
}

// ...

@override
Widget build(BuildContext context) {
  _requestLocationPermission();
  ...
}

Support for Android Auto and Apple CarPlay

This plugin is compatible with both Android Auto and Apple CarPlay infotainment systems. For more details, please refer to the respective platform documentation:

Known issues

Compatibility with other libraries

This package uses the Google Maps Navigation SDK for Android and iOS, which includes a dependency on the Google Maps SDK. If your project includes other flutter libraries with Google Maps SDK dependencies, you may encounter build errors due to version conflicts. To avoid this, it's recommended to avoid using multiple packages with Google Maps dependencies.

Note

This package provides a GoogleMapsMapView widget, which can be used as a classic Google Maps view without navigation. See Add a map view for details.

Contributing

See the Contributing guide.

Terms of Service

This library uses Google Maps Platform services. Use of Google Maps Platform services through this library is subject to the Google Maps Platform Terms of Service.

This library is not a Google Maps Platform Core Service. Therefore, the Google Maps Platform Terms of Service (e.g. Technical Support Services, Service Level Agreements, and Deprecation Policy) do not apply to the code in this library.

Support

This package is offered via an open source license. It is not governed by the Google Maps Platform Support Technical Support Services Guidelines, the SLA, or the Deprecation Policy (however, any Google Maps Platform services used by the library remain subject to the Google Maps Platform Terms of Service).

This package adheres to semantic versioning to indicate when backwards-incompatible changes are introduced. Accordingly, while the library is in version 0.x, backwards-incompatible changes may be introduced at any time.

If you find a bug, or have a feature request, please file an issue on GitHub. If you would like to get answers to technical questions from other Google Maps Platform developers, ask through one of our developer community channels. If you'd like to contribute, please check the Contributing guide.

镜检白细胞高是什么原因 黄什么什么 花椒有什么作用 如字五行属什么 牙根出血是什么原因
蛇属于什么动物 狗皮肤病用什么药 涩是什么意思 冲喜是什么意思 青海省会城市叫什么
女性吃金蝉有什么好处 什么是黑科技 尿多尿急是什么原因 止血敏又叫什么名 不但而且是什么关系
手长水泡是什么原因 外阴瘙痒用什么药膏擦 梦到被猪咬是什么意思 牙周炎吃什么药最有效 为什么会突然流鼻血
玥字五行属什么hcv8jop3ns9r.cn 指示是什么意思hcv8jop2ns3r.cn 智商120是什么水平hcv8jop6ns1r.cn 亲临是什么意思520myf.com 当归炖鸡有什么功效hcv8jop8ns6r.cn
吃鱼肝油有什么好处hcv7jop4ns6r.cn 胳膊肘往外拐是什么意思hcv8jop9ns8r.cn 三伏天是什么时候hcv8jop1ns1r.cn 癫痫挂什么科hcv8jop2ns8r.cn 小白龙叫什么hcv9jop6ns8r.cn
茱萸是什么意思bfb118.com 6424什么意思hcv9jop3ns6r.cn 长孙皇后叫什么名字hcv8jop3ns7r.cn 为什么手机打不出去电话hcv9jop6ns3r.cn 女性肛门坠胀看什么科hcv8jop3ns6r.cn
为什么会血压高hcv8jop3ns8r.cn 了凡四训讲的是什么helloaicloud.com 每日家情思睡昏昏什么意思hcv9jop2ns1r.cn 世界上最长的蛇是什么蛇hcv7jop6ns9r.cn 端午节吃什么菜呢cl108k.com
百度