openfoodfacts
3.32.0, released 11 days ago by openfoodfacts.org
Dart client for the Open Food Facts REST API.
WASM-readyRock solid
What it does
Provides typed objects and functions to read, search and edit food product data from the Open Food Facts database. Handles authentication, suggestions, and various product‑related endpoints.
AI-written summary of version 3.31.1, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need to fetch or submit food product information from Open Food Facts.
- You want a cross‑platform Dart/Flutter solution with ready‑made models and API helpers.
Skip it when
- You require offline‑only storage without network calls.
- You need a UI widget library rather than an API client.
Strengths
- Comprehensive coverage of Open Food Facts endpoints (read, write, search, suggestions).
- Typed models generated via json_annotation for easy use.
- Works on all Flutter platforms (mobile, web, desktop).
Weaknesses
- No built‑in caching; you must add your own solution.
- Relies on the public API – rate limits or downtime affect your app.
- Only useful for Open Food Facts; not a generic networking client.
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- Yes (build_runner)
- Direct dependencies
- 4
Add the package to pubspec.yaml; run `flutter pub get`. If you want generated JSON code, run `flutter pub run build_runner build`. No special permissions required.
import 'package:openfoodfacts/openfoodfacts.dart';
void main() async {
OpenFoodAPIConfiguration.userAgent = UserAgent(name: 'MyApp', url: 'https://example.com');
final product = await OpenFoodAPIClient.getProductV3('1234567890123');
print(product?.product?.productName);
}Works with
Packages commonly used together with openfoodfacts: ones it builds on, ones built on it, and its own family.