address_search_field 2.0.0+1 copy "address_search_field: ^2.0.0+1" to clipboard
address_search_field: ^2.0.0+1 copied to clipboard

outdated

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).

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.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 resulted Address from the search. When it returns true the Dialog does pop().
  • 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 that onTap shows a AddressSearchDialog.
  • It uses an AddressDialogCtor object to build an AddressSearchDialog 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 two AddressSearchField to call Google Directions API and get Directions beetwen two or more points.
  • It uses an AddressFieldCtor object to build an AddressSearchField sharing variables like controller and geoMethods.
  • In its constructor it edits the AddressFieldCtor to use the result variable connecting directly these two widgets.
  • The widgetBuilder lets you build a widget using two AddressSearchField to get two Address objects and be able to call Google Directions API by getDirections to finally get a Directions object.

License #

MIT License

94
likes
0
pub points
91%
popularity

Publisher

verified publisherjostech.dev

An address search field which helps to autocomplete an address by a reference. It can be used to get Directions beetwen two points.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter, google_maps_flutter, http

More

Packages that depend on address_search_field