agromart_google_maps_place_picker 2.0.0-lws-0.2 copy "agromart_google_maps_place_picker: ^2.0.0-lws-0.2" to clipboard
agromart_google_maps_place_picker: ^2.0.0-lws-0.2 copied to clipboard

A Flutter plugin which provides 'Picking Place' using Google Maps widget. (MB version)

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:agromart_google_maps_place_picker/agromart_google_maps_place_picker.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';

// Your api key storage.
import 'keys.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  // Light Theme
  final ThemeData lightTheme = ThemeData.light().copyWith(
    // Background color of the FloatingCard
    cardColor: Colors.white,
  );

  // Dark Theme
  final ThemeData darkTheme = ThemeData.dark().copyWith(
    // Background color of the FloatingCard
    cardColor: Colors.grey,
  );

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Google Map Place Picker Demo',
      theme: lightTheme,
      darkTheme: darkTheme,
      themeMode: ThemeMode.light,
      home: HomePage(),
      debugShowCheckedModeBanner: false,
    );
  }
}

class HomePage extends StatefulWidget {
  const HomePage({Key key}) : super(key: key);

  static final kInitialPosition = LatLng(-33.8567844, 151.213108);

  @override
  _HomePageState createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  PickResult selectedPlace;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: Text("Google Map Place Picker Demo"),
        ),
        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            crossAxisAlignment: CrossAxisAlignment.center,
            children: <Widget>[
              ElevatedButton(
                child: Text("Load Google Map"),
                onPressed: () {
                  Navigator.push(
                    context,
                    MaterialPageRoute(
                      builder: (context) {
                        return PlacePicker(
                          apiKey: APIKeys.apiKey,
                          hintText: "Find a place ...",
                          searchingText: "Please wait ...",
                          selectText: "Select place",
                          outsideOfPickAreaText: "Place not in area",
                          initialPosition: HomePage.kInitialPosition,
                          useCurrentLocation: false,
                          selectInitialPosition: true,
                          usePinPointingSearch: true,
                          usePlaceDetailSearch: true,
                          autocompleteLanguage: "en",
                          region: 'my',
                          pickArea: CircleArea(
                            center: LatLng(3.157764, 101.711861),
                            radius: 7000,
                            fillColor:
                                Colors.lightGreen.withGreen(255).withAlpha(32),
                            strokeColor:
                                Colors.lightGreen.withGreen(255).withAlpha(192),
                            strokeWidth: 2,
                          ),
                          onPlacePicked: (result) {
                            selectedPlace = result;
                            Navigator.of(context).pop();
                            setState(() {});
                          },
                        );
                      },
                    ),
                  );
                },
              ),
              selectedPlace == null
                  ? Container()
                  : Text(selectedPlace.formattedAddress ?? ""),
            ],
          ),
        ));
  }
}
1
likes
100
pub points
10%
popularity

Publisher

unverified uploader

A Flutter plugin which provides 'Picking Place' using Google Maps widget. (MB version)

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

flutter, geolocator, google_api_headers, google_maps_flutter, google_maps_webservice, http, location, provider, tuple, uuid

More

Packages that depend on agromart_google_maps_place_picker