How emran92/flutter_google_places works
Project type and purpose
• This is a Flutter plugin package (“flutter_google_places”) providing Google Places autocomplete widgets.
• It exposes a simple Dart API for embedding autocomplete overlays or full-screen pickers in any Flutter app.
• An “example” subfolder contains a demo Flutter application (for Android and iOS) showing usage.
File structure
Top‐level:
• lib/
– flutter_google_places.dart (public entrypoint)
– src/ (internal implementation)
· places_autocomplete_field.dart
· places_autocomplete_form_field.dart
· flutter_google_places.dart (widget logic)
• example/ (demo app)
– android/, ios/ (native runner projects)
– lib/main.dart (example app UI)
– pubspec.yaml, gradle, Xcode config (standard Flutter project structure)
• pubspec.yaml (plugin metadata, dependencies: google_maps_webservice, flutter SDK, etc.)
• CI configs (.github), lint rules (analysis_options.yaml), docs (README.md, CHANGELOG.md)
README for additional insights
• Core dependency: [google_maps_webservice] which wraps HTTP calls to Google Maps Web Service APIs.
• Usage excerpt shows a widget API: PlacesAutocomplete.show(...) returning a Prediction.
• No native platform code—pure Dart/Flutter implementation.
Main components & their interactions
A. Example App (Flutter UI)
– main.dart initializes a MaterialApp and invokes the plugin widget.
B. Plugin Public API
– flutter_google_places.dart (exports PlacesAutocomplete, Prediction types)
C. Plugin Internal Modules
– PlacesAutocomplete widget (overlay or fullscreen)
– FormField & TextField wrappers for embedding in forms
D. Dependency: google_maps_webservice
– Wraps HTTP client (package:http) for contacting Google Places REST endpoints
E. External Service
– Google Maps Web Service (Places API) over HTTPS
[Data flow & interactions]
1. User taps input → Example App widget calls PlacesAutocomplete.show
2. Plugin builds Flutter overlay or full-screen route
3. As user types, plugin calls google_maps_webservice via HTTP
4. HTTP client issues GET to Google Places API, returns JSON
5. google_maps_webservice parses JSON → Plugin wraps into Prediction objects
6. Plugin updates UI list; user selects prediction → returned to Example App
Architectural patterns & design principles
• Modular Dart package: clear separation of public API vs src implementation
• Flutter Widget Composition: small reusable widgets (overlay, form field, list item)
• Dependency inversion: plugin delegates HTTP and JSON parsing to google_maps_webservice
• Clean API: single entrypoint, minimal surface area
• Example-driven documentation: ‘example’ app as integration smoke test
Detail without over-complication
• Dart modules under lib/src as one grouped component
• Pubspec.yaml declaring dependencies
• Flutter rendering pipeline abstractly (you don’t need the entire Flutter engine)
• Plugin’s boundary, its dependencies, and the external service