address_search_field 2.0.1 address_search_field: ^2.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.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.
AddressSearchDialog #
AddressSearchDialog(
controller: TextEditingController(),
color: Color,
backgroundColor: Color,
hintText: String,
noResultText: String,
cancelText: String,
continueText: String,
useButtons: bool,
onDone: FutureOr<bool> Function(Address addressPoint),
geoMethods: GeoMethods
result: Address
);
- 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()
. - The result object helps this widget to work in a
RouteSearchBox
.
AddressSearchField #
AddressSearchField(
controller: TextEditingController(),
decoration: InputDecoration(),
style: TextStyle(),
barrierDismissible: bool,
addressDialog: AddressDialogCtor,
geoMethods: GeoMethods,
);
- This widget is a
TextField
thatonTap
shows aAddressSearchDialog
. - It uses an
AddressDialogCtor
object to build anAddressSearchDialog
sharing variables like controller and geoMethods.
RouteSearchBox #
RouteSearchBox(
geoMethods: GeoMethods,
originCtrl: TextEditingController(),
originCtor: AddressFieldCtor,
destinationCtrl: TextEditingController(),
destinationCtor: AddressFieldCtor,
widgetBuilder: Widget Function(
BuildContext context,
AddressSearchField originField,
AddressSearchField destinationField,
Future<Directions> Function(List<Address> waypoints) getDirections,
),
);
- This widget use a custom
WidgetBuilder
with twoAddressSearchField
to call Google Directions API and getDirections
beetwen two or more points. - It uses an
AddressFieldCtor
object to build anAddressSearchField
sharing variables like controller and geoMethods. - In its constructor it edits the
AddressFieldCtor
to use theresult
variable connecting directly these two widgets. - The
widgetBuilder
lets you build a widget using twoAddressSearchField
to get twoAddress
objects and be able to call Google Directions API bygetDirections
to finally get aDirections
object.
License #
MIT License