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

outdated

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('api-key')..setLanguage('en');

  // first
  print('Places autocomplete');
  final response1 = await placesApi.placeAutocomplete(
    input: 'amoeba',
    location: PlaceLocation(
      latitude: 37.76999,
      longitude: -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);
    }
  }
}
2
likes
0
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

License

unknown (license)

Dependencies

http, logging

More

Packages that depend on nova_places_api