google_maps_pick_place 0.8.7 copy "google_maps_pick_place: ^0.8.7" to clipboard
google_maps_pick_place: ^0.8.7 copied to clipboard

A pub.dev package which helps pick a location from google maps

example/lib/main.dart

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

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

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Google Maps Pick Place Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const MyHomePage(title: 'Google Maps Pick Place Demo'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({Key? key, required this.title}) : super(key: key);

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {

  String address = "";
  double latitude = 0.0;
  double longitude = 0.0;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
        elevation: 0.0,
        centerTitle: true,
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Text(
              'Address: $address',
            ),
            Text(
              'Latitude: $latitude ',
            ),
            Text(
              'Longitude: $longitude',
            ),
            RaisedButton(
              color: Colors.blue,
              elevation: 0.0,
              onPressed: () {
                Navigator.push(
                  context,
                  MaterialPageRoute(
                    builder: (context) => GoogleMapsPickPlace(
                      apiKey: 'YOUR_GOOGLE_MAPS_API_KEY',
                      getResult: (FullAddress fullAddress) {
                        setState(() {
                          address = fullAddress.address.toString();
                          latitude = fullAddress.position!.latitude;
                          longitude = fullAddress.position!.longitude;
                        });
                      },
                    ),
                  ),
                );
              },
              child: const Text('Pick Place'),
            ),
          ],
        ),
      ),
    );
  }
}
24
likes
100
points
35
downloads

Publisher

unverified uploader

Weekly Downloads

A pub.dev package which helps pick a location from google maps

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

dio, flutter, geocoding, geolocator, google_maps_flutter, permission_handler

More

Packages that depend on google_maps_pick_place