address_search_field 2.1.0+1 address_search_field: ^2.1.0+1 copied to clipboard
An address search field which helps to autocomplete an address by a reference. It can be used to get Directions beetwen two points.
Address Search Field #
An address search field which helps to autocomplete an address by a reference. It can be used to get Directions beetwen two points. It uses HTTP, Google Maps for Flutter plugins. (This last plugin is to use compatible objects that can be converted). FlutterToast plugin is used to improve the frontend.
Getting Started #
To use this plugin, add address_search_field
as a dependency in your pubspec.yaml file. For example:
dependencies:
address_search_field: ^2.1.0+1
Permissions #
Android #
On Android you'll need to add the internet permission to your Android Manifest file (located under android/app/src/main). To do so add next lines as direct child of the <manifest>
tag:
<uses-permission android:name="android.permission.INTERNET"/>
Usage #
Import the package:
import 'package:address_search_field/address_search_field.dart';
GeoMethods #
GeoMethods(
googleApiKey: String,
language: String,
countryCode: String,
country: String,
city: String,
mode: String,
);
- This object make calls to Google APIs using the parameters set. It can do requests to Google places, geocode and directions APIs.
- Language support list here.
- List of countries here.
AddressDialog #
AddressDialog(
controller: TextEditingController(),
color: Color,
backgroundColor: Color,
hintText: String,
noResultText: String,
cancelText: String,
continueText: String,
useButtons: bool,
onDone: FutureOr<bool> Function(Address addressPoint),
geoMethods: GeoMethods
);
- This widget is a
Dialog
box to search a place or address in an autocompleted results list. - onDone
Function
let you work with the resultedAddress
from the search. When it returnstrue
theDialog
doespop()
. - It has a result object that helps this widget to work in a
RouteSearchBox
.
AddressField #
AddressField(
controller: TextEditingController(),
/// ... more variables of `TextFormField`
barrierDismissible: bool,
addressDialog: AddressDialogBuilder,
geoMethods: GeoMethods,
);
- This widget is a
TextFormField
thatonTap
shows aAddressDialog
. - It uses an
AddressDialogBuilder
object to build anAddressDialog
sharing variables like controller and geoMethods.
RouteSearchBox #
RouteSearchBox(
geoMethods: GeoMethods,
originBldr: AddressFieldBuilder,
destinationBldr: AddressFieldBuilder,
widgetBuilder: Widget Function(
BuildContext context,
AddressField originField,
AddressField destinationField,
Future<Directions> Function(List<Address> waypoints) getDirections,
),
);
- This widget use a custom
WidgetBuilder
with twoAddressField
to call Google Directions API and getDirections
beetwen two or more points. - It uses an
AddressFieldBuilder
object to build anAddressField
sharing variables like controller and geoMethods. - In its constructor it edits the
AddressFieldBuilder
to use theresult
variable connecting directly these two widgets. - The
widgetBuilder
lets you build a widget using twoAddressField
to get twoAddress
objects and be able to call Google Directions API bygetDirections
to finally get aDirections
object.
License #
MIT License