zomato_dart 1.0.3

  • Readme
  • Changelog
  • Example
  • Installing
  • 53

ZomatoDart #

A wrapper for the Zomato API implemented in Dart #

https://developers.zomato.com/api

Usage: #

A user key must be provided to initialize the ZomatoDart object. Convenience methods are used to fetch responses and await Futures of the corresponding model:

await ZomatoDart(userKey).convenienceMethod()

Convenience Methods: #

  • .categories
  • .cities
  • .cuisines
  • .establishments
  • .locations
  • .locationDetails
  • .geocode
  • .restaurant
  • .restaurantSearch
  • .dailyMenus
  • .reviews

Notes #

  • Organization of the methods and models is based upon the organization of the API documentation.
  • This package is meant to be platform agnostic, in order to be usable on mobile, web and desktop.

1.0.2 #

  • Minor adjustment to comply with pub.dev analyzer

1.0.3 #

  • Added constructors to various models that didn't have them

example/example.dart

import 'package:zomato_dart/models/models.dart';
import 'package:zomato_dart/zomato_dart.dart';

/// Command Line Sample
/// Run with: $ dart example.dart {user-key}
void main(List<String> args) async {
  String userKey = args.first;
  print('Your Zomato user-key: $userKey');

  // var cats = await ZomatoDart(userKey).categories();
  // cats.forEach((p) => print("${p.name} ${p.id}"));

  // var cities = await ZomatoDart(userKey).cities(cityName: "Los Angeles", count: 5);
  // print(cities.length);

  // var collections = await ZomatoDart(userKey).collections();
  // print(collections.first.title);

  // // Be mindful of bad coordinates
  // var cuisines = await ZomatoDart(userKey).cuisines(latitude: "40", longitude: "-37");

  // // var cuisines = await ZomatoDart(userKey).cuisines(cityId:280);
  // print(cuisines.first.cuisineName);

  // var establishments = await ZomatoDart(userKey).establishments(cityId:280);
  // print(establishments.first.name);

  // var locations = await ZomatoDart(userKey).locations("Chelsea Market");
  // print(locations.first.title);

  // var locationdetail = await ZomatoDart(userKey).locationDetails(118273, "subzone");
  // print(locationdetail.bestRatedRestaurants.first.name);
  // print(locationdetail.bestRatedRestaurants.first.location.localityVerbose);
  // print(locationdetail.bestRatedRestaurants.first.photos.first.url);
  // print(locationdetail.bestRatedRestaurants.first.photos.first.user.name);
  // print(locationdetail.bestRatedRestaurants.first.toJson());

  // var geocode = await ZomatoDart(userKey).geocode("39.973609", "-75.128669");
  // print(geocode.link);
  // print(geocode.location.cityName);
  // print(geocode.popularity.subzone);
  // for (Restaurant res in geocode.nearbyRestaurants) {
  //   print(res.id);
  // }
  // print(geocode.nearbyRestaurants.first.toJson());

  // var restaurant = await ZomatoDart(userKey).restaurant("17016328");
  // print(restaurant.name);

  // var rq = await ZomatoDart(userKey).reviews("17016328");
  // // var rq = await ZomatoDart(userKey).reviews("17016328", start: 3);
  // print(rq.reviewsShown);
  // print(rq.userReviews.first.reviewText);

  var rs = await ZomatoDart(userKey).restaurantSearch(
    latitude: '39.973609',
    longitude: '-75.128669',
    categoryId: 7
  );

  print('Found: ${rs.resultsFound}');
  print('Shown: ${rs.resultsShown}');
  print('Start: ${rs.resultsStart}');
  print('Restaurant list length: ${rs.restaurants.length}'); 
  print(rs.restaurants.map((r) => r.toJson()));

  // var dms = await ZomatoDart(userKey).dailyMenus("16507624");
  // print(dms?.first?.dailyMenuId);
  // print(dms?.first?.dishes?.last?.name);
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  zomato_dart: ^1.0.3

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:zomato_dart/zomato_dart.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
7
Health:
Code health derived from static analysis. [more]
99
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
53
Learn more about scoring.

We analyzed this package on Jul 3, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.13

Health suggestions

Fix lib/zomato_dart.dart. (-1 points)

Analysis of lib/zomato_dart.dart reported 2 hints:

line 478 col 29: Don't type annotate initializing formals.

line 478 col 50: Use ; instead of {} for empty constructor bodies.

Format lib/models/category.dart.

Run dartfmt to format lib/models/category.dart.

Format lib/models/city.dart.

Run dartfmt to format lib/models/city.dart.

Format lib/models/cuisine.dart.

Run dartfmt to format lib/models/cuisine.dart.

Format lib/models/establishment.dart.

Run dartfmt to format lib/models/establishment.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.8.0 <3.0.0
http ^0.12.0+4 0.12.1
Transitive dependencies
charcode 1.1.3
collection 1.14.13
http_parser 3.1.4
meta 1.1.8
path 1.7.0
pedantic 1.9.0 1.9.1
source_span 1.7.0
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.2.0