flutter_amap_location_plugin 1.0.0 copy "flutter_amap_location_plugin: ^1.0.0" to clipboard
flutter_amap_location_plugin: ^1.0.0 copied to clipboard

outdated

A amap Flutter plugin to easily handle realtime location in iOS and Android.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:flutter_amap_location_plugin/amap_location_option.dart';
import 'package:flutter_amap_location_plugin/flutter_amap_location_plugin.dart';

import 'get_location.dart';
import 'listener_location.dart';

void main() {
  //todo
  FlutterAmapLocationPlugin.setApiKey("xx");

//  runApp(MyApp());

  runApp(new MaterialApp(
    home: MyApp(),
    routes: {
      "/getLocation": (BuildContext context) => GetLocation(),
      "/listenerLocation": (BuildContext content) => ListenerLocation()
    },
  ));
}

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  @override
  void initState() {
    super.initState();

    //启动客户端,这里设置ios端的精度小一点
    FlutterAmapLocationPlugin.startup(
      AMapLocationOption(
        iosOption: IosAMapLocationOption(
          desiredAccuracy: CLLocationAccuracy.kCLLocationAccuracyHundredMeters,
        ),
      ),
    );
  }

  @override
  void dispose() {
    //注意这里关闭
    FlutterAmapLocationPlugin.shutdown();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Plugin example app'),
      ),
      body: ListView(
        children: <Widget>[
          ListTile(
            onTap: () {
              Navigator.of(context).pushNamed("/getLocation");
            },
            isThreeLine: true,
            dense: false,
            leading: null,
            title: Text("直接获取定位"),
            subtitle: Text("直接单次定位,获取定位信息"),
            trailing: new Icon(
              Icons.arrow_right,
              color: Colors.blueAccent,
            ),
          ),
          Divider(),
          ListTile(
            onTap: () {
              Navigator.of(context).pushNamed("/getLocation");
            },
            isThreeLine: true,
            dense: false,
            leading: null,
            title: Text("持续定位"),
            subtitle: Text("持续定位,通过监听获取定位信息"),
            trailing: new Icon(
              Icons.arrow_right,
              color: Colors.blueAccent,
            ),
          ),
          Divider(),
        ],
      ),
    );
  }
}
0
likes
0
pub points
0%
popularity

Publisher

unverified uploader

A amap Flutter plugin to easily handle realtime location in iOS and Android.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on flutter_amap_location_plugin