gmap_place_picker 0.0.1 copy "gmap_place_picker: ^0.0.1" to clipboard
gmap_place_picker: ^0.0.1 copied to clipboard

outdated

A new Flutter plugin for get location detail from map.

example/lib/main.dart

import 'dart:async';

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:gmap_place_picker/gmap_place_picker.dart';
import 'package:gmap_place_picker/model/place_info.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';
import 'package:location/location.dart';

void main() {
  runApp(MyApp());
}

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

class _MyAppState extends State<MyApp> {
  String _platformVersion = 'Unknown';
  PlaceInfo _selectedPlace;

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

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> initPlatformState() async {
    String platformVersion;
    // Platform messages may fail, so we use a try/catch PlatformException.
    try {
      platformVersion = await GmapPlacePicker.platformVersion;
    } on PlatformException {
      platformVersion = 'Failed to get platform version.';
    }

    // If the widget was removed from the tree while the asynchronous platform
    // message was in flight, we want to discard the reply rather than calling
    // setState to update our non-existent appearance.
    if (!mounted) return;

    setState(() {
      _platformVersion = platformVersion;
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Google map place picker'),
        ),
        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              RaisedButton(
                onPressed: () async {
                  PlaceInfo result = await openPlacePicker(
                    context,
                    "apiKey",
                    initialCenter: LatLng(12.9716, 77.5946),
                    myLocationButtonEnabled: true,
                    layersButtonEnabled: true,
                    desiredAccuracy: LocationAccuracy.high,
                  );
                  print("result = $result");
                  setState(() => _selectedPlace = result);
                },
                child: Text('Pick desire place'),
              ),
              Text(_selectedPlace.toString()),
            ],
          ),
        ),
      ),
    );
  }
}
3
likes
0
points
37
downloads

Publisher

unverified uploader

Weekly Downloads

A new Flutter plugin for get location detail from map.

License

unknown (license)

Dependencies

android_intent, flutter, flutter_localizations, google_maps_flutter, http, intl, intl_translation, location, package_info, provider, stack_trace

More

Packages that depend on gmap_place_picker

Packages that implement gmap_place_picker