geo_contacts 1.0.0
geo_contacts: ^1.0.0 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 #
- Obtain an API key for the Google Places API from the Google Cloud Console.
- 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');
}
}
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
GeoContactsExceptionfor 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.