geo_contacts 1.1.1 copy "geo_contacts: ^1.1.1" to clipboard
geo_contacts: ^1.1.1 copied to clipboard

GeoContacts is a Dart package for managing geographical contacts.

GeoContacts #

  • GeoContacts is a Dart package that simplifies interaction with the Google Places API.
  • It enables you to search for nearby places based on a provided keyword and location, offering an intuitive way to retrieve information about places with contacts.

Features #

  • Search Places: Perform text-based searches for places using keywords and locations.
  • Retrieve Place Details: Fetch detailed information about a place, including its name, address, phone number, rating, types, business status, and website.
  • Rate Limiting: Avoid hitting API rate limits by configuring a delay between requests.
  • Customizable Results: Limit the number of results returned by the API.

Getting Started #

Prerequisites #

  1. Obtain an API key for the Google Places API from the Google Cloud Console.
  2. Enable the Places API for your project in the Google Cloud Console.

Installation #

Add the following to your pubspec.yaml:

dependencies:
    geo_contacts: ^1.0.0

Then, run:

flutter pub get

Usage #

Import the Package #

import 'package:geo_contacts/geo_contacts.dart';

Example #

void main() async {
    final geoContacts = GeoContacts(
        apiKey: 'YOUR_API_KEY',
        maxLimit: 10,
        apiRateLimitDurationMS: 500,
    );

    try {
        List<GeoContact> results = await geoContacts.searchPlaces('coffee shop', 'San Francisco');
        for (var place in results) {
            print('Name: ${place.name}');
            print('Address: ${place.address}');
            print('Phone: ${place.phone}');
            print('Rating: ${place.rating}');
            print('Website: ${place.website}');
            print('---');
        }
    } catch (e) {
        print('Error: $e');
    }
}

If Future function searchPlaces takes too much time then we may use searchPlacesStream to get the stream of List<GeoContact> whenever a new contact added

  // Print the details of each place found in the results
  await for (var partialResults in geoContacts.searchPlacesStream(
    'restaurant',
    'Ganesh Nagar, Delhi',
  )) {
    print('Items: ${partialResults.length}\nData: ${partialResults.last}');
  }

What data we receive in each contact #

Contact Details Table #

Name Address Business Status Rating Ratings Phone Website
Coffee House 123 Main St, SF OPERATIONAL 4.5 120 +1-555-123456 www.coffeehouse.com
Bookstore Hub 456 Elm St, SF OPERATIONAL 4.2 85 +1-555-654321 www.bookstorehub.com
Pizza Palace 789 Oak St, SF CLOSED_TEMPORARILY 4.8 200 +1-555-987654 www.pizzapalace.com
Tech World 101 Pine St, SF OPERATIONAL 4.7 150 +1-555-112233 www.techworld.com
Flower Boutique 202 Maple St, SF OPERATIONAL 4.3 95 +1-555-445566 www.flowerboutique.com

Parameters #

  • apiKey: Your Google Places API key (required).
  • maxLimit: Maximum number of results to return (default: 20).
  • apiRateLimitDurationMS: Delay in milliseconds between API requests (default: 500).

Additional Information #

  • API Key Security: Keep your API key secret and avoid exposing it in client-side code.
  • Error Handling: The package throws GeoContactsException for API errors or unexpected issues.
  • Contributions: Contributions are welcome! Feel free to open issues or submit pull requests on the GitHub repository.

For more details, refer to the Google Places API documentation.

0
likes
150
points
233
downloads

Publisher

verified publisherwaygosquad.com

Weekly Downloads

GeoContacts is a Dart package for managing geographical contacts.

Repository (GitHub)

Topics

#google-places #contacts #geolocation

Documentation

API reference

License

MIT (license)

Dependencies

dio

More

Packages that depend on geo_contacts