OpenFoodAPIConfiguration class

Allows to configure the behavior of the package.

All of the values are static, they only need to be set once at the beginning of the lifecycle of the app. They can be changed at any point later. Some methods allow to pass configurations which can be also set here, in these cases, the most local value is used. E.g.

  OpenFoodAPIConfiguration.userAgent = UserAgent(
    name: '<Name of your app>',
  );

  OpenFoodAPIConfiguration.globalLanguages = <OpenFoodFactsLanguage>[
    OpenFoodFactsLanguage.ENGLISH,
  ];

  // Uses german
  OpenFoodAPIClient.getProductUri(
    '0000000',
    language: OpenFoodFactsLanguage.GERMAN,
    ....
  );

  // Uses english again
  OpenFoodAPIClient.getProductUri(
      '0000000',
      ....
  );

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Properties

globalCountry OpenFoodFactsCountry?
A global way to specify the country code for queries, can be overwritten for each individual request by specifying the country code in the individual request configurations
getter/setter pair
globalLanguages List<OpenFoodFactsLanguage>?
A global way to specify the languages for queries, can be overwritten for each individual request by specifying the languages in the individual request configurations
getter/setter pair
globalUser User?
Defines a global user to avoid adding it to every request
getter/setter pair
userAgent UserAgent?
Defines a global userAgent to tell the backend the source of the request.
getter/setter pair
uuid String?
Defines a global uuid to tell the backend the source of the request.
getter/setter pair

Static Methods

computeCountryCode(OpenFoodFactsCountry? country, String? cc) String?
Returns the most relevant country code
getUser(User? user) User?
Returns the User to use, using a default value