✨ Editable search data collections
This commit is contained in:
@@ -25,13 +25,21 @@ class FoodDataController extends GetxController {
|
||||
await _prefs.setString("data_fdc_api_key", value);
|
||||
}
|
||||
|
||||
List<String>? getDataCollections() {
|
||||
return _prefs.getStringList("data_enabled_collections");
|
||||
}
|
||||
|
||||
Future<void> setDataCollections(List<String> value) async {
|
||||
await _prefs.setStringList("data_enabled_collections", value);
|
||||
}
|
||||
|
||||
Future<FoodDataQueryResponse> searchFood(String probe) async {
|
||||
final client = Dio();
|
||||
final resp = await client.get(
|
||||
'https://api.nal.usda.gov/fdc/v1/foods/search',
|
||||
queryParameters: {
|
||||
'query': probe,
|
||||
'dataType': 'Foundation',
|
||||
'dataType': getDataCollections()?.join(','),
|
||||
'pageSize': 25,
|
||||
'pageNumber': 1,
|
||||
'sortBy': 'dataType.keyword',
|
||||
|
Reference in New Issue
Block a user