Flutter library to help you consume Baato APIs.
- Search
- Reverse Geocoding
- Places
- Directions
This library is available at pub.dev. You can get the latest version from there. To get started, add the following to your package's pubspec.yaml file:
dependencies:
baato_api: ^1.0.3
You can install packages from the command line:
with Flutter: flutter pub get
Now in your Dart code, you can use : import 'package:baato_api/baato_api.dart';
After initializing Baato with your access token and the query, the searchQuery
method can be used to make requests to the Search API.
import 'package:baato_api/baato_api.dart';
import 'package:baato_api/models/search.dart';
void main() async {
String baatoAccessToken = "your-baato-access-token";
BaatoSearch baatoSearch = BaatoSearch.initialize(
query: 'your-query',
accessToken: baatoAccessToken,
type: 'school', //optional parameter
limit: 5, //optional parameter
);
//perform Search
SearchResponse response = await baatoSearch.searchQuery();
print(response);
}
import 'package:baato_api/baato_api.dart';
import 'package:baato_api/models/place.dart';
void main() async {
String baatoAccessToken = "your-baato-access-token";
BaatoReverse baatoReverse = BaatoReverse.initialize(
latLon: GeoCoord(lat, lon),
accessToken: baatoAccessToken,
);
//perform reverse Search
PlaceResponse reverse = await baatoReverse.reverseGeocode();
print(reverse);
}
import 'package:baato_api/baato_api.dart';
import 'package:baato_api/models/place.dart';
void main() async {
String baatoAccessToken = "your-baato-access-token";
BaatoPlace baatoPlace = BaatoPlace.initialize(
placeId: placeId, //placeId is required parameter
accessToken: baatoAccessToken, //accessToken is required parameter
);
//perform the place lookup
PlaceResponse placeResponse = await baatoPlace.getPlaceDetails();
print(placeResponse);
}
import 'package:baato_api/baato_api.dart';
import 'package:baato_api/models/route.dart';
void main() async {
var points = [];
points.add("27.717844,85.3248188");
points.add("27.6876224,85.33827");
String baatoAccessToken = "your-baato-access-token";
BaatoRoute baatoRoute = BaatoRoute.initialize(
accessToken: baatoAccessToken,
points: points,
mode: "car", //can be 'bike', 'car', 'foot'
alternatives: false, //optional parameter
instructions: false); //optional parameter
//get routes between start and destination point
RouteResponse response = await baatoRoute.getRoutes();
print(response);
}