Skip to content

baato/baato-flutter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pub

baato-api

Flutter library to help you consume Baato APIs.

Features

  • Search
  • Reverse Geocoding
  • Places
  • Directions

Implementation

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';

1. Search

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);
}

2. Reverse GeoCode

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);
}

3. Places

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);
}

4. Directions

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);
}

About

Flutter library to consume Baato APIs.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages