nova_places_api 2.0.0 copy "nova_places_api: ^2.0.0" to clipboard
nova_places_api: ^2.0.0 copied to clipboard

The Places API lets you search for place information using a variety of categories, including establishments, prominent points of interest, and geographic locations. You can search for places either b [...]

example/main.dart

import 'package:nova_places_api/nova_places_api.dart';

void main(List<String> arguments) async {
  final placesApi = PlacesApi(apiKey: 'api-key')..setLanguage('en');

  // first
  print('Places autocomplete');
  final response1 = await placesApi.placeAutocomplete(
    input: 'amoeba',
    location: LatLngLiteral(
      lat: 37.76999,
      lng: -122.44696,
    ),
    radius: 500,
    strictBounds: true,
    types: ['establishment'],
    // sessionToken: generateSessionToken()
  );

  if (!response1.isSuccess) {
    print(response1.errorMessage);
  } else {
    final predictions = response1.predictions;
    predictions.map((p) => p.description).forEach(print);
  }

  // second
  print('\nQuery autocomplete');
  final response2 = await placesApi.queryAutocomplete(
    input: 'pizza near San Francisco',
  );
  if (!response2.isSuccess) {
    print(response2.errorMessage);
  } else {
    final predictions = response2.predictions;
    predictions.map((p) => p.description).forEach(print);
  }

  if (response1.isSuccess && response1.predictions.isNotEmpty) {
    // third;
    print('\nQuery place detail');
    final response3 = await placesApi.getPlaceDetails(
      placeId: response1.predictions.first.placeId!,
    );
    if (!response3.isSuccess) {
      print(response3.errorMessage);
    } else {
      print(response3.result!.formattedAddress);
      print(response3.result!.geometry!.location);
    }
  }

  placesApi.dispose();
}
2
likes
150
pub points
6%
popularity

Publisher

unverified uploader

The Places API lets you search for place information using a variety of categories, including establishments, prominent points of interest, and geographic locations. You can search for places either by proximity or a text string. A Place Search returns a list of places along with summary information about each place.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

nova_google_services_core

More

Packages that depend on nova_places_api