repo_id
stringlengths 21
168
| file_path
stringlengths 36
210
| content
stringlengths 1
9.98M
| __index_level_0__
int64 0
0
|
|---|---|---|---|
mirrored_repositories/snippet_generator/lib/gen_parsers
|
mirrored_repositories/snippet_generator/lib/gen_parsers/models/stores.dart
|
import 'dart:async';
import 'dart:convert';
import 'package:dart_style/dart_style.dart';
import 'package:file_system_access/file_system_access.dart' as fs;
import 'package:flutter/widgets.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:mobx/mobx.dart';
import 'package:petitparser/petitparser.dart';
import 'package:snippet_generator/gen_parsers/models/predifined_parsers.dart';
import 'package:snippet_generator/gen_parsers/models/store_value.dart';
import 'package:snippet_generator/gen_parsers/models/token_value.dart';
import 'package:snippet_generator/gen_parsers/models/tokens.dart';
import 'package:snippet_generator/globals/pod_notifier.dart';
import 'package:snippet_generator/notifiers/app_notifier.dart';
import 'package:snippet_generator/notifiers/collection_notifier/list_notifier.dart';
import 'package:snippet_generator/notifiers/collection_notifier/map_notifier.dart';
import 'package:snippet_generator/types/root_store.dart';
import 'package:snippet_generator/types/type_models.dart';
import 'package:snippet_generator/utils/extensions.dart';
import 'package:snippet_generator/utils/persistence.dart';
import 'package:uuid/uuid.dart';
const _uuid = Uuid();
final _formatter = DartFormatter();
final testPod = Pod.notifier(1);
extension ButNotParser<T> on Parser<T> {
Parser<T> butNot(Parser not) {
return this.and().seq(not.end().not()).pick(0).cast();
}
}
GenerateParserStore useParserStore() {
return useRootStore().parserStore;
}
GenerateParserItem useSelectedParser() {
final store = useRootStore().parserStore;
final selectedItem = store.selectedItem;
useListenable(selectedItem);
return selectedItem.value!;
}
class GenerateParserStore {
late final persistence = GenerateParserStorePersistence(this);
final items = ListNotifier<GenerateParserItem>([]);
final selectedItem = AppNotifier<GenerateParserItem?>(null);
void addValues(Iterable<GenerateParserStoreValue> values) {
runInAction(() {
for (final value in values) {
addValue(value);
}
});
}
void addValue([GenerateParserStoreValue? value]) {
runInAction(() {
final item = value != null
? GenerateParserItem.fromValue(value)
: GenerateParserItem();
items.add(item);
selectedItem.value = item;
});
}
void removeItem(GenerateParserItem item) {
runInAction(() {
items.remove(item);
if (items.isEmpty) {
addValue();
} else if (selectedItem.value == item) {
selectedItem.value = items.first;
}
});
}
List<GenerateParserStoreValue> makeValues() {
return items.map((i) => i.makeValue()).toList();
}
}
class GenerateParserItem {
final String key;
factory GenerateParserItem({String? key}) {
return GenerateParserItem._(key: key)..init();
}
GenerateParserItem._({String? key}) : this.key = key ?? _uuid.v4();
factory GenerateParserItem.fromValue(GenerateParserStoreValue value) {
final v = GenerateParserItem._(key: value.key);
v.init(value);
return v;
}
final tokenKeys = ListNotifier<String>([]);
final tokens = MapNotifier<String, ParserTokenNotifier>();
final isDragging = AppNotifier(false);
late final filteredTokenKeys = Computed(() {
final text = searchText.value.toLowerCase();
if (text.isEmpty) {
return tokenKeys;
}
return tokenKeys.where((key) {
final tokenValue = tokens[key]!.value;
return tokenValue.name.toLowerCase().contains(text);
}).toList();
});
late final isFiltered = Computed(() {
return searchText.value.isNotEmpty;
});
final selectedTestTokenKey = AppNotifier('');
final scrollController = ScrollController();
late final selectedTestToken =
Computed(() => tokens[selectedTestTokenKey.value]!);
final showTokens = AppNotifier(true);
final searchText = TextNotifier();
final parserTestText = TextNotifier();
final name = TextNotifier();
GenerateParserStoreValue makeValue() {
final _tokens = tokens.values.map((t) => MapEntry(t.key, t.value)).toList();
return GenerateParserStoreValue(
key,
_tokens,
name: name.value,
);
}
void toggleShowTokens() {
final token = firstTokenInView();
print(token.value.name);
showTokens.value = !showTokens.value;
Future.delayed(const Duration(milliseconds: 10), () {
scrollTo(token);
});
}
void init([GenerateParserStoreValue? value]) {
runInAction(() {
if (value != null) {
name.value = value.name;
final incoming = Map.fromEntries(value.tokens.map((e) {
final value = ParserTokenNotifier(this, e.key);
value.notifier.value = e.value;
return MapEntry(e.key, value);
}));
final additionalKeys = incoming.keys.where(
(key) => !tokens.containsKey(key),
);
tokenKeys.addAll(additionalKeys);
tokens.addAll(incoming);
}
if (tokenKeys.isEmpty) {
addToken();
}
selectedTestTokenKey.value = tokenKeys.first;
});
}
ParserTokenNotifier firstTokenInView() {
int i = 0;
double offset = 0;
while (offset < scrollController.offset && i != tokenKeys.length - 1) {
final token = tokens[tokenKeys[i]]!;
offset += token.isShowing ? token.widgetHeight + 10 : 45 + 10;
i += 1;
}
return tokens[tokenKeys[i]]!;
}
void scrollTo(ParserTokenNotifier token) {
final index = tokenKeys.indexOf(token.key);
int i = 0;
double offset = 0;
while (i < index) {
final token = tokens[tokenKeys[i]]!;
offset += token.isShowing ? token.widgetHeight + 10 : 45 + 10;
i += 1;
}
scrollController.animateTo(
offset,
duration: const Duration(milliseconds: 300),
curve: Curves.easeIn,
);
}
ParserTokenNotifier addToken() {
return runInAction(() {
final token = ParserTokenNotifier(this, _uuid.v4());
tokens[token.key] = token;
tokenKeys.add(token.key);
scrollTo(token);
return token;
});
}
void removeToken(String key) {
runInAction(() {
tokens.remove(key);
tokenKeys.remove(key);
if (tokens.isEmpty) {
addToken();
}
if (key == selectedTestTokenKey.value) {
selectedTestTokenKey.value = tokenKeys.first;
}
});
}
String generateCode() {
final Set<PredifinedParser> predifined = {};
void _processToken(ParserToken token) {
token.value.map(
and: (list) => list.values.forEach(_processToken),
or: (list) => list.values.forEach(_processToken),
string: (_) {},
ref: (_) {},
butNot: (b) {
_processToken(b.item);
_processToken(b.not);
},
predifined: (value) {
predifined.add(value.value);
},
separated: (s) {
_processToken(s.item);
_processToken(s.separator);
},
);
}
for (final v in tokens.values) {
_processToken(v.value);
}
String code = """
import 'dart:convert';
import 'dart:ui';
import 'package:petitparser/petitparser.dart';
extension ButNotParser<T> on Parser<T> {
Parser<T> butNot(Parser not) {
return this.and().seq(not.end().not()).pick(0).cast();
}
}
${predifined.map((e) => e.dartDefinition()).whereType<String>().join('\n')}
${tokens.values.map((e) {
final t = e.value;
final expressionContext = e.expression.value;
final _type = t.dartType(tokens, parent: null);
final exp = e.hasLoop.value
? '''
SettableParser<$_type>? _${t.name};
Parser<$_type> get ${t.name} {
if (_${t.name} != null) {
return _${t.name}!;
}
_${t.name} = undefined();
final p = ${expressionContext.expression};
_${t.name}!.set(p);
return _${t.name}!;
}
'''
: 'final ${t.name} = ${expressionContext.expression};';
return '$exp\n\n$expressionContext';
}).join('\n\n')}
""";
try {
code = _formatter.format(code);
} catch (_) {}
return code;
}
late final parserTestResult = Computed(
() {
final parser = selectedTestToken.value.parser.value;
return parser.when(
ok: (parser) => parser.parse(parserTestText.value).toString(),
err: (err) => err.toString(),
);
},
);
}
class GenerateParserStorePersistence {
final GenerateParserStore store;
const GenerateParserStorePersistence(this.store);
Future<void> saveHive() async {
final parserBox = getBox<GenerateParserStoreValue>();
await parserBox.clear();
final values = store.makeValues();
final str = jsonEncode(values.map((v) => v.toJson()).toList());
await parserBox.addAll(values);
}
Future<void> loadHive() async {
final parserBox = getBox<GenerateParserStoreValue>();
final values = parserBox.values;
store.addValues(values);
if (store.items.isEmpty) {
store.addValue();
}
}
}
class TokenContext {
final List<TypeConfig> types = [];
String expression = '';
bool withinFlatten = false;
String _lastName = '';
String getName(String newName) {
if (newName.isEmpty) {
return _lastName;
} else {
_lastName = newName;
return newName;
}
}
TokenContext();
void add(TypeConfig value) {
if (withinFlatten) {
return;
}
types.add(value);
}
@override
String toString() {
return types
.map((e) => e.sourceCode.value)
.join('\n')
.replaceAll("import 'dart:ui';", '')
.replaceAll("import 'dart:convert';", '');
}
}
class ParserTokenNotifier {
final String key;
final GenerateParserItem store;
double widgetHeight = 190;
ParserTokenNotifier(this.store, this.key);
final showToken = AppNotifier(false);
final notifier = AppNotifier(
const ParserToken.def(
value: TokenValue.and([ParserToken.def()], flatten: false),
),
);
bool get isShowing => showToken.value || store.showTokens.value;
ParserToken get value => notifier.value;
late final parser = Computed<fs.Result<Parser, Object>>(() {
try {
final _p = undefined();
_p.set(_parser(value));
return fs.Ok(_p);
} catch (e) {
return fs.Err(e);
}
});
Parser _parser(ParserToken token) {
Parser result = token.value.when(
and: (list, flatten) {
Parser p = SequenceParser(list.map((e) => _parser(e)));
if (flatten) {
p = p.flatten();
}
return p;
},
or: (list) => ChoiceParser(list.map((e) => _parser(e))),
string: (s, isPattern, caseSensitive) {
if (caseSensitive) {
return isPattern ? pattern(s) : string(s);
} else {
return isPattern ? patternIgnoreCase(s) : stringIgnoreCase(s);
}
},
butNot: (item, not) => _parser(item).butNot(_parser(not)),
ref: (ref) => store.tokens[ref]?.parser.value.unwrap() ?? any(),
predifined: (pred) => pred.parser(),
separated: (item, separator, includeSeparators, separatorAtEnd) =>
_parser(item).separatedBy(
_parser(separator),
includeSeparators: includeSeparators,
optionalSeparatorAtEnd: separatorAtEnd,
),
);
if (token.negated) {
result = result.neg();
}
if (token.trim) {
result = result.trim();
}
return token.repeat.apply(result);
}
late final hasLoop = Computed(() {
final Set<ParserToken> s = {};
return _hasLoop(s, value);
});
bool _hasLoop(Set<ParserToken> s, ParserToken t) {
if (s.contains(t)) {
return t == this.value;
}
s.add(t);
return t.value.maybeMap(
and: (and) => and.values.any((element) => _hasLoop(s, element)),
or: (or) => or.values.any((element) => _hasLoop(s, element)),
ref: (ref) =>
ref.value == key ||
store.tokens.containsKey(ref.value) &&
_hasLoop(s, store.tokens[ref.value]!.value),
separated: (sep) => _hasLoop(s, sep.item) || _hasLoop(s, sep.separator),
orElse: () => false,
);
}
late final expression = Computed(() {
final context = TokenContext();
final expression = _expr(
context,
value,
parent: null,
);
context.expression = expression;
return context;
});
String _expr(
TokenContext context,
ParserToken token, {
required ParserToken? parent,
}) {
final _inner = token.value.when(
and: (list, flatten) {
final String _mapCode;
if (!flatten) {
final type = TypeConfig(
isDataValue: true,
isSerializable: true,
);
type.addVariant();
final _toStr = <String>[];
final _class = type.classes.first;
_class.typeConfig = type;
type.signatureNotifier.value = token.name.toClassName();
final _props = <PropertyField?>[];
if (list.length == 1 && list.first.value.isOr) {
} else {
for (final innerToken in list) {
if (innerToken.name.isEmpty) {
_props.add(null);
if (innerToken.value.isString) {
_toStr.add((innerToken.value as TokenValueString).value);
if (innerToken.trim) {
_toStr.add(' ');
}
}
continue;
}
final prop = _class.addProperty();
prop.classConfig = _class;
prop.nameNotifier.value = innerToken.name;
final _type = innerToken.dartType(store.tokens, parent: token);
final _optional = innerToken.repeat.min == 0;
prop.isRequiredNotifier.value = !_optional;
prop.typeNotifier.value = innerToken.repeat.canBeMany
? 'List<$_type>${_optional ? "?" : ""}'
: '$_type${_optional ? "?" : ""}';
_props.add(prop);
final _g = _optional
? '${prop.nameNotifier.value}!'
: prop.nameNotifier.value;
final v = innerToken.value;
final s = innerToken.repeat.canBeMany
? '\${$_g.join(" ")}'
: v is TokenValueSeparated &&
v.separator.value is TokenValueString
? "\${$_g.join('${(v.separator.value as TokenValueString).value}')}"
: '\${$_g}';
_toStr.add(_optional
? '\${${prop.nameNotifier.value} == null ? "" : "$s"}'
: s);
if (innerToken.trim) {
_toStr.add(' ');
}
}
context.add(type);
}
type.advancedConfig.customCodeNotifier.value = """
@override
String toString() {
return '${_toStr.map((e) => e == "'" ? "\\'" : e).join()}';
}
""";
_mapCode = list.length == 1 && list.first.value.isOr
? ''
// ignore: leading_newlines_in_multiline_strings
: '''.map((l) {
return ${type.name}(
${_props.mapIndex((p, i) => p == null ? '' : '${p.name}: ${list.length == 1 ? "l" : "l[$i]"} as ${p.type},').join()}
);
})''';
} else {
_mapCode = '.flatten()';
}
final _prev = context.withinFlatten;
context.withinFlatten = _prev || flatten;
final code = '(' +
list.map((e) => _expr(context, e, parent: token)).join(' & ') +
')$_mapCode';
if (!_prev && flatten) {
context.withinFlatten = false;
}
return code;
},
or: (list) {
final allStrings = list.every(
(element) => element.value.maybeMap(
and: (and) => and.flatten,
string: (string) => !string.isPattern,
orElse: () => false,
),
);
final TypeConfig type;
final _afterCode = <String>[];
if (allStrings) {
type = TypeConfig(
isSerializable: true,
isEnum: true,
);
type.signatureNotifier.value =
(parent?.name.toClassName() ?? '') + token.name.toClassName();
int _index = 0;
for (final innerToken in list) {
type.addVariant();
final _class = type.classes[_index++];
_class.typeConfig = type;
_class.nameNotifier.value = innerToken.value.maybeMap(
and: (and) => innerToken.name,
string: (string) => string.value,
orElse: () => throw Error(),
);
if (_class.name.toUpperCase() == _class.name) {
_class.nameNotifier.value = _class.name.toLowerCase();
}
_afterCode.add(
context.withinFlatten
? ''
: '.map((_) => ${type.signature}.${_class.name.asVariableName()})',
);
}
context.add(type);
} else {
type = TypeConfig(
isSerializable: true,
isDataValue: true,
isSumType: true,
);
type.sumTypeConfig.prefix.value =
parent?.name.toClassName() ?? token.name;
type.sumTypeConfig.enumDiscriminant.value = false;
type.signatureNotifier.value = token.dartType(
store.tokens,
parent: parent,
);
int _index = 0;
for (final innerToken in list) {
type.addVariant();
final _class = type.classes[_index++];
_class.typeConfig = type;
final nameAndType = innerToken.value.map(
and: (and) => and.flatten
? [
innerToken.name,
]
: [innerToken.name, innerToken.name.toClassName()],
or: (or) => [innerToken.name, innerToken.name.toClassName()],
string: (string) => [
string.isPattern
? innerToken.name
: innerToken.name.isNotEmpty
? innerToken.name
: string.value.asVariableName(),
'String'
],
predifined: (predifined) =>
[innerToken.name, predifined.value.toDartType()],
ref: (ref) {
final _refToken = store.tokens[ref.value];
return [
innerToken.name.isEmpty
? _refToken?.value.name ?? ''
: innerToken.name,
_refToken?.value.dartType(store.tokens, parent: token) ?? ''
];
},
butNot: (butNot) => [
innerToken.name.isEmpty ? butNot.item.name : innerToken.name,
butNot.item.dartType(store.tokens, parent: parent),
],
separated: (separated) => [
innerToken.name.isEmpty
? separated.item.name
: innerToken.name,
'List<${separated.item.dartType(
store.tokens,
parent: token,
)}>'
],
);
_class.nameNotifier.value = nameAndType.first.toClassName();
final prop = _class.addProperty();
prop.classConfig = _class;
prop.nameNotifier.value = 'value';
final _type = nameAndType.last;
prop.typeNotifier.value = innerToken.repeat.canBeMany
? 'List<$_type>'
: '$_type${innerToken.repeat.isOptionalSingle ? "?" : ""}';
_afterCode.add(
context.withinFlatten
? ''
: '.map((v) => ${type.signature}.${_class.name.asVariableName()}(value: v))',
);
}
type.advancedConfig.customCodeNotifier.value = '''
@override
String toString() {
return value.toString();
}
''';
context.add(type);
}
return '(' +
list
.mapIndex(
(e, i) => _expr(context, e, parent: token) + _afterCode[i],
)
.join(' | ') +
')${context.withinFlatten ? '' : '.cast<${type.signature}>()'}';
},
string: (string, isPattern, caseSensitive) {
final _c = string.contains("'") ? '"' : "'";
if (caseSensitive) {
return isPattern
? 'pattern($_c$string$_c)'
: string.length == 1
? 'char($_c$string$_c)'
: 'string($_c$string$_c)';
} else {
return isPattern
? 'patternIgnoreCase($_c$string$_c)'
: 'stringIgnoreCase($_c$string$_c)';
}
},
ref: (ref) => store.tokens[ref]?.value.name ?? '',
predifined: (pred) => pred.toDart(),
butNot: (item, butNot) => '${_expr(context, item, parent: token)}'
'.butNot(${_expr(context, butNot, parent: token)})',
separated: (item, separator, includeSeparators, separatorAtEnd) =>
'${_expr(context, item, parent: token)}.separatedBy<${item.dartType(store.tokens, parent: parent)}>(${_expr(
context,
separator,
parent: token,
)}, '
'includeSeparators: $includeSeparators, '
'optionalSeparatorAtEnd: $separatorAtEnd)');
return '$_inner${token.negated ? ".neg()" : ""}'
'${token.trim ? ".trim()" : ""}${token.repeat.toDart()}';
}
void setName(String name) {
notifier.value = notifier.value.copyWith(name: name);
}
void setTokenValue(TokenValue value) {
notifier.value = notifier.value.copyWith(value: value);
}
void setRepeat(RepeatRange repeat) {
notifier.value = notifier.value.copyWith(repeat: repeat);
}
}
extension ClassNameString on String {
String toClassName() {
String _value = this;
if (_value.toUpperCase() == _value) {
_value = _value.toLowerCase();
}
return _value.snakeToCamel(firstUpperCase: true);
}
}
// error name of variant in OR list
// error name unique property in AND
// error name of OR in AND
// error duplicate names
// error empty strings
// dont trim by default
// default name for references
// default trim fro top AND (using context) (only for inner items in AND)
// detect camelcase/pascalcase and normalize dart strings
// use raw for generated strings
| 0
|
mirrored_repositories/snippet_generator/lib/gen_parsers
|
mirrored_repositories/snippet_generator/lib/gen_parsers/models/tokens.dart
|
import 'dart:convert';
import 'package:petitparser/petitparser.dart';
import 'package:snippet_generator/gen_parsers/models/predifined_parsers.dart';
import 'package:snippet_generator/gen_parsers/models/stores.dart';
import 'package:snippet_generator/gen_parsers/models/token_value.dart';
import 'package:snippet_generator/widgets/make_table.dart';
// any
// digit
// letter
// int (min-max-unsigned)
// double (min-max-unsigned)
// whitespace
// bool (ignoreCase)
// pattern
// ignoreCase
// flatten
// trim
// not
// star *
// plus +
// repeat min-max
// times min=max
// optional
// separatedBy
class RepeatRange {
final int min;
final int? max;
const RepeatRange(this.min, [this.max]);
const RepeatRange.optional()
: min = 0,
max = 1;
const RepeatRange.star()
: min = 0,
max = null;
const RepeatRange.plus()
: min = 1,
max = null;
const RepeatRange.times(int times)
: min = times,
max = times;
bool get isOptionalSingle => min == 0 && isSingle;
bool get isOptionalMany => min == 0 && canBeMany;
bool get isStar => min == 0 && max == null;
bool get isPlus => min == 1 && max == null;
bool get isFixed => min == max;
bool get canBeMany => max == null || max! > 1;
bool get isSingle => max == 1;
String userString() {
if (isFixed) {
return min.toString();
} else if (max != null) {
return '$min-$max';
} else {
return '$min-*';
}
}
Parser apply(Parser parser) {
if (max == null) {
return parser.repeat(min, unbounded);
} else if (max == 1) {
return min == 0 ? parser.optional() : parser;
} else {
return parser.repeat(min, max);
}
}
String toDart() {
if (max == null) {
return min == 0
? '.star()'
: min == 1
? '.plus()'
: '.repeat($min, unbounded)';
} else if (max == 1) {
return min == 0 ? '.optional()' : '';
} else {
return '.repeat($min, $max)';
}
}
Map<String, Object?> toJson() {
return {
'min': min,
'max': max,
};
}
factory RepeatRange.fromJson(Map<String, dynamic> json) {
return RepeatRange(
json['min'] as int,
json['max'] as int?,
);
}
}
class ParserToken {
final String name;
final String? parentKey;
final TokenValue value;
final RepeatRange repeat;
final bool trim;
final bool negated;
const ParserToken({
required this.name,
required this.value,
required this.repeat,
required this.trim,
required this.negated,
required this.parentKey,
});
const ParserToken.def({
this.name = '',
this.value =
const TokenValue.string('', isPattern: false, caseSensitive: true),
this.repeat = const RepeatRange.times(1),
this.trim = true,
this.negated = false,
this.parentKey,
});
ParserToken copyWith({
String? name,
TokenValue? value,
RepeatRange? repeat,
bool? trim,
bool? negated,
Ref<String?>? parentKey,
}) {
return ParserToken(
name: name ?? this.name,
value: value ?? this.value,
repeat: repeat ?? this.repeat,
trim: trim ?? this.trim,
negated: negated ?? this.negated,
parentKey: parentKey != null ? parentKey.value : this.parentKey,
);
}
String dartType(
Map<String, ParserTokenNotifier> tokens, {
required ParserToken? parent,
}) {
return this.value.map(
and: (and) => and.flatten ? 'String' : this.name.toClassName(),
or: (or) =>
(parent?.name.toClassName() ?? '') + this.name.toClassName(),
string: (string) => 'String',
ref: (ref) =>
tokens[ref.value]?.value.dartType(tokens, parent: null) ?? '',
predifined: (predifined) => predifined.value.toDartType(),
butNot: (b) => b.item.dartType(tokens, parent: this),
separated: (separated) => 'List<${separated.item.dartType(
tokens,
parent: this,
)}>',
);
}
Map<String, Object?> toJson() {
return {
'name': name,
'value': value.toJson(),
'repeat': repeat.toJson(),
'trim': trim,
'negated': negated,
'parentKey': parentKey,
};
}
factory ParserToken.fromJson(Object? _map) {
final Map<String, Object?> map;
if (_map is ParserToken) {
return _map;
} else if (_map is String) {
map = jsonDecode(_map) as Map<String, dynamic>;
} else {
map = (_map! as Map).cast();
}
return ParserToken(
name: map['name']! as String,
value: TokenValue.fromJson(map['value']),
repeat: RepeatRange.fromJson(map['repeat']! as Map<String, dynamic>),
trim: map['trim']! as bool,
negated: map['negated']! as bool,
parentKey: map['parentKey'] as String?,
);
}
}
| 0
|
mirrored_repositories/snippet_generator/lib
|
mirrored_repositories/snippet_generator/lib/fields/color_field.dart
|
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart';
import 'package:flutter_colorpicker/flutter_colorpicker.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:flutter_portal/flutter_portal.dart';
import 'package:snippet_generator/utils/extensions.dart';
class ColorFieldRow extends HookWidget {
const ColorFieldRow({
Key? key,
required this.name,
required this.value,
required this.onChanged,
this.width = 180,
}) : super(key: key);
final String name;
final Color value;
final double width;
final void Function(Color) onChanged;
@override
Widget build(BuildContext context) {
return Row(
mainAxisSize: MainAxisSize.min,
children: [
ColorHoverButton(
onChanged: onChanged,
value: value,
),
SizedBox(width: width, child: SelectableText(name)),
],
);
}
}
class ColorHoverButton extends HookWidget {
const ColorHoverButton({
Key? key,
required this.value,
required this.onChanged,
}) : super(key: key);
final Color value;
final void Function(Color) onChanged;
@override
Widget build(BuildContext context) {
final showColorPicker = useState(false);
final isInside = useState(false);
const closeDuration = Duration(milliseconds: 130);
final animationController = useAnimationController(
duration: closeDuration,
);
final verticalOffset = useState(0.0);
final curvedAnimation = useMemoized(
() => animationController.drive(CurveTween(curve: Curves.easeOut)),
[animationController],
);
const cardHeight = 360.0;
useValueChanged<bool, void>(showColorPicker.value, (_previous, _result) {
if (showColorPicker.value) {
animationController.forward();
} else {
animationController.reverse();
}
});
useEffect(() {
Timer? timer;
if (isInside.value && !showColorPicker.value) {
timer = Timer(const Duration(milliseconds: 400), () {
showColorPicker.value = true;
});
} else if (!isInside.value && showColorPicker.value) {
timer = Timer(const Duration(milliseconds: 300), () {
showColorPicker.value = false;
});
}
return timer?.cancel;
}, [isInside.value, showColorPicker.value]);
Widget mouseRegion(Widget child) {
return MouseRegion(
onEnter: (_) {
isInside.value = true;
},
onExit: (_) {
isInside.value = false;
},
child: child,
);
}
return PortalEntry(
childAnchor: Alignment.centerRight,
portalAnchor: Alignment.centerLeft,
closeDuration: closeDuration,
visible: showColorPicker.value,
portal: Padding(
padding: EdgeInsets.only(
top: verticalOffset.value > 0 ? verticalOffset.value * 2 : 0,
bottom: verticalOffset.value < 0 ? verticalOffset.value * -2 : 0,
),
child: mouseRegion(
AnimatedBuilder(
animation: curvedAnimation,
builder: (context, snapshot) {
return Opacity(
opacity: curvedAnimation.value,
child: _picker(),
);
},
),
),
),
child: mouseRegion(
TextButton(
onPressed: () => showColorPicker.value = true,
child: Container(
height: 25,
width: 40,
margin: const EdgeInsets.symmetric(vertical: 1),
decoration: BoxDecoration(
color: value,
borderRadius: BorderRadius.circular(4),
border: Border.all(width: 1,
// color: Theme.of(context).shadowColor.withOpacity(0.2),
),
),
child: Builder(
builder: (context) {
final screenHeight = MediaQuery.of(context).size.height;
if (showColorPicker.value) {
SchedulerBinding.instance!.addPostFrameCallback(
(timeStamp) {
final bounds = context.globalPaintBounds;
if (bounds != null) {
const minMargin = 10.0;
final deltaTop =
bounds.centerRight.dy - cardHeight / 2 - minMargin;
final deltaBottom = screenHeight -
(bounds.centerRight.dy +
cardHeight / 2 +
minMargin);
if (deltaTop < 0) {
verticalOffset.value = -deltaTop;
} else if (deltaBottom < 0) {
verticalOffset.value = deltaBottom;
} else {
verticalOffset.value = 0;
}
}
},
);
}
return const SizedBox();
},
),
),
),
),
);
}
Widget _picker() {
return Card(
elevation: 4,
margin: const EdgeInsets.only(left: 8),
child: Container(
width: 274,
height: 360,
padding: const EdgeInsets.symmetric(vertical: 12),
child: Builder(
builder: (context) {
final mq = MediaQuery.of(context);
return MediaQuery(
data: mq.copyWith(size: Size(250, mq.size.height)),
child: ColorPicker(
pickerColor: value,
onColorChanged: onChanged,
colorPickerWidth: 250.0,
displayThumbColor: true,
paletteType: PaletteType.hsv,
pickerAreaBorderRadius:
const BorderRadius.all(Radius.circular(3)),
showLabel: true,
enableAlpha: true,
pickerAreaHeightPercent: 0.7,
),
);
},
),
),
);
}
// void _showColorPicker(BuildContext context) {
// showDialog(
// context: context,
// builder: (context) {
// return Dialog(
// child: Container(
// height: 400,
// width: 300,
// padding: const EdgeInsets.all(12),
// child: _picker(),
// ),
// );
// },
// );
// }
}
| 0
|
mirrored_repositories/snippet_generator/lib
|
mirrored_repositories/snippet_generator/lib/fields/fields.dart
|
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:snippet_generator/fields/base_fields.dart';
import 'package:snippet_generator/fields/color_field.dart';
import 'package:snippet_generator/fields/enum_fields.dart';
import 'package:snippet_generator/fields/flutter_border_fields.dart';
import 'package:snippet_generator/fields/flutter_fields.dart';
import 'package:snippet_generator/fields/text_theme_fields.dart';
import 'package:snippet_generator/globals/props_serializable.dart';
import 'package:snippet_generator/themes/text_themes.dart';
import 'package:stack_portal/resizable.dart';
typedef FieldFunc<T> = Widget Function(PropClass<T>);
class GlobalFields {
static final Map<Type, _FunctionWrapper<Object?>> _map = {};
static Widget? get<T>(PropClass<T> notifier) {
final builder = _map[notifier.type];
return builder?.build(notifier);
}
static void add<T extends Object>(FieldFunc<T?> builder) {
final _wrapper = _FunctionWrapper(builder);
_map[T] = _wrapper;
_addNullable<T?>(_wrapper);
}
static void _addNullable<T>(_FunctionWrapper<T?> wrapper) {
_map[T] = wrapper;
}
static void init() {
add<Alignment>(
(notifier) => AlignmentInput(
key: ValueKey(notifier.name),
set: notifier.set,
value: notifier.value,
),
);
add<EdgeInsetsGeometry>(
(notifier) => PaddingInput(
key: ValueKey(notifier.name),
set: notifier.set,
value: notifier.value,
),
);
add<double>(
(notifier) => DefaultCardInput(
label: notifier.name,
children: [
DoubleInput(
label: notifier.name,
onChanged: notifier.set,
value: notifier.value,
),
],
),
);
add<int>(
(notifier) => DefaultCardInput(
label: notifier.name,
children: [
IntInput(
label: notifier.name,
onChanged: notifier.set,
value: notifier.value,
),
],
),
);
add<bool>(
(notifier) => DefaultCardInput(
label: notifier.name,
children: [
Switch(
onChanged: notifier.set,
value: notifier.value!,
),
],
),
);
add<Size>((notifier) => SizeInput(notifier: notifier));
add<Color>((notifier) => ColorInput(notifier: notifier));
add<InputBorder>((notifier) => InputBorderInput(notifier: notifier));
add<BorderSide>((notifier) => BorderSideInput(notifier: notifier));
add<BorderRadius>((notifier) => BorderRadiusInput(notifier: notifier));
add<TextTheme>((notifier) => TextThemeInput(
set: notifier.set,
key: ValueKey(notifier.name),
value: notifier.value,
));
add<TextStyle>((notifier) {
final n = notifier;
if (n is TextStyleNotifier) {
return PropsForm(
props: n.props,
);
} else {
return Container();
}
});
setUpEnumFields();
}
}
class _FunctionWrapper<T> {
final FieldFunc<T> _func;
_FunctionWrapper(this._func);
Widget build(PropClass<T> notifier) {
return FocusTraversalGroup(
child: AnimatedBuilder(
animation: notifier,
builder: (context, _child) {
return _func(notifier);
},
),
);
}
}
class PropsForm extends StatelessWidget {
const PropsForm({
Key? key,
required this.props,
}) : super(key: key);
final Iterable<SerializableProp> props;
@override
Widget build(BuildContext context) {
final colorProps = props.whereType<PropClass<Color?>>().toSet();
final boolProps = props.whereType<PropClass<bool?>>().toSet();
final numProps = props.whereType<PropClass<num?>>().toSet();
return FocusTraversalGroup(
child: SizedBox(
height: 300,
child: SingleScrollable(
padding: const EdgeInsets.only(right: 6),
child: Wrap(
alignment: WrapAlignment.center,
crossAxisAlignment: WrapCrossAlignment.center,
children: [
FocusTraversalGroup(
child: Column(
children: [
...colorProps.map(
(notifier) => AnimatedBuilder(
animation: notifier,
builder: (context, _) => ColorFieldRow(
name: notifier.name,
onChanged: notifier.set,
value: notifier.value ?? Colors.white,
),
),
)
],
),
),
FocusTraversalGroup(
child: Column(
children: [
...boolProps.map(
(notifier) => SizedBox(
width: 180,
child: Row(
children: [
AnimatedBuilder(
animation: notifier,
builder: (context, _) => Checkbox(
onChanged: (value) => notifier.set(value!),
value: notifier.value,
),
),
Expanded(
child: Text(notifier.name),
),
],
),
),
)
],
),
),
FocusTraversalGroup(
child: Column(
children: [
...numProps.map(
(notifier) => SizedBox(
width: 150,
child: AnimatedBuilder(
animation: notifier,
builder: (context, _) {
if (notifier is PropClass<int?>) {
return IntInput(
onChanged: (value) => notifier.set(value!),
value: notifier.value,
label: notifier.name,
);
} else {
return DoubleInput(
onChanged: (value) => notifier.set(value!),
value: notifier.value as double?,
label: notifier.name,
);
}
},
),
),
)
],
),
),
...props
.cast<PropClass<Object?>>()
.where((p) =>
!colorProps.contains(p) &&
!boolProps.contains(p) &&
!numProps.contains(p))
.map(GlobalFields.get)
.whereType<Widget>()
],
),
),
),
);
}
}
class DefaultCardInput extends StatelessWidget {
final List<Widget> children;
final String label;
const DefaultCardInput({
Key? key,
required this.label,
required this.children,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return Card(
child: Container(
width: 150,
padding: const EdgeInsets.all(12),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Align(
alignment: Alignment.centerLeft,
child: Text(label),
),
...children,
],
),
),
);
}
}
abstract class PropClass<T> implements ValueListenable<T> {
Type get type;
String get name;
void set(T value);
@override
T get value;
factory PropClass.fromNotifier(
String name,
ValueNotifier<T> valueNotifier,
) = _NotifierPropClass<T>;
// factory PropClass.fromStream(
// String name,
// T initialValue,
// StreamController<T> valueNotifier,
// ) = _StreamPropClass<T>;
}
class _NotifierPropClass<T> implements PropClass<T> {
@override
final String name;
final ValueNotifier<T> valueNotifier;
const _NotifierPropClass(this.name, this.valueNotifier);
@override
void set(T value) {
valueNotifier.value = value;
}
@override
T get value => valueNotifier.value;
@override
Type get type => T;
@override
void addListener(VoidCallback listener) {
valueNotifier.addListener(listener);
}
@override
void removeListener(VoidCallback listener) {
valueNotifier.removeListener(listener);
}
}
// class _StreamPropClass<T> implements PropClass<T> {
// @override
// final String name;
// T _value;
// final StreamController<T> controller;
// _StreamPropClass(this.name, this._value, this.controller) {
// controller.stream.listen((event) {
// _value = event;
// });
// }
// @override
// void set(T value) {
// controller.add(value);
// }
// @override
// T get value => _value;
// @override
// Type get type => T;
// }
| 0
|
mirrored_repositories/snippet_generator/lib
|
mirrored_repositories/snippet_generator/lib/fields/flutter_fields.dart
|
import 'package:flutter/material.dart';
import 'package:flutter_colorpicker/flutter_colorpicker.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:snippet_generator/fields/base_fields.dart';
import 'package:snippet_generator/fields/fields.dart';
import 'package:snippet_generator/parsers/widget_parsers/flutter_props_parsers.dart';
class AlignmentInput extends HookWidget {
const AlignmentInput({
required ValueKey<String> key,
Alignment? value,
required this.set,
}) : value = value ?? const Alignment(0, 0),
super(key: key);
@override
ValueKey<String> get key => super.key as ValueKey<String>;
final void Function(Alignment) set;
final Alignment value;
@override
Widget build(BuildContext context) {
final controllerL = useTextEditingController();
final controllerR = useTextEditingController();
useEffect(() {
if (double.tryParse(controllerL.text) != value.x) {
controllerL.value =
controllerL.value.copyWith(text: value.x.toString());
}
if (double.tryParse(controllerR.text) != value.y) {
controllerR.value =
controllerR.value.copyWith(text: value.y.toString());
}
return () {};
}, [value]);
return Card(
child: Container(
width: 200,
height: 150,
padding: const EdgeInsets.all(12),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Align(
alignment: Alignment.centerLeft,
child: Text(key.value),
),
Row(
children: [
Expanded(
child: TextField(
controller: controllerL,
decoration: const InputDecoration(labelText: 'delta x'),
onChanged: (String dx) {
final dxNum = double.tryParse(dx);
if (dxNum != null) {
set(Alignment(dxNum, value.y));
}
},
),
),
const SizedBox(width: 20),
Expanded(
child: TextField(
controller: controllerR,
decoration: const InputDecoration(labelText: 'delta y'),
onChanged: (String dy) {
final dyNum = double.tryParse(dy);
if (dyNum != null) {
set(Alignment(value.x, dyNum));
}
},
),
),
],
),
DropdownButton<Alignment>(
value: alignmentList.contains(value) ? value : null,
items: alignmentList
.map(
(e) => DropdownMenuItem(
value: e,
key: ValueKey(e),
child: Text(e.toString().split('.')[1]),
),
)
.toList(),
onChanged: (v) {
if (v != null) set(v);
},
),
],
),
),
);
}
}
class PaddingInput extends HookWidget {
const PaddingInput({
required ValueKey<String> key,
EdgeInsetsGeometry? value,
required this.set,
}) : _value = value ?? EdgeInsets.zero,
super(key: key);
final EdgeInsetsGeometry _value;
// TODO: support directional
final void Function(EdgeInsets) set;
static EdgeInsets _mapEdgeInsets(EdgeInsetsGeometry v) {
if (v is EdgeInsets) {
return v;
} else if (v is EdgeInsetsDirectional) {
return EdgeInsets.only(
bottom: v.bottom,
left: v.start,
right: v.end,
top: v.top,
);
} else {
throw Exception();
}
}
@override
Widget build(BuildContext context) {
final key = this.key! as ValueKey<String>;
final value = _mapEdgeInsets(_value);
return Card(
child: Container(
width: 240,
padding: const EdgeInsets.all(12),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Align(
alignment: Alignment.centerLeft,
child: Text(key.value),
),
Row(
children: [
Expanded(
child: DoubleInput(
label: 'horizontal',
value: value.hasHorizontal ? value.left : null,
onChanged: (v) {
set(value.copyWith(left: v, right: v));
},
),
),
const SizedBox(width: 15),
Expanded(
child: DoubleInput(
label: 'top',
value: value.top,
onChanged: (v) {
set(value.copyWith(top: v));
},
),
),
const SizedBox(width: 15),
Expanded(
child: DoubleInput(
label: 'vertical',
value: value.hasVertical ? value.top : null,
onChanged: (v) {
set(value.copyWith(top: v, bottom: v));
},
),
),
],
),
Row(
children: [
Expanded(
child: DoubleInput(
label: 'left',
value: value.left,
onChanged: (v) {
set(value.copyWith(left: v));
},
),
),
const SizedBox(width: 15),
Expanded(
child: DoubleInput(
label: 'all',
value: value.hasAll ? value.left : null,
onChanged: (v) {
// TODO:
set(EdgeInsets.all(v ?? 0));
},
),
),
const SizedBox(width: 15),
Expanded(
child: DoubleInput(
label: 'right',
value: value.right,
onChanged: (v) {
set(value.copyWith(right: v));
},
),
),
],
),
Row(
children: [
const Spacer(),
const SizedBox(width: 15),
Expanded(
child: DoubleInput(
label: 'bottom',
value: value.bottom,
onChanged: (v) {
set(value.copyWith(bottom: v));
},
),
),
const SizedBox(width: 15),
const Spacer(),
],
),
],
),
),
);
}
}
extension ExtEdgeInsets on EdgeInsets {
bool get hasHorizontal => left == right;
bool get hasVertical => top == bottom;
bool get hasAll => left == right && top == bottom && left == bottom;
}
class SizeInput extends StatelessWidget {
const SizeInput({
Key? key,
required this.notifier,
}) : super(key: key);
final PropClass<Size?> notifier;
@override
Widget build(BuildContext context) {
return DefaultCardInput(
label: notifier.name,
children: [
DoubleInput(
label: 'width',
onChanged: (w) => notifier.set(
w == null ? null : Size(w, notifier.value?.height ?? 0),
),
value: notifier.value?.width,
),
DoubleInput(
label: 'height',
onChanged: (h) => notifier.set(
h == null ? null : Size(notifier.value?.width ?? 0, h),
),
value: notifier.value?.height,
)
],
);
}
}
// class TextStyleInput extends HookWidget {
// const TextStyleInput({Key? key}) : super(key: key);
// @override
// Widget build(BuildContext context) {
// final textTheme = Theme.of(context).textTheme;
// final style = useState(TextStyleEnum.bodyText1);
// return ButtonSelect<TextStyleEnum>(
// onChange: (v) => style.value = v,
// options: TextStyleEnum.values,
// asString: (b) => b.toEnumString(),
// selected: style.value,
// );
// }
// }
class ColorInput extends StatelessWidget {
const ColorInput({
Key? key,
required this.notifier,
}) : super(key: key);
final PropClass<Color?> notifier;
@override
Widget build(BuildContext context) {
return Card(
child: Container(
width: 250,
padding: const EdgeInsets.all(12),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Align(
alignment: Alignment.centerLeft,
child: Text(notifier.name),
),
const SizedBox(height: 5),
Builder(builder: (context) {
final mq = MediaQuery.of(context);
return MediaQuery(
data: mq.copyWith(size: Size(250, mq.size.height)),
child: ColorPicker(
pickerColor: notifier.value ?? Colors.black,
onColorChanged: notifier.set,
colorPickerWidth: 250.0,
pickerAreaHeightPercent: 0.7,
enableAlpha: true,
displayThumbColor: true,
showLabel: true,
paletteType: PaletteType.hsv,
pickerAreaBorderRadius: const BorderRadius.all(
Radius.circular(4.0),
),
),
);
}),
],
),
),
);
}
}
| 0
|
mirrored_repositories/snippet_generator/lib
|
mirrored_repositories/snippet_generator/lib/fields/text_theme_fields.dart
|
import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:snippet_generator/widgets/context_menu_portal.dart';
import 'package:url_launcher/url_launcher.dart';
class TextThemeInput extends HookWidget {
const TextThemeInput({
required ValueKey<String> key,
TextTheme? value,
required this.set,
}) : value = value ?? const TextTheme(),
super(key: key);
final TextTheme value;
final void Function(TextTheme) set;
static final _lowercaseFonts =
GoogleFonts.asMap().map((e, v) => MapEntry(e.toLowerCase(), e));
@override
Widget build(BuildContext context) {
final controller = useTextEditingController();
final focusNode = useFocusNode();
final lowercaseText = useState(controller.text);
useListenable(focusNode);
Future<void> fetch() async {
if (GoogleFonts.asMap().containsKey(controller.text)) {
final _theme = GoogleFonts.getTextTheme(controller.text);
set(_theme);
}
}
final found = _lowercaseFonts.entries
.where((k) => k.key.contains(lowercaseText.value));
return Align(
child: SizedBox(
width: 300,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
const Text('Font Family'),
TextButton(
onPressed: () {
launch('https://fonts.google.com/');
},
child: Text(
'Open Google Fonts',
style: Theme.of(context).textTheme.button!.copyWith(
decoration: TextDecoration.underline,
),
),
),
],
),
Row(
children: [
Expanded(
child: MenuPortalEntry(
options: found
.map(
(e) => TextButton(
onPressed: () {
controller.value = TextEditingValue(
text: e.value,
selection: TextSelection.collapsed(
offset: e.value.length,
),
);
lowercaseText.value =
controller.text.toLowerCase();
},
key: Key(e.value),
child: Text(e.value),
),
)
.toList(),
width: 200,
isVisible: controller.text.isNotEmpty &&
focusNode.hasPrimaryFocus &&
(found.length != 1 ||
found.first.value != controller.text),
child: TextField(
controller: controller,
onChanged: (textStr) {
lowercaseText.value = textStr.toLowerCase();
},
focusNode: focusNode,
),
),
),
TextButton(
onPressed: fetch,
child: const Text('Fetch'),
)
],
),
],
),
),
);
}
}
| 0
|
mirrored_repositories/snippet_generator/lib
|
mirrored_repositories/snippet_generator/lib/fields/button_select_field.dart
|
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/scheduler.dart';
import 'package:flutter_hooks/flutter_hooks.dart' show HookWidget, useState;
import 'package:snippet_generator/utils/extensions.dart';
// @freezed
// class SelectOption{
// factory SelectOption.enums()
// }
class ButtonSelect<T> extends HookWidget {
const ButtonSelect({
Key? key,
required this.options,
required this.selected,
required this.onChange,
this.asString,
this.alwaysButtons = false,
this.wrapHorizontal = false,
}) : super(key: key);
final Iterable<T> options;
final T? selected;
final String Function(T)? asString;
final void Function(T) onChange;
final bool alwaysButtons;
final bool wrapHorizontal;
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
final isDropdown = useState(false);
final checkedShouldBeDropdown = useState(false);
double? buttonTop;
String _asString(T e) =>
asString == null ? e.toString() : asString!.call(e);
if (isDropdown.value && !alwaysButtons) {
return Align(
child: CustomDropdownField(
options: options,
selected: selected,
asString: _asString,
onChange: onChange,
),
);
}
Widget _buildButtons(List<Widget> children) {
if (wrapHorizontal) {
return Wrap(
alignment: WrapAlignment.center,
crossAxisAlignment: WrapCrossAlignment.center,
runAlignment: WrapAlignment.center,
children: children,
);
} else {
return ButtonBar(
alignment: MainAxisAlignment.center,
layoutBehavior: ButtonBarLayoutBehavior.constrained,
buttonPadding: EdgeInsets.zero,
children: children,
);
}
}
return Visibility(
// TODO: can be calculate when we need a dropdown?
visible: options.length <= 3 || checkedShouldBeDropdown.value,
maintainState: true,
child: Padding(
padding: const EdgeInsets.only(top: 8.0),
child: _buildButtons(
options.map((e) {
final s = _asString(e);
return TextButton(
key: Key(s),
onPressed: () => onChange(e),
style: TextButton.styleFrom(
backgroundColor: e == selected ? theme.colorScheme.primary : null,
primary: e == selected ? theme.colorScheme.onPrimary : null
),
child: Builder(builder: (context) {
SchedulerBinding.instance!.addPostFrameCallback((timeStamp) {
// print("Text ${ctx.size} ${ctx.globalPaintBounds}");
if (buttonTop == null) {
buttonTop = context.globalPaintBounds!.top;
return;
}
if (!checkedShouldBeDropdown.value) {
if (buttonTop != context.globalPaintBounds!.top) {
isDropdown.value = options.length > 3;
}
checkedShouldBeDropdown.value = true;
}
});
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 6.0),
child: Text(s),
);
}),
);
}).toList(),
),
),
);
}
}
class CustomDropdownField<T> extends HookWidget {
final Iterable<T> options;
final T? selected;
final String Function(T) asString;
final void Function(T) onChange;
final EdgeInsetsGeometry? padding;
const CustomDropdownField({
Key? key,
required this.selected,
required this.asString,
required this.onChange,
required this.options,
this.padding,
}) : super(key: key);
@override
Widget build(BuildContext context) {
final isHovering = useState(false);
final _baseColor = Theme.of(context).colorScheme.onSurface;
return MouseRegion(
cursor: SystemMouseCursors.click,
onEnter: (_) => isHovering.value = true,
onExit: (_) => isHovering.value = false,
child: Container(
decoration: BoxDecoration(
color: isHovering.value
? _baseColor.withOpacity(0.08)
: _baseColor.withOpacity(0.05),
borderRadius: BorderRadius.circular(3),
),
padding: padding ??
const EdgeInsets.only(
left: 8,
right: 8,
bottom: 8,
top: 7,
),
child: DropdownButton<T>(
value: selected,
isExpanded: true,
isDense: true,
items: options.map((e) {
final s = asString(e);
return DropdownMenuItem<T>(
value: e,
child: Center(
child: Text(
s,
overflow: TextOverflow.ellipsis,
),
),
);
}).toList(),
onChanged: (value) {
if (value != null) onChange(value);
},
),
),
);
}
}
| 0
|
mirrored_repositories/snippet_generator/lib
|
mirrored_repositories/snippet_generator/lib/fields/base_fields.dart
|
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:snippet_generator/utils/formatters.dart';
class DoubleInput extends HookWidget {
final String label;
final void Function(double?) onChanged;
final double? value;
const DoubleInput({
Key? key,
required this.label,
required this.onChanged,
required this.value,
}) : super(key: key);
@override
Widget build(BuildContext context) {
final input = useTextInput<double>(
value,
onChanged,
doubleStringInput,
);
return TextField(
controller: input.controller,
decoration: InputDecoration(
labelText: label,
errorText: input.errorIfTouchedNotEmpty,
),
onChanged: input.onChangedString,
inputFormatters: [Formatters.onlyDigitsOrDecimal],
focusNode: input.focusNode,
keyboardType: TextInputType.number,
);
}
}
class IntInput extends HookWidget {
final String label;
final void Function(int?) onChanged;
final int? value;
const IntInput({
Key? key,
required this.label,
required this.onChanged,
required this.value,
}) : super(key: key);
@override
Widget build(BuildContext context) {
const _size = 20.0;
final input = useTextInput<int>(
value,
onChanged,
intStringInput,
);
final _buttonStyle = TextButton.styleFrom(
padding: EdgeInsets.zero,
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
fixedSize: const Size(_size, _size),
minimumSize: const Size(_size, _size),
);
return Row(
children: [
Expanded(
child: TextField(
controller: input.controller,
decoration: InputDecoration(
labelText: label,
errorText: input.errorIfTouchedNotEmpty,
),
onChanged: input.onChangedString,
inputFormatters: [Formatters.onlyDigits],
focusNode: input.focusNode,
keyboardType: TextInputType.number,
),
),
Column(
mainAxisSize: MainAxisSize.min,
children: [
TextButton(
onPressed: value == null
? null
: () {
onChanged(value! + 1);
},
style: _buttonStyle,
child: const Icon(Icons.arrow_drop_up, size: _size - 2),
),
TextButton(
onPressed: value == null
? null
: () {
onChanged(value! - 1);
},
style: _buttonStyle,
child: const Icon(Icons.arrow_drop_down, size: _size - 2),
),
],
),
],
);
}
}
final doubleStringInput = StringInputSerializer<double>(
double.tryParse,
(v) {
final str = v.toString();
return str.endsWith('.0') ? str.substring(0, str.length - 2) : str;
},
);
String objectToString(Object v) => v.toString();
const intStringInput = StringInputSerializer<int>(
int.tryParse,
objectToString,
);
class StringInputSerializer<T> {
final T? Function(String) fromString;
final String Function(T) asString;
final String? Function(String, T?)? validate;
const StringInputSerializer(
this.fromString,
this.asString, {
this.validate,
});
}
TextInputParams useTextInput<T>(
T? value,
void Function(T?) onChanged,
StringInputSerializer<T> serializer,
) {
final controller = useTextEditingController();
final focusNode = useFocusNode();
final error = useState<String?>(null);
final isTouched = useState(false);
useEffect(() {
if (value == null) {
controller.value = controller.value.copyWith(text: '');
} else if (serializer.fromString(controller.text) != value) {
error.value = null;
controller.value = controller.value.copyWith(
text: serializer.asString(value),
);
}
}, [serializer, value]);
final onChangedString = useMemoized(() {
void _onControllerChange(String newString) {
final newValue = serializer.fromString(newString);
final newError = serializer.validate?.call(newString, newValue);
if (newValue != null && newError == null) {
if (value != newValue) {
onChanged(newValue);
}
error.value = null;
} else if (newString.isEmpty) {
if (value != newValue) {
onChanged(null);
}
} else {
error.value = newError ?? '';
}
}
return _onControllerChange;
}, [serializer, value, onChanged]);
useValueChanged<bool, void>(focusNode.hasPrimaryFocus, (prev, _) {
if (prev && !focusNode.hasPrimaryFocus) {
isTouched.value = true;
}
});
return TextInputParams(
controller: controller,
focusNode: focusNode,
error: error.value,
isTouched: isTouched.value,
onChangedString: onChangedString,
);
}
class TextInputParams {
final TextEditingController controller;
final FocusNode focusNode;
final String? error;
final bool isTouched;
final void Function(String) onChangedString;
const TextInputParams({
required this.controller,
required this.focusNode,
required this.error,
required this.isTouched,
required this.onChangedString,
});
String? get errorIfTouched => isTouched ? error : null;
String? get errorIfTouchedNotEmpty =>
isTouched && controller.text.isNotEmpty ? error : null;
}
| 0
|
mirrored_repositories/snippet_generator/lib
|
mirrored_repositories/snippet_generator/lib/fields/enum_fields.dart
|
import 'package:flutter/material.dart';
import 'package:snippet_generator/fields/button_select_field.dart';
import 'package:snippet_generator/fields/fields.dart';
const add = GlobalFields.add;
void setUpEnumFields() {
add<MaterialTapTargetSize>((notifier) =>
EnumInput(notifier: notifier, enumList: MaterialTapTargetSize.values));
add<MainAxisAlignment>((notifier) =>
EnumInput(notifier: notifier, enumList: MainAxisAlignment.values));
add<CrossAxisAlignment>((notifier) =>
EnumInput(notifier: notifier, enumList: CrossAxisAlignment.values));
add<MainAxisSize>((notifier) =>
EnumInput(notifier: notifier, enumList: MainAxisSize.values));
add<Axis>((notifier) => EnumInput(notifier: notifier, enumList: Axis.values));
add<FlexFit>(
(notifier) => EnumInput(notifier: notifier, enumList: FlexFit.values));
add<TextOverflow>((notifier) =>
EnumInput(notifier: notifier, enumList: TextOverflow.values));
add<TextAlign>(
(notifier) => EnumInput(notifier: notifier, enumList: TextAlign.values));
add<TextDirection>((notifier) =>
EnumInput(notifier: notifier, enumList: TextDirection.values));
add<VerticalDirection>((notifier) =>
EnumInput(notifier: notifier, enumList: VerticalDirection.values));
add<TextBaseline>((notifier) =>
EnumInput(notifier: notifier, enumList: TextBaseline.values));
add<Clip>((notifier) => EnumInput(notifier: notifier, enumList: Clip.values));
add<StackFit>(
(notifier) => EnumInput(notifier: notifier, enumList: StackFit.values));
add<Overflow>(
(notifier) => EnumInput(notifier: notifier, enumList: Overflow.values));
add<FontStyle>(
(notifier) => EnumInput(notifier: notifier, enumList: FontStyle.values));
add<BlurStyle>(
(notifier) => EnumInput(notifier: notifier, enumList: BlurStyle.values));
add<BlendMode>(
(notifier) => EnumInput(notifier: notifier, enumList: BlendMode.values));
add<StrokeCap>(
(notifier) => EnumInput(notifier: notifier, enumList: StrokeCap.values));
add<StrokeJoin>(
(notifier) => EnumInput(notifier: notifier, enumList: StrokeJoin.values));
add<FilterQuality>((notifier) =>
EnumInput(notifier: notifier, enumList: FilterQuality.values));
add<PaintingStyle>((notifier) =>
EnumInput(notifier: notifier, enumList: PaintingStyle.values));
add<TileMode>(
(notifier) => EnumInput(notifier: notifier, enumList: TileMode.values));
add<TextDecorationStyle>((notifier) =>
EnumInput(notifier: notifier, enumList: TextDecorationStyle.values));
add<FontWeight>(
(notifier) => EnumInput(notifier: notifier, enumList: FontWeight.values));
add<FloatingLabelBehavior>((notifier) =>
EnumInput(notifier: notifier, enumList: FloatingLabelBehavior.values));
add<BorderStyle>((notifier) =>
EnumInput(notifier: notifier, enumList: BorderStyle.values));
add<TextStyleEnum>((notifier) =>
EnumInput(notifier: notifier, enumList: TextStyleEnum.values));
add<VisualDensity>(
(notifier) => DefaultCardInput(
label: notifier.name,
children: [
ButtonSelect<VisualDensity>(
key: ValueKey(notifier.name),
selected: notifier.value,
options: const [
VisualDensity.comfortable,
VisualDensity.compact,
VisualDensity.standard,
],
asString: (d) {
return _visualDensityNameMap[d]!;
},
onChange: notifier.set,
),
],
),
);
}
final _visualDensityNameMap = {
VisualDensity.comfortable: 'comfortable',
VisualDensity.compact: 'compact',
VisualDensity.standard: 'standard',
};
class EnumInput<E extends Object> extends StatelessWidget {
const EnumInput({
Key? key,
required this.notifier,
required this.enumList,
this.withCard = true,
}) : super(key: key);
final PropClass<E?> notifier;
final List<E> enumList;
final bool withCard;
static String _enumToString(Object? e) => e.toString().split('.')[1];
@override
Widget build(BuildContext context) {
final child = ButtonSelect<E>(
key: ValueKey(notifier.name),
selected: notifier.value,
options: enumList,
asString: _enumToString,
onChange: notifier.set,
);
if (!withCard) {
return child;
}
return DefaultCardInput(
label: notifier.name,
children: [
child,
],
);
}
}
enum TextStyleEnum {
headline1,
headline2,
headline3,
headline4,
headline5,
headline6,
subtitle1,
subtitle2,
bodyText1,
bodyText2,
caption,
button,
overline,
}
extension TextStyleEnumTheme on TextStyleEnum {
String toEnumString() => this.toString().split('.')[1];
TextStyle? fromTheme(TextTheme theme) {
switch (this) {
case TextStyleEnum.headline1:
return theme.headline1;
case TextStyleEnum.headline2:
return theme.headline2;
case TextStyleEnum.headline3:
return theme.headline3;
case TextStyleEnum.headline4:
return theme.headline4;
case TextStyleEnum.headline5:
return theme.headline5;
case TextStyleEnum.headline6:
return theme.headline6;
case TextStyleEnum.subtitle1:
return theme.subtitle1;
case TextStyleEnum.subtitle2:
return theme.subtitle2;
case TextStyleEnum.bodyText1:
return theme.bodyText1;
case TextStyleEnum.bodyText2:
return theme.bodyText2;
case TextStyleEnum.caption:
return theme.caption;
case TextStyleEnum.button:
return theme.button;
case TextStyleEnum.overline:
return theme.overline;
}
}
}
| 0
|
mirrored_repositories/snippet_generator/lib
|
mirrored_repositories/snippet_generator/lib/fields/flutter_border_fields.dart
|
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:snippet_generator/fields/base_fields.dart';
import 'package:snippet_generator/fields/color_field.dart';
import 'package:snippet_generator/fields/enum_fields.dart';
import 'package:snippet_generator/fields/fields.dart';
class BorderSideInput extends HookWidget {
const BorderSideInput({
Key? key,
required this.notifier,
}) : super(key: key);
final PropClass<BorderSide?> notifier;
@override
Widget build(BuildContext context) {
final value = notifier.value ?? const BorderSide();
final style = useMemoized(
() => PropClass.fromNotifier(
'style',
ValueNotifier(BorderStyle.solid),
),
);
return DefaultCardInput(
label: notifier.name,
children: [
DoubleInput(
label: 'width',
onChanged: (newWidth) {
if (newWidth != null) {
notifier.set(value.copyWith(width: newWidth));
}
},
value: notifier.value?.width,
),
const SizedBox(height: 10),
ColorFieldRow(
name: 'color',
width: 60,
onChanged: (color) {
notifier.set(value.copyWith(color: color));
},
value: notifier.value?.color ?? Colors.white,
),
GlobalFields.get(style)!,
],
);
}
}
class BorderRadiusInput extends HookWidget {
const BorderRadiusInput({
Key? key,
required this.notifier,
}) : super(key: key);
final PropClass<BorderRadius?> notifier;
@override
Widget build(BuildContext context) {
final value = notifier.value ?? const BorderRadius.all(Radius.zero);
void set(BorderRadius newValue) {
notifier.set(newValue);
}
return DefaultCardInput(
label: notifier.name,
children: [
Row(
children: [
Expanded(
child: DoubleInput(
label: 'topLeft',
value: value.topLeft.x,
onChanged: (v) {
set(value.copyWith(topLeft: Radius.circular(v ?? 0)));
},
),
),
const SizedBox(width: 15),
Expanded(
child: DoubleInput(
label: 'top',
value: value.hasTop ? value.topLeft.x : null,
onChanged: (v) {
if (v != null) {
final r = Radius.circular(v);
set(value.copyWith(topLeft: r, topRight: r));
}
},
),
),
const SizedBox(width: 15),
Expanded(
child: DoubleInput(
label: 'topRight',
value: value.topRight.x,
onChanged: (v) {
set(value.copyWith(topRight: Radius.circular(v ?? 0)));
},
),
),
],
),
Row(
children: [
Expanded(
child: DoubleInput(
label: 'left',
value: value.bottomLeft.x,
onChanged: (v) {
if (v != null) {
final r = Radius.circular(v);
set(value.copyWith(topLeft: r, bottomLeft: r));
}
},
),
),
const SizedBox(width: 15),
Expanded(
child: DoubleInput(
label: 'all',
value: value.hasAll ? value.topLeft.x : null,
onChanged: (v) {
if (v != null) {
final r = Radius.circular(v);
set(BorderRadius.all(r));
}
},
),
),
const SizedBox(width: 15),
Expanded(
child: DoubleInput(
label: 'right',
value: value.hasRight ? value.topRight.x : null,
onChanged: (v) {
if (v != null) {
final r = Radius.circular(v);
set(value.copyWith(topRight: r, bottomRight: r));
}
},
),
),
],
),
Row(
children: [
Expanded(
child: DoubleInput(
label: 'bottomLeft',
value: value.bottomLeft.x,
onChanged: (v) {
set(value.copyWith(bottomLeft: Radius.circular(v ?? 0)));
},
),
),
const SizedBox(width: 15),
Expanded(
child: DoubleInput(
label: 'bottom',
value: value.hasBottom ? value.bottomLeft.x : null,
onChanged: (v) {
if (v != null) {
final r = Radius.circular(v);
set(value.copyWith(bottomLeft: r, bottomRight: r));
}
},
),
),
const SizedBox(width: 15),
Expanded(
child: DoubleInput(
label: 'bottomRight',
value: value.bottomRight.x,
onChanged: (v) {
set(value.copyWith(bottomRight: Radius.circular(v ?? 0)));
},
),
),
],
),
],
);
}
}
extension ExtBorderRadius on BorderRadius {
bool get hasTop => topRight == topLeft;
bool get hasBottom => bottomRight == bottomLeft;
bool get hasLeft => bottomLeft == topLeft;
bool get hasRight => bottomRight == topRight;
bool get hasHorizontal => hasLeft && hasRight;
bool get hasVertical => hasTop && hasBottom;
bool get hasAll => hasHorizontal && hasVertical;
}
enum InputBorderType { outline, underline }
class InputBorderInput extends HookWidget {
const InputBorderInput({Key? key, required this.notifier}) : super(key: key);
final PropClass<InputBorder?> notifier;
@override
Widget build(BuildContext context) {
final value = notifier.value ?? const UnderlineInputBorder();
late final PropClass<InputBorderType?> type;
late final PropClass<BorderSide?> borderSide;
late final PropClass<BorderRadius?> borderRadius;
void _onChange(dynamic _) {
if (type.value == InputBorderType.underline) {
notifier.set(const UnderlineInputBorder().copyWith(
borderRadius: borderRadius.value,
borderSide: borderSide.value,
));
} else if (type.value == InputBorderType.outline) {
notifier.set(const OutlineInputBorder().copyWith(
borderRadius: borderRadius.value,
borderSide: borderSide.value,
));
}
}
type = usePropClass<InputBorderType?>(
'type',
value is OutlineInputBorder
? InputBorderType.outline
: InputBorderType.underline,
_onChange,
);
borderRadius = usePropClass('borderRadius', null, _onChange);
borderSide = usePropClass<BorderSide?>('borderSide', null, _onChange);
return DefaultCardInput(
label: notifier.name,
children: [
EnumInput(
notifier: type,
enumList: InputBorderType.values,
withCard: false,
),
if (value is OutlineInputBorder)
DoubleInput(
label: 'gapPadding',
onChanged: (v) {
notifier.set(value.copyWith(gapPadding: v));
},
value: value.gapPadding,
),
BorderRadiusInput(notifier: borderRadius),
BorderSideInput(notifier: borderSide)
],
);
}
}
PropClass<T> usePropClass<T>(
String name,
T value,
void Function(T) onChanged, [
List<Object?> deps = const [],
]) {
final prop = useMemoized(
() => PropClass.fromNotifier(
name,
ValueNotifier<T>(value),
),
);
useEffect(() {
void _l() {
onChanged(prop.value);
}
prop.addListener(_l);
return () {
prop.removeListener(_l);
};
}, deps);
return prop;
}
| 0
|
mirrored_repositories/snippet_generator/lib
|
mirrored_repositories/snippet_generator/lib/utils/set_up_globals.dart
|
import 'package:snippet_generator/fields/fields.dart';
import 'package:snippet_generator/globals/models.dart';
import 'package:snippet_generator/themes/theme_store.dart';
void setUpGlobals() {
Globals.addFactory(() => ThemeCouple());
GlobalFields.init();
}
| 0
|
mirrored_repositories/snippet_generator/lib
|
mirrored_repositories/snippet_generator/lib/utils/download_json.dart
|
import 'dart:typed_data';
import 'package:file_selector_platform_interface/file_selector_platform_interface.dart';
import 'package:file_system_access/file_system_access.dart';
Future<String?> getDirectory() async {
final handle = await FileSystem.instance.showDirectoryPicker();
if (handle == null) {
return null;
}
print(handle.name);
final fileResult = await handle.getFileHandle('nameFile.txt', create: true);
await fileResult.when(
ok: (file) async {
print(file.name);
final writable = await file.createWritable();
// await writable.write(FileSystemWriteChunkType.string("appended"));
await writable.close();
},
err: (err) async {},
);
return handle.name;
// } else {
// final path = await FileSelectorPlatform.instance.getDirectoryPath();
// return path;
// }
}
void downloadToClient(
String content,
String fileName,
String contentType,
) {
_downloadToClientNative(content, fileName, contentType);
}
final _jsonFileType = [
XTypeGroup(extensions: ['json'])
];
Future<void> _downloadToClientNative(
String content,
String fileName,
String contentType,
) async {
final path = await FileSelectorPlatform.instance.getSavePath(
acceptedTypeGroups: _jsonFileType,
suggestedName: fileName,
);
if (path == null) {
return;
} else {
final textFile = XFile.fromData(
Uint8List.fromList(content.codeUnits),
mimeType: 'text/plain',
name: fileName,
);
await textFile.saveTo(path);
}
}
Future<String?> importFromClient() async {
final file = await FileSelectorPlatform.instance.openFile(
acceptedTypeGroups: _jsonFileType,
// allowsMultipleSelection: false,
// canSelectDirectories: false,
);
if (file == null) {
return null;
} else {
return file.readAsString();
}
}
| 0
|
mirrored_repositories/snippet_generator/lib
|
mirrored_repositories/snippet_generator/lib/utils/theme.dart
|
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:google_fonts/google_fonts.dart';
ButtonStyle elevatedStyle(BuildContext context) => ElevatedButton.styleFrom();
ButtonStyle actionStyle(BuildContext context) => TextButton.styleFrom(
primary: Colors.white,
onSurface: Colors.white,
disabledMouseCursor: MouseCursor.defer,
enabledMouseCursor: SystemMouseCursors.click,
padding: const EdgeInsets.symmetric(horizontal: 17),
);
ButtonStyle menuStyle(BuildContext context, {EdgeInsetsGeometry? padding}) =>
TextButton.styleFrom(
padding: padding,
);
ThemeData lightTheme() {
final _baseTheme = ThemeData.light();
return ThemeData(
primarySwatch: Colors.teal,
brightness: Brightness.light,
visualDensity: VisualDensity.adaptivePlatformDensity,
scaffoldBackgroundColor: const Color(0xfff5f8fa),
textTheme: GoogleFonts.nunitoSansTextTheme(_baseTheme.textTheme),
colorScheme: ColorScheme.fromSwatch(primarySwatch: Colors.teal).copyWith(
error: Colors.red[100],
onError: Colors.black,
),
inputDecorationTheme: const InputDecorationTheme(
isDense: true,
filled: true,
contentPadding: EdgeInsets.only(top: 7, left: 7, right: 7, bottom: 8),
labelStyle: TextStyle(height: 1),
),
elevatedButtonTheme: ElevatedButtonThemeData(
style: ElevatedButton.styleFrom(
primary: Colors.white,
onPrimary: Colors.black,
disabledMouseCursor: SystemMouseCursors.basic,
enabledMouseCursor: SystemMouseCursors.click,
),
),
textButtonTheme: TextButtonThemeData(
style: TextButton.styleFrom(
primary: Colors.black,
disabledMouseCursor: SystemMouseCursors.basic,
enabledMouseCursor: SystemMouseCursors.click,
// minimumSize: const Size(0, 34),
// padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 0),
),
),
);
}
ThemeData darkTheme() {
final _baseTheme = ThemeData.dark();
final accentColor = Colors.teal[600];
return _baseTheme.copyWith(
// primaryColor: Colors.black,
toggleableActiveColor: accentColor,
accentColor: accentColor,
colorScheme: const ColorScheme.dark().copyWith(
primary: Colors.white,
error: Colors.red[100],
),
brightness: Brightness.dark,
visualDensity: VisualDensity.adaptivePlatformDensity,
// scaffoldBackgroundColor: const Color(0xfff5f8fa),
textTheme: GoogleFonts.nunitoSansTextTheme(_baseTheme.textTheme),
inputDecorationTheme: const InputDecorationTheme(
isDense: true,
filled: true,
contentPadding: EdgeInsets.only(top: 7, left: 7, right: 7, bottom: 8),
labelStyle: TextStyle(height: 1),
),
elevatedButtonTheme: ElevatedButtonThemeData(
style: ElevatedButton.styleFrom(
primary: Colors.black26,
onPrimary: Colors.white,
disabledMouseCursor: SystemMouseCursors.basic,
enabledMouseCursor: SystemMouseCursors.click,
),
),
textButtonTheme: TextButtonThemeData(
style: TextButton.styleFrom(
// primary: Colors.black,
disabledMouseCursor: SystemMouseCursors.basic,
enabledMouseCursor: SystemMouseCursors.click,
// minimumSize: const Size(0, 34),
// padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 0),
),
),
);
}
| 0
|
mirrored_repositories/snippet_generator/lib
|
mirrored_repositories/snippet_generator/lib/utils/persistence.dart
|
import 'dart:convert';
import 'package:hive/hive.dart';
import 'package:hive_flutter/hive_flutter.dart';
import 'package:snippet_generator/gen_parsers/models/store_value.dart';
import 'package:snippet_generator/globals/serializer.dart';
import 'package:snippet_generator/types/type_models.dart';
final _boxesMap = {
TypeConfig: _BoxConfig<TypeConfig>(0, 'type', TypeConfig.serializer),
ClassConfig: _BoxConfig<ClassConfig>(1, 'class', ClassConfig.serializer),
PropertyField:
_BoxConfig<PropertyField>(2, 'property', PropertyField.serializer),
GenerateParserStoreValue: _BoxConfig<GenerateParserStoreValue>(
3,
'parsers',
GenerateParserStoreValue.serializer,
),
};
Box<T> getBox<T>() {
return Hive.box<T>(_boxesMap[T]!.boxName);
}
Future<void> initHive() async {
await Hive.initFlutter();
for (final _boxConfig in _boxesMap.values) {
_boxConfig.register();
}
for (final _boxConfig in _boxesMap.values) {
await _boxConfig.openBox();
}
}
class _JsonAdapter<T> extends TypeAdapter<T> {
_JsonAdapter({required this.typeId, required this.serializer});
final Serializer<T> serializer;
@override
final int typeId;
@override
T read(BinaryReader reader) {
final jsonString = reader.readString();
final Object? json = jsonDecode(jsonString);
return serializer.fromJson(json);
}
@override
void write(BinaryWriter writer, T obj) {
final json = serializer.toJson(obj);
final jsonString = jsonEncode(json);
writer.writeString(jsonString);
}
}
class _BoxConfig<T> {
final int typeId;
final String boxName;
final Serializer<T> serializer;
const _BoxConfig(
this.typeId,
this.boxName,
this.serializer,
);
void register() {
Hive.registerAdapter<T>(
_JsonAdapter<T>(
typeId: typeId,
serializer: serializer,
),
);
}
Future<void> openBox() async {
await _openBox<T>(boxName);
}
}
Future<Box<T>> _openBox<T>(String name) async {
Box<T> box;
try {
box = await Hive.openBox<T>(name);
} catch (_) {
await Hive.deleteBoxFromDisk(name);
box = await Hive.openBox<T>(name);
}
return box;
}
| 0
|
mirrored_repositories/snippet_generator/lib
|
mirrored_repositories/snippet_generator/lib/utils/tt.dart
|
import 'dart:convert';
import 'package:snippet_generator/database/models/sql_values.dart';
class Message {
final int numId;
final String codeMessage;
final List<int> userCode;
final String roomCode;
final int roomCodeSection;
final String text;
final String? senderName;
final String typeMessageCode;
final int read;
final DateTime createdAt;
final List<Room>? refRoom;
final List<User>? refUser;
final List<TypeMessage>? refTypeMessage;
final Map<String, Object?> additionalInfo;
const Message({
required this.numId,
required this.codeMessage,
required this.userCode,
required this.roomCode,
required this.roomCodeSection,
required this.text,
this.senderName,
required this.typeMessageCode,
required this.read,
required this.createdAt,
this.refRoom,
this.refUser,
this.refTypeMessage,
this.additionalInfo = const {},
});
String insertShallowSql() {
return '''
INSERT INTO message(num_id,code_message,user_code,room_code,room_code_section,text,sender_name,type_message_code,read,created_at)
VALUES ($numId,$codeMessage,$userCode,$roomCode,$roomCodeSection,$text,$senderName,$typeMessageCode,$read,$createdAt);
''';
}
Future<SqlQueryResult> insertShallow(TableConnection conn) {
final sqlQuery = insertShallowSql();
return conn.query(sqlQuery);
}
static SqlQuery selectSql({
SqlValue<SqlBoolValue>? where,
List<SqlOrderItem>? orderBy,
SqlLimit? limit,
required SqlDatabase database,
bool unsafe = false,
bool withRoom = false,
bool withUser = false,
bool withTypeMessage = false,
}) {
final ctx = SqlContext(database: database, unsafe: unsafe);
final query = """
SELECT num_id,code_message,user_code,room_code,room_code_section,text,sender_name,type_message_code,read,created_at
${withRoom ? ",JSON_ARRAYAGG(JSON_OBJECT('codeRoom',room.code_room,'section',room.section,'createdAt',room.created_at)) refRoom" : ""}
${withUser ? ",JSON_ARRAYAGG(JSON_OBJECT('codeUser',user.code_user,'createdAt',user.created_at)) refUser" : ""}
${withTypeMessage ? ",JSON_ARRAYAGG(JSON_OBJECT('codeType',type_message.code_type,'createdAt',type_message.created_at)) refTypeMessage" : ""}
FROM message
${withRoom ? "JOIN room ON message.room_code=room.code_room AND message.room_code_section=room.section" : ""}
${withUser ? "JOIN user ON message.user_code=user.code_user" : ""}
${withTypeMessage ? "JOIN type_message ON message.type_message_code=type_message.code_type" : ""}
${where == null ? '' : 'WHERE ${where.toSql(ctx)}'}
GROUP BY num_id,code_message
${orderBy == null ? '' : 'ORDER BY ${orderBy.map((item) => item.toSql(ctx)).join(",")}'}
${limit == null ? '' : 'LIMIT ${limit.rowCount} ${limit.offset == null ? "" : "OFFSET ${limit.offset}"}'}
;
""";
return SqlQuery(query, ctx.variables);
}
static Future<List<Message>> select(
TableConnection conn, {
SqlValue<SqlBoolValue>? where,
List<SqlOrderItem>? orderBy,
SqlLimit? limit,
bool withRoom = false,
bool withUser = false,
bool withTypeMessage = false,
}) async {
final query = Message.selectSql(
where: where,
limit: limit,
orderBy: orderBy,
database: conn.database,
withRoom: withRoom,
withUser: withUser,
withTypeMessage: withTypeMessage,
);
final result = await conn.query(query.query, query.params);
int _refIndex = 10;
return result.map((r) {
return Message(
numId: r[0] as int,
codeMessage: r[1] as String,
userCode: r[2] as List<int>,
roomCode: r[3] as String,
roomCodeSection: r[4] as int,
text: r[5] as String,
senderName: r[6] as String?,
typeMessageCode: r[7] as String,
read: r[8] as int,
createdAt: r[9] as DateTime,
refRoom: withRoom ? Room.listFromJson(r[_refIndex++]) : null,
refUser: withUser ? User.listFromJson(r[_refIndex++]) : null,
refTypeMessage:
withTypeMessage ? TypeMessage.listFromJson(r[_refIndex++]) : null,
);
}).toList();
}
factory Message.fromJson(dynamic json) {
final Map map;
if (json is Message) {
return json;
} else if (json is Map) {
map = json;
} else if (json is String) {
map = jsonDecode(json) as Map;
} else {
throw Error();
}
return Message(
numId: map['numId'] as int,
codeMessage: map['codeMessage'] as String,
userCode: map['userCode'] as List<int>,
roomCode: map['roomCode'] as String,
roomCodeSection: map['roomCodeSection'] as int,
text: map['text'] as String,
senderName: map['senderName'] as String?,
typeMessageCode: map['typeMessageCode'] as String,
read: map['read'] as int,
createdAt: map['createdAt'] as DateTime,
refRoom: Room.listFromJson(map['refRoom']),
refUser: User.listFromJson(map['refUser']),
refTypeMessage: TypeMessage.listFromJson(map['refTypeMessage']),
);
}
static List<Message>? listFromJson(dynamic _json) {
final json = _json is String ? jsonDecode(_json) : _json;
if (json is List || json is Set) {
return (json as Iterable).map((e) => Message.fromJson(e)).toList();
} else if (json is Map) {
final _jsonMap = json.cast<String, List>();
final numId = _jsonMap['numId'];
final codeMessage = _jsonMap['codeMessage'];
final userCode = _jsonMap['userCode'];
final roomCode = _jsonMap['roomCode'];
final roomCodeSection = _jsonMap['roomCodeSection'];
final text = _jsonMap['text'];
final senderName = _jsonMap['senderName'];
final typeMessageCode = _jsonMap['typeMessageCode'];
final read = _jsonMap['read'];
final createdAt = _jsonMap['createdAt'];
final refRoom = _jsonMap['refRoom'];
final refUser = _jsonMap['refUser'];
final refTypeMessage = _jsonMap['refTypeMessage'];
return Iterable.generate(
(numId?.length ??
codeMessage?.length ??
userCode?.length ??
roomCode?.length ??
roomCodeSection?.length ??
text?.length ??
senderName?.length ??
typeMessageCode?.length ??
read?.length ??
createdAt?.length ??
refRoom?.length ??
refUser?.length ??
refTypeMessage?.length)!,
(_ind) {
return Message(
numId: numId?[_ind] as int,
codeMessage: codeMessage?[_ind] as String,
userCode: userCode?[_ind] as List<int>,
roomCode: roomCode?[_ind] as String,
roomCodeSection: roomCodeSection?[_ind] as int,
text: text?[_ind] as String,
senderName: senderName?[_ind] as String?,
typeMessageCode: typeMessageCode?[_ind] as String,
read: read?[_ind] as int,
createdAt: createdAt?[_ind] as DateTime,
refRoom: Room.listFromJson(refRoom?[_ind]),
refUser: User.listFromJson(refUser?[_ind]),
refTypeMessage: TypeMessage.listFromJson(refTypeMessage?[_ind]),
);
},
).toList();
} else {
return _json as List<Message>?;
}
}
}
class MessageCols {
MessageCols(String tableAlias)
: numId = SqlValue.raw('$tableAlias.num_id'),
codeMessage = SqlValue.raw('$tableAlias.code_message'),
userCode = SqlValue.raw('$tableAlias.user_code'),
roomCode = SqlValue.raw('$tableAlias.room_code'),
roomCodeSection = SqlValue.raw('$tableAlias.room_code_section'),
text = SqlValue.raw('$tableAlias.text'),
senderName = SqlValue.raw('$tableAlias.sender_name'),
typeMessageCode = SqlValue.raw('$tableAlias.type_message_code'),
read = SqlValue.raw('$tableAlias.read'),
createdAt = SqlValue.raw('$tableAlias.created_at');
final SqlValue<SqlNumValue> numId;
final SqlValue<SqlStringValue> codeMessage;
final SqlValue<SqlBinaryValue> userCode;
final SqlValue<SqlStringValue> roomCode;
final SqlValue<SqlNumValue> roomCodeSection;
final SqlValue<SqlStringValue> text;
final SqlValue<SqlStringValue> senderName;
final SqlValue<SqlStringValue> typeMessageCode;
final SqlValue<SqlNumValue> read;
final SqlValue<SqlDateValue> createdAt;
late final List<SqlValue> allColumns = [
numId,
codeMessage,
userCode,
roomCode,
roomCodeSection,
text,
senderName,
typeMessageCode,
read,
createdAt,
];
}
class User {
final List<int> codeUser;
final DateTime createdAt;
final Map<String, Object?> additionalInfo;
const User({
required this.codeUser,
required this.createdAt,
this.additionalInfo = const {},
});
String insertShallowSql() {
return '''
INSERT INTO user(code_user,created_at)
VALUES ($codeUser,$createdAt);
''';
}
Future<SqlQueryResult> insertShallow(TableConnection conn) {
final sqlQuery = insertShallowSql();
return conn.query(sqlQuery);
}
static SqlQuery selectSql({
SqlValue<SqlBoolValue>? where,
List<SqlOrderItem>? orderBy,
SqlLimit? limit,
required SqlDatabase database,
bool unsafe = false,
}) {
final ctx = SqlContext(database: database, unsafe: unsafe);
final query = """
SELECT code_user,created_at
FROM user
${where == null ? '' : 'WHERE ${where.toSql(ctx)}'}
GROUP BY null
${orderBy == null ? '' : 'ORDER BY ${orderBy.map((item) => item.toSql(ctx)).join(",")}'}
${limit == null ? '' : 'LIMIT ${limit.rowCount} ${limit.offset == null ? "" : "OFFSET ${limit.offset}"}'}
;
""";
return SqlQuery(query, ctx.variables);
}
static Future<List<User>> select(
TableConnection conn, {
SqlValue<SqlBoolValue>? where,
List<SqlOrderItem>? orderBy,
SqlLimit? limit,
}) async {
final query = User.selectSql(
where: where,
limit: limit,
orderBy: orderBy,
database: conn.database,
);
final result = await conn.query(query.query, query.params);
int _refIndex = 2;
return result.map((r) {
return User(
codeUser: r[0] as List<int>,
createdAt: r[1] as DateTime,
);
}).toList();
}
factory User.fromJson(dynamic json) {
final Map map;
if (json is User) {
return json;
} else if (json is Map) {
map = json;
} else if (json is String) {
map = jsonDecode(json) as Map;
} else {
throw Error();
}
return User(
codeUser: map['codeUser'] as List<int>,
createdAt: map['createdAt'] as DateTime,
);
}
static List<User>? listFromJson(dynamic _json) {
final json = _json is String ? jsonDecode(_json) : _json;
if (json is List || json is Set) {
return (json as Iterable).map((e) => User.fromJson(e)).toList();
} else if (json is Map) {
final _jsonMap = json.cast<String, List>();
final codeUser = _jsonMap['codeUser'];
final createdAt = _jsonMap['createdAt'];
return Iterable.generate(
(codeUser?.length ?? createdAt?.length)!,
(_ind) {
return User(
codeUser: codeUser?[_ind] as List<int>,
createdAt: createdAt?[_ind] as DateTime,
);
},
).toList();
} else {
return _json as List<User>?;
}
}
}
class UserCols {
UserCols(String tableAlias)
: codeUser = SqlValue.raw('$tableAlias.code_user'),
createdAt = SqlValue.raw('$tableAlias.created_at');
final SqlValue<SqlBinaryValue> codeUser;
final SqlValue<SqlDateValue> createdAt;
late final List<SqlValue> allColumns = [
codeUser,
createdAt,
];
}
class Room {
final String codeRoom;
final int section;
final DateTime createdAt;
final Map<String, Object?> additionalInfo;
const Room({
required this.codeRoom,
required this.section,
required this.createdAt,
this.additionalInfo = const {},
});
String insertShallowSql() {
return '''
INSERT INTO room(code_room,section,created_at)
VALUES ($codeRoom,$section,$createdAt);
''';
}
Future<SqlQueryResult> insertShallow(TableConnection conn) {
final sqlQuery = insertShallowSql();
return conn.query(sqlQuery);
}
static SqlQuery selectSql({
SqlValue<SqlBoolValue>? where,
List<SqlOrderItem>? orderBy,
SqlLimit? limit,
required SqlDatabase database,
bool unsafe = false,
}) {
final ctx = SqlContext(database: database, unsafe: unsafe);
final query = """
SELECT code_room,section,created_at
FROM room
${where == null ? '' : 'WHERE ${where.toSql(ctx)}'}
GROUP BY null
${orderBy == null ? '' : 'ORDER BY ${orderBy.map((item) => item.toSql(ctx)).join(",")}'}
${limit == null ? '' : 'LIMIT ${limit.rowCount} ${limit.offset == null ? "" : "OFFSET ${limit.offset}"}'}
;
""";
return SqlQuery(query, ctx.variables);
}
static Future<List<Room>> select(
TableConnection conn, {
SqlValue<SqlBoolValue>? where,
List<SqlOrderItem>? orderBy,
SqlLimit? limit,
}) async {
final query = Room.selectSql(
where: where,
limit: limit,
orderBy: orderBy,
database: conn.database,
);
final result = await conn.query(query.query, query.params);
int _refIndex = 3;
return result.map((r) {
return Room(
codeRoom: r[0] as String,
section: r[1] as int,
createdAt: r[2] as DateTime,
);
}).toList();
}
factory Room.fromJson(dynamic json) {
final Map map;
if (json is Room) {
return json;
} else if (json is Map) {
map = json;
} else if (json is String) {
map = jsonDecode(json) as Map;
} else {
throw Error();
}
return Room(
codeRoom: map['codeRoom'] as String,
section: map['section'] as int,
createdAt: map['createdAt'] as DateTime,
);
}
static List<Room>? listFromJson(dynamic _json) {
final json = _json is String ? jsonDecode(_json) : _json;
if (json is List || json is Set) {
return (json as Iterable).map((e) => Room.fromJson(e)).toList();
} else if (json is Map) {
final _jsonMap = json.cast<String, List>();
final codeRoom = _jsonMap['codeRoom'];
final section = _jsonMap['section'];
final createdAt = _jsonMap['createdAt'];
return Iterable.generate(
(codeRoom?.length ?? section?.length ?? createdAt?.length)!,
(_ind) {
return Room(
codeRoom: codeRoom?[_ind] as String,
section: section?[_ind] as int,
createdAt: createdAt?[_ind] as DateTime,
);
},
).toList();
} else {
return _json as List<Room>?;
}
}
}
class RoomCols {
RoomCols(String tableAlias)
: codeRoom = SqlValue.raw('$tableAlias.code_room'),
section = SqlValue.raw('$tableAlias.section'),
createdAt = SqlValue.raw('$tableAlias.created_at');
final SqlValue<SqlStringValue> codeRoom;
final SqlValue<SqlNumValue> section;
final SqlValue<SqlDateValue> createdAt;
late final List<SqlValue> allColumns = [
codeRoom,
section,
createdAt,
];
}
class TypeMessage {
final String codeType;
final DateTime createdAt;
final Map<String, Object?> additionalInfo;
const TypeMessage({
required this.codeType,
required this.createdAt,
this.additionalInfo = const {},
});
String insertShallowSql() {
return '''
INSERT INTO type_message(code_type,created_at)
VALUES ($codeType,$createdAt);
''';
}
Future<SqlQueryResult> insertShallow(TableConnection conn) {
final sqlQuery = insertShallowSql();
return conn.query(sqlQuery);
}
static SqlQuery selectSql({
SqlValue<SqlBoolValue>? where,
List<SqlOrderItem>? orderBy,
SqlLimit? limit,
required SqlDatabase database,
bool unsafe = false,
}) {
final ctx = SqlContext(database: database, unsafe: unsafe);
final query = """
SELECT code_type,created_at
FROM type_message
${where == null ? '' : 'WHERE ${where.toSql(ctx)}'}
GROUP BY null
${orderBy == null ? '' : 'ORDER BY ${orderBy.map((item) => item.toSql(ctx)).join(",")}'}
${limit == null ? '' : 'LIMIT ${limit.rowCount} ${limit.offset == null ? "" : "OFFSET ${limit.offset}"}'}
;
""";
return SqlQuery(query, ctx.variables);
}
static Future<List<TypeMessage>> select(
TableConnection conn, {
SqlValue<SqlBoolValue>? where,
List<SqlOrderItem>? orderBy,
SqlLimit? limit,
}) async {
final query = TypeMessage.selectSql(
where: where,
limit: limit,
orderBy: orderBy,
database: conn.database,
);
final result = await conn.query(query.query, query.params);
int _refIndex = 2;
return result.map((r) {
return TypeMessage(
codeType: r[0] as String,
createdAt: r[1] as DateTime,
);
}).toList();
}
factory TypeMessage.fromJson(dynamic json) {
final Map map;
if (json is TypeMessage) {
return json;
} else if (json is Map) {
map = json;
} else if (json is String) {
map = jsonDecode(json) as Map;
} else {
throw Error();
}
return TypeMessage(
codeType: map['codeType'] as String,
createdAt: map['createdAt'] as DateTime,
);
}
static List<TypeMessage>? listFromJson(dynamic _json) {
final json = _json is String ? jsonDecode(_json) : _json;
if (json is List || json is Set) {
return (json as Iterable).map((e) => TypeMessage.fromJson(e)).toList();
} else if (json is Map) {
final _jsonMap = json.cast<String, List>();
final codeType = _jsonMap['codeType'];
final createdAt = _jsonMap['createdAt'];
return Iterable.generate(
(codeType?.length ?? createdAt?.length)!,
(_ind) {
return TypeMessage(
codeType: codeType?[_ind] as String,
createdAt: createdAt?[_ind] as DateTime,
);
},
).toList();
} else {
return _json as List<TypeMessage>?;
}
}
}
class TypeMessageCols {
TypeMessageCols(String tableAlias)
: codeType = SqlValue.raw('$tableAlias.code_type'),
createdAt = SqlValue.raw('$tableAlias.created_at');
final SqlValue<SqlStringValue> codeType;
final SqlValue<SqlDateValue> createdAt;
late final List<SqlValue> allColumns = [
codeType,
createdAt,
];
}
| 0
|
mirrored_repositories/snippet_generator/lib
|
mirrored_repositories/snippet_generator/lib/utils/extensions.dart
|
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
extension GlobalPaintBoundsExt on BuildContext {
Rect? get globalPaintBounds {
final renderObject = findRenderObject();
final translation = renderObject?.getTransformTo(null).getTranslation();
if (translation != null && renderObject!.paintBounds != null) {
return renderObject.paintBounds
.shift(Offset(translation.x, translation.y));
} else {
return null;
}
}
}
extension ContextExtension on BuildContext {
ThemeData get theme => Theme.of(this);
TextTheme get textTheme => theme.textTheme;
MediaQueryData get mq => MediaQuery.of(this);
Size get size => mq.size;
}
extension IndexedMap<T> on Iterable<T> {
Iterable<V> mapIndex<V>(V Function(T, int) f) {
int i = 0;
return this.map((v) => f(v, i++));
}
Iterable<ItemIndex<T>> indexed() {
int i = 0;
return this.map((v) => ItemIndex(i++, v));
}
Iterable<O> zip<O, V>(Iterable<V> it, O Function(T, V) f) sync* {
final iterator = it.iterator;
for (final v in this) {
if (iterator.moveNext()) {
yield f(v, iterator.current);
} else {
break;
}
}
}
}
class ItemIndex<T> {
final int index;
final T item;
const ItemIndex(this.index, this.item);
}
T? parseEnum<T>(String rawString, List<T> enumValues,
{bool caseSensitive = true}) {
final _rawStringComp = caseSensitive ? rawString : rawString.toLowerCase();
for (final value in enumValues) {
final str =
caseSensitive ? value.toString() : value.toString().toLowerCase();
if (str == _rawStringComp || str.split('.')[1] == _rawStringComp) {
return value;
}
}
return null;
}
extension ValueListenableBuilderExtension<T> on ValueListenable<T> {
Widget rebuild(Widget Function(T value) fn, {Key? key}) {
return ValueListenableBuilder<T>(
key: key,
valueListenable: this,
builder: (context, v, _) {
return fn(v);
},
);
}
}
extension ListenableBuilder on Listenable {
Widget rebuild(Widget Function() fn) {
return AnimatedBuilder(
animation: this,
builder: (context, _) {
return fn();
},
);
}
}
extension ValueNotifierSetter<T> on ValueNotifier<T> {
void set(T newValue) {
this.value = newValue;
}
}
extension MapSetter<K, T> on Map<K, T> {
void set(K key, T newValue) {
this[key] = newValue;
}
T? get(K key) {
return this[key];
}
}
extension CasingString on String {
String firstToLowerCase() =>
length > 0 ? substring(0, 1).toLowerCase() + substring(1) : this;
String firstToUpperCase() =>
length > 0 ? substring(0, 1).toUpperCase() + substring(1) : this;
String asVariableName({bool dart = true}) {
String value = replaceFirst('_', '').firstToLowerCase();
const _reserved = {'null', 'true', 'false', 'default', 'enum'};
const _reservedChar = {
'"': 'doubleQuote',
r'\\': 'escape',
r'\n': 'newLine',
'"""': 'tripleDoubleQuote',
r'\\"""': 'escapedTripleDoubleQuote',
};
if (dart && _reserved.contains(value)) {
value += '_';
} else if (_reservedChar.containsKey(value)) {
value = _reservedChar[value]!;
}
return value;
}
String snakeToCamel({bool firstUpperCase = false}) {
int lastIndex = 0;
int index = 0;
final buffer = StringBuffer();
void _add() {
if (index <= lastIndex) {
return;
}
final _toAdd = this.substring(lastIndex, index);
buffer.write(lastIndex != 0 || firstUpperCase
? _toAdd.firstToUpperCase()
: _toAdd);
}
for (final codeUnit in this.codeUnits) {
final char = String.fromCharCode(codeUnit);
if (char == '_') {
_add();
lastIndex = index + 1;
}
index += 1;
}
_add();
return buffer.toString();
}
}
const dynamic importExtensions = null;
| 0
|
mirrored_repositories/snippet_generator/lib
|
mirrored_repositories/snippet_generator/lib/utils/formatters.dart
|
// ignore_for_file: unnecessary_raw_strings
import 'package:flutter/services.dart';
final _variableNameRegex = RegExp(r'^[a-zA-Z_][a-zA-Z_0-9]*');
class Formatters {
const Formatters._();
// CUSTOM
// static final variableName = [FilteringTextInputFormatter.allow(_variableNameRegex)];
static final variableName = [
TextInputFormatter.withFunction((oldValue, newValue) {
final m = _variableNameRegex.firstMatch(newValue.text);
return m != null || newValue.text.isEmpty
? newValue.copyWith(text: m?.group(0) ?? '')
: oldValue;
})
];
// SPACES
static final onlySpaceWhitespace =
FilteringTextInputFormatter.deny(RegExp(r'(\s)'), replacementString: ' ');
static final noWhitespaces =
FilteringTextInputFormatter.deny(RegExp(r'(\s)'));
static final noDoubleSpace = FilteringTextInputFormatter.deny(
RegExp(r'[ ]{2,}'),
replacementString: ' ');
static final noStartWhitespaces =
FilteringTextInputFormatter.allow(RegExp(r'^\S[\s\S]*'));
// NUMBERS
static final noStartNumber =
FilteringTextInputFormatter.allow(RegExp(r'^[^0-9][\s\S]*'));
static final onlyDigits = FilteringTextInputFormatter.allow(RegExp(r'[0-9]'));
static final onlyDigitsOrSpace =
FilteringTextInputFormatter.allow(RegExp(r'[0-9 ]'));
static final onlyQuantities =
FilteringTextInputFormatter.allow(RegExp(r'[1-9][0-9]*'));
static final onlyDigitsOrDecimal =
FilteringTextInputFormatter.allow(RegExp(r'[\.0-9]'));
static CustomFormatter onlyDigitsCustom({
int minLenght = 0,
int? maxLength,
String? errorMessage,
}) {
return CustomFormatter(onlyDigits, validate: (t) {
if (t.length >= minLenght && (maxLength == null || t.length <= maxLength)
// && onlyDigits.whitelistedPattern.matchAsPrefix(t)?.group(0) == t
) {
return null;
} else {
return errorMessage;
}
});
}
}
bool Function(String) convertValidate(String? Function(String)? validate) {
return (String v) => validate!(v) != null;
}
String? Function(String) combineValidators(
List<String? Function(String)> validators,
) {
return (String v) {
for (final validator in validators) {
final error = validator(v);
if (error != null) {
return error;
}
}
return null;
};
}
class CustomFormatter {
CustomFormatter(
this.formatter, {
String? Function(String)? validate,
}) : this.validateWithError = validate,
this.validate = convertValidate(validate);
final bool Function(String) validate;
final String? Function(String)? validateWithError;
final TextInputFormatter formatter;
}
| 0
|
mirrored_repositories/snippet_generator/lib/utils
|
mirrored_repositories/snippet_generator/lib/utils/wasm/wasm_interop_test.dart
|
// import 'dart:io';
// import 'dart:typed_data';
// import 'package:test/test.dart';
// import 'package:wasm/wasm.dart';
// WasmInstance createWasm(Uint8List bytes) {
// final module = WasmModule(bytes);
// return module.instantiate().build();
// }
// Future<void> main() async {
// print(Platform.resolvedExecutable);
// final file = File("./lib/utils/main.wasm");
// final moduleBytes = await file.readAsBytes();
// final instance = createWasm(moduleBytes);
// final addFunc = instance.lookupFunction("add");
// final result = addFunc.call([1, 2]);
// test("", () {
// expect(result, 3);
// });
// }
| 0
|
mirrored_repositories/snippet_generator
|
mirrored_repositories/snippet_generator/test/widget_test.dart
|
// This is a basic Flutter widget test.
//
// To perform an interaction with a widget in your test, use the WidgetTester
// utility that Flutter provides. For example, you can send tap and scroll
// gestures. You can also use WidgetTester to find child widgets in the widget
// tree, read text, and verify that the values of widget properties are correct.
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:snippet_generator/main.dart';
void main() {
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
// Build our app and trigger a frame.
await tester.pumpWidget(const MyApp());
// Verify that our counter starts at 0.
expect(find.text('0'), findsOneWidget);
expect(find.text('1'), findsNothing);
// Tap the '+' icon and trigger a frame.
await tester.tap(find.byIcon(Icons.add));
await tester.pump();
// Verify that our counter has incremented.
expect(find.text('0'), findsNothing);
expect(find.text('1'), findsOneWidget);
});
}
| 0
|
mirrored_repositories/snippet_generator/plugins/file_download_web
|
mirrored_repositories/snippet_generator/plugins/file_download_web/lib/file_download_web.dart
|
import 'dart:async';
import 'package:flutter/services.dart';
const MethodChannel _channel = MethodChannel('file_download_web');
Future<String> get platformVersion async {
final String version = await _channel.invokeMethod('getPlatformVersion');
return version;
}
Future<void> downloadToClientWeb(
String content,
String fileName,
String contentType,
) async {
await _channel.invokeMethod('downloadToClient', {
'content': content,
'fileName': fileName,
'contentType': contentType,
});
}
Future<String> importFromClientWeb() async {
return _channel.invokeMethod('importFromClient');
}
| 0
|
mirrored_repositories/snippet_generator/plugins/file_download_web
|
mirrored_repositories/snippet_generator/plugins/file_download_web/lib/file_download_web_web.dart
|
import 'dart:async';
import 'dart:html' as html;
import 'package:flutter/services.dart';
import 'package:flutter_web_plugins/flutter_web_plugins.dart';
/// A web implementation of the FileDownloadWeb plugin.
class FileDownloadWebWeb {
static void registerWith(Registrar registrar) {
final MethodChannel channel = MethodChannel(
'file_download_web',
const StandardMethodCodec(),
registrar.messenger,
);
final pluginInstance = FileDownloadWebWeb();
channel.setMethodCallHandler(pluginInstance.handleMethodCall);
}
/// Handles method calls over the MethodChannel of this plugin.
/// Note: Check the "federated" architecture for a new way of doing this:
/// https://flutter.dev/go/federated-plugins
Future<dynamic> handleMethodCall(MethodCall call) async {
switch (call.method) {
case 'getPlatformVersion':
return getPlatformVersion();
break;
case 'downloadToClient':
return _downloadToClientWeb(
call.arguments["content"] as String,
call.arguments["fileName"] as String,
call.arguments["contentType"] as String);
case 'importFromClient':
return _importFromClientWeb();
default:
throw PlatformException(
code: 'Unimplemented',
details:
"file_download_web for web doesn't implement '${call.method}'",
);
}
}
/// Returns a [String] containing the version of the platform.
Future<String> getPlatformVersion() {
final version = html.window.navigator.userAgent;
return Future.value(version);
}
}
void _downloadToClientWeb(
String content,
String fileName,
String contentType,
) {
final file = html.Blob([content], contentType);
final a = html.AnchorElement(href: html.Url.createObjectUrlFromBlob(file));
a.download = fileName;
a.click();
a.remove();
}
Future<String> _importFromClientWeb() async {
final input = html.InputElement(type: "file");
input.accept = "application/json";
final completer = Completer<String>();
input.onChange.listen((event) {
if (input.files.isNotEmpty) {
final file = input.files[0];
if (file.type != "application/json") {
html.window.alert(
"Debes seleccionar un archivo válido, la extensión debe ser '.json'.");
return completer.complete(null);
}
final reader = html.FileReader();
reader.onLoad.listen((e) {
return completer.complete(reader.result as String);
});
reader.readAsText(file);
} else {
return completer.complete(null);
}
});
input.click();
final result = await completer.future;
input.remove();
return result;
}
| 0
|
mirrored_repositories/snippet_generator/plugins/file_download_web
|
mirrored_repositories/snippet_generator/plugins/file_download_web/test/file_download_web_test.dart
|
// import 'package:flutter/services.dart';
// import 'package:flutter_test/flutter_test.dart';
// import 'package:file_download_web/file_download_web.dart';
// void main() {
// const MethodChannel channel = MethodChannel('file_download_web');
// TestWidgetsFlutterBinding.ensureInitialized();
// setUp(() {
// channel.setMockMethodCallHandler((MethodCall methodCall) async {
// return '42';
// });
// });
// tearDown(() {
// channel.setMockMethodCallHandler(null);
// });
// test('getPlatformVersion', () async {
// expect(await FileDownloadWeb.platformVersion, '42');
// });
// }
| 0
|
mirrored_repositories/snippet_generator/plugins/file_download_web/example
|
mirrored_repositories/snippet_generator/plugins/file_download_web/example/lib/main.dart
|
// import 'package:flutter/material.dart';
// import 'dart:async';
// import 'package:flutter/services.dart';
// import 'package:file_download_web/file_download_web.dart';
// void main() {
// runApp(MyApp());
// }
// class MyApp extends StatefulWidget {
// @override
// _MyAppState createState() => _MyAppState();
// }
// class _MyAppState extends State<MyApp> {
// String _platformVersion = 'Unknown';
// @override
// void initState() {
// super.initState();
// initPlatformState();
// }
// // Platform messages are asynchronous, so we initialize in an async method.
// Future<void> initPlatformState() async {
// String platformVersion;
// // Platform messages may fail, so we use a try/catch PlatformException.
// try {
// platformVersion = await FileDownloadWeb.platformVersion;
// } on PlatformException {
// platformVersion = 'Failed to get platform version.';
// }
// // If the widget was removed from the tree while the asynchronous platform
// // message was in flight, we want to discard the reply rather than calling
// // setState to update our non-existent appearance.
// if (!mounted) return;
// setState(() {
// _platformVersion = platformVersion;
// });
// }
// @override
// Widget build(BuildContext context) {
// return MaterialApp(
// home: Scaffold(
// appBar: AppBar(
// title: const Text('Plugin example app'),
// ),
// body: Center(
// child: Text('Running on: $_platformVersion\n'),
// ),
// ),
// );
// }
// }
| 0
|
mirrored_repositories/snippet_generator/plugins/file_download_web/example
|
mirrored_repositories/snippet_generator/plugins/file_download_web/example/test/widget_test.dart
|
// // This is a basic Flutter widget test.
// //
// // To perform an interaction with a widget in your test, use the WidgetTester
// // utility that Flutter provides. For example, you can send tap and scroll
// // gestures. You can also use WidgetTester to find child widgets in the widget
// // tree, read text, and verify that the values of widget properties are correct.
// import 'package:flutter/material.dart';
// import 'package:flutter_test/flutter_test.dart';
// import 'package:file_download_web_example/main.dart';
// void main() {
// testWidgets('Verify Platform version', (WidgetTester tester) async {
// // Build our app and trigger a frame.
// await tester.pumpWidget(MyApp());
// // Verify that platform version is retrieved.
// expect(
// find.byWidgetPredicate(
// (Widget widget) => widget is Text &&
// widget.data.startsWith('Running on:'),
// ),
// findsOneWidget,
// );
// });
// }
| 0
|
mirrored_repositories/recipe_finder
|
mirrored_repositories/recipe_finder/lib/main.dart
|
import 'package:core/core.dart' show diContainer;
import 'package:flutter/material.dart' show WidgetsFlutterBinding, runApp;
import 'app/init/dependency_injection/dependency_injection.dart';
import 'app/init/recipe_finder_app.dart' show RecipeFinderApp;
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
await configureDependencies();
await diContainer.allReady();
runApp(const RecipeFinderApp());
}
| 0
|
mirrored_repositories/recipe_finder/lib/app
|
mirrored_repositories/recipe_finder/lib/app/init/recipe_finder_app.dart
|
import 'package:core/core.dart';
import 'package:flutter/material.dart';
import 'package:route_not_found/presentation/route_not_found_view.dart';
import '../router/route_manager_impl.dart';
class RecipeFinderApp extends StatelessWidget {
const RecipeFinderApp({super.key});
@override
Widget build(BuildContext context) {
return ApplicationStarter(
routeManager: RouteManagerImpl(),
screenWorkingManager: diContainer<ScreenWorkingManager>(),
child: Builder(
builder: (appContext) {
return MaterialApp(
builder: (context, child) => ConnectivityWidget(
child: child ?? const RouteNotFoundView(),
),
initialRoute: appContext.routeManager.initialRoute,
onGenerateRoute: appContext.routeManager.generateRoute,
);
},
),
);
}
}
| 0
|
mirrored_repositories/recipe_finder/lib/app/init
|
mirrored_repositories/recipe_finder/lib/app/init/dependency_injection/dependency_injection.dart
|
import 'package:core/core.dart';
import 'package:data/data.module.dart';
import 'package:domain/domain.module.dart';
import 'package:injectable/injectable.dart';
import 'dependency_injection.config.dart';
@InjectableInit(
initializerName: 'startInjection',
throwOnMissingDependencies: true,
externalPackageModulesBefore: [
ExternalModule(DataPackageModule),
ExternalModule(DomainPackageModule),
],
)
Future<void> configureDependencies() async => diContainer.startInjection();
| 0
|
mirrored_repositories/recipe_finder/lib/app/init/dependency_injection
|
mirrored_repositories/recipe_finder/lib/app/init/dependency_injection/modules/screen_working_manager_module.dart
|
import 'package:core/widget/screen_working_manager/screen_working_manager.dart';
import 'package:core/widget/screen_working_manager/screen_working_manager_impl.dart';
import 'package:injectable/injectable.dart';
@module
abstract class ScreenWorkingManagerModule {
@singleton
ScreenWorkingManager createWorkingManager() {
return ScreenWorkingManagerImpl();
}
}
| 0
|
mirrored_repositories/recipe_finder/lib/app/init/dependency_injection
|
mirrored_repositories/recipe_finder/lib/app/init/dependency_injection/modules/debounce_manager_module.dart
|
import 'package:core/utils/debounce_manager.dart';
import 'package:injectable/injectable.dart';
@module
abstract class DebounceManagerModule {
@singleton
DebounceManager createDebounceManager() {
return DebounceManager();
}
}
| 0
|
mirrored_repositories/recipe_finder/lib/app
|
mirrored_repositories/recipe_finder/lib/app/router/route_manager_impl.dart
|
import 'package:core/base/route_manager.dart';
import 'package:favourite_recipes/presentation/favourite_recipes_view.dart';
import 'package:flutter/material.dart';
import 'package:home/presentation/home_view.dart';
import 'package:recipe_detail/presentation/recipe_detail_view.dart';
import 'package:route_information/route_information.dart';
import 'package:route_not_found/presentation/route_not_found_view.dart';
class RouteManagerImpl extends RouteManager {
@override
String get initialRoute => Routes.home.path;
@override
Route? generateRoute(RouteSettings settings) {
final route = Routes.fromRouteSettings(settings);
WidgetBuilder? builder;
switch (route) {
case Routes.home:
builder = (_) => const HomeView();
break;
case Routes.recipeDetail:
builder = (_) => const RecipeDetailView();
break;
case Routes.favouriteRecipes:
builder = (_) => const FavouriteRecipesView();
break;
case Routes.notFound:
builder = (_) => const RouteNotFoundView();
break;
}
return MaterialPageRoute(
builder: builder,
settings: settings,
);
}
}
| 0
|
mirrored_repositories/recipe_finder/modules/features/favourite_recipes
|
mirrored_repositories/recipe_finder/modules/features/favourite_recipes/lib/favourite_recipes.dart
|
library favourite_recipes;
import 'package:injectable/injectable.dart';
@InjectableInit.microPackage(
preferRelativeImports: true,
)
void initMicroPackage() {}
| 0
|
mirrored_repositories/recipe_finder/modules/features/favourite_recipes/lib
|
mirrored_repositories/recipe_finder/modules/features/favourite_recipes/lib/presentation/favourite_recipes_view_model.dart
|
import 'package:core/base/base_view_model.dart';
import 'package:domain/domain.dart';
import 'package:injectable/injectable.dart';
import 'package:route_information/route_information.dart';
@injectable
class FavouriteRecipesViewModel extends BaseViewModel {
FavouriteRecipesViewModel(this.getFavoriteRecipesUseCase);
final GetFavoriteRecipesUseCase getFavoriteRecipesUseCase;
final List<RecipeEntity> favoriteRecipes = [];
@override
void initViewModel() {
_getFavoriteRecipes();
}
Future<void> _getFavoriteRecipes() async {
final favoriteRecipeUseCase = await getFavoriteRecipesUseCase();
favoriteRecipes.clear();
favoriteRecipes.addAll(favoriteRecipeUseCase);
notifyListeners();
}
Future<void> onRecipePressed(RecipeEntity recipe) async {
await navigateTo(
Routes.recipeDetail.path,
arguments: recipe,
);
_getFavoriteRecipes();
}
}
| 0
|
mirrored_repositories/recipe_finder/modules/features/favourite_recipes/lib
|
mirrored_repositories/recipe_finder/modules/features/favourite_recipes/lib/presentation/favourite_recipes_view.dart
|
import 'package:core/core.dart';
import 'package:flutter/material.dart';
import 'package:ui/components/recipe_list_item_widget.dart';
import 'favourite_recipes_view_model.dart';
class FavouriteRecipesView extends ReactiveBaseView<FavouriteRecipesViewModel> {
const FavouriteRecipesView({super.key});
@override
Widget build(BuildContext context, FavouriteRecipesViewModel viewModel) {
return Scaffold(
appBar: AppBar(
title: const Text('Favourite Recipes'),
),
body: viewModel.favoriteRecipes.isEmpty
? const Center(
child: Text('No favourite recipes'),
)
: ListView.builder(
itemCount: viewModel.favoriteRecipes.length,
itemBuilder: (context, index) {
final recipe = viewModel.favoriteRecipes[index];
return RecipeListItemWidget(
recipe: recipe,
onRecipePressed: viewModel.onRecipePressed,
);
},
),
);
}
@override
FavouriteRecipesViewModel createViewModel() {
return diContainer<FavouriteRecipesViewModel>();
}
}
| 0
|
mirrored_repositories/recipe_finder/modules/features/route_not_found
|
mirrored_repositories/recipe_finder/modules/features/route_not_found/lib/route_not_found.dart
|
library route_not_found;
| 0
|
mirrored_repositories/recipe_finder/modules/features/route_not_found/lib
|
mirrored_repositories/recipe_finder/modules/features/route_not_found/lib/presentation/route_not_found_view.dart
|
import 'package:flutter/material.dart';
class RouteNotFoundView extends StatefulWidget {
const RouteNotFoundView({super.key});
@override
State<RouteNotFoundView> createState() => _RouteNotFoundViewState();
}
class _RouteNotFoundViewState extends State<RouteNotFoundView> {
String routePath = '';
@override
void didChangeDependencies() {
setState(() {
routePath = ModalRoute.of(context)!.settings.name!;
});
super.didChangeDependencies();
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Text('No route defined for $routePath'),
),
);
}
}
| 0
|
mirrored_repositories/recipe_finder/modules/features/home
|
mirrored_repositories/recipe_finder/modules/features/home/lib/home.dart
|
library home;
import 'package:domain/usecases/get_last_query_recipes_use_case.dart';
import 'package:injectable/injectable.dart';
@InjectableInit.microPackage(
preferRelativeImports: true,
usesNullSafety: true,
ignoreUnregisteredTypes: [
GetLastQueryRecipesUseCase,
],
throwOnMissingDependencies: true,
)
void initMicroPackage() {}
| 0
|
mirrored_repositories/recipe_finder/modules/features/home/lib
|
mirrored_repositories/recipe_finder/modules/features/home/lib/presentation/home_view.dart
|
import 'package:core/core.dart';
import 'package:domain/domain.dart';
import 'package:flutter/material.dart';
import 'package:gap/gap.dart';
import 'package:provider/provider.dart';
import 'package:ui/components/recipe_list_item_widget.dart';
import 'home_view_model.dart';
class HomeView extends BaseView<HomeViewModel> {
const HomeView({super.key});
@override
Widget builder(BuildContext context, HomeViewModel viewModel) {
return Scaffold(
appBar: AppBar(
title: const Text('Home'),
actions: [
IconButton(
icon: const Icon(Icons.favorite),
onPressed: viewModel.onFavouriteRecipesPressed,
),
],
),
body: Column(
children: <Widget>[
Padding(
padding: const EdgeInsets.all(16.0),
child: TextField(
onChanged: viewModel.onSearchTextChanged,
decoration: const InputDecoration(
hintText: 'Search',
),
),
),
const Gap(16),
Expanded(
child: Consumer<HomeViewModel>(
builder: (___, __, _) => const _RecipeListWidget(),
),
),
],
),
);
}
@override
HomeViewModel viewModelBuilder(BuildContext context) {
return diContainer<HomeViewModel>();
}
}
class _RecipeListWidget extends StatelessWidget {
const _RecipeListWidget();
@override
Widget build(BuildContext context) {
final HomeViewModel viewModel = context.watch<HomeViewModel>();
return ListView.builder(
itemCount: viewModel.recipes.length,
shrinkWrap: true,
itemBuilder: (BuildContext context, int index) {
final RecipeEntity recipe = viewModel.recipes[index];
return RecipeListItemWidget(
recipe: recipe,
onRecipePressed: viewModel.onRecipePressed,
);
},
);
}
}
| 0
|
mirrored_repositories/recipe_finder/modules/features/home/lib
|
mirrored_repositories/recipe_finder/modules/features/home/lib/presentation/home_view_model.dart
|
import 'package:core/core.dart';
import 'package:domain/domain.dart';
import 'package:injectable/injectable.dart';
import 'package:route_information/route_information.dart';
@injectable
class HomeViewModel extends BaseViewModel {
HomeViewModel(this.getLastQueryRecipesUseCase);
final GetLastQueryRecipesUseCase getLastQueryRecipesUseCase;
final List<RecipeEntity> recipes = [];
@override
void initViewModel() {
getLastQueryRecipes();
super.initViewModel();
}
void onRecipePressed(RecipeEntity recipe) {
navigateTo(
Routes.recipeDetail.path,
arguments: recipe,
);
}
void onSearchTextChanged(String query) {
final useCase = diContainer<SearchRecipesUseCase>();
useCase(
query: query,
onResult: (List<RecipeEntity> response) {
recipes.replaceRange(0, recipes.length, response);
notifyListeners();
},
);
}
void onFavouriteRecipesPressed() {
navigateTo(
Routes.favouriteRecipes.path,
);
}
Future<void> getLastQueryRecipes() async {
final result = await getLastQueryRecipesUseCase();
recipes.replaceRange(0, recipes.length, result);
notifyListeners();
}
}
| 0
|
mirrored_repositories/recipe_finder/modules/features/recipe_detail
|
mirrored_repositories/recipe_finder/modules/features/recipe_detail/lib/recipe_detail.dart
|
library recipe_detail;
import 'package:injectable/injectable.dart';
@InjectableInit.microPackage(
preferRelativeImports: true,
throwOnMissingDependencies: false,
)
void initMicroPackage() {}
| 0
|
mirrored_repositories/recipe_finder/modules/features/recipe_detail/lib
|
mirrored_repositories/recipe_finder/modules/features/recipe_detail/lib/presentation/recipe_detail_view.dart
|
import 'package:core/core.dart';
import 'package:flutter/material.dart';
import 'package:gap/gap.dart';
import 'recipe_detail_view_model.dart';
class RecipeDetailView extends ReactiveBaseView<RecipeDetailViewModel> {
const RecipeDetailView({super.key});
@override
Widget build(BuildContext context, RecipeDetailViewModel viewModel) {
return Scaffold(
appBar: AppBar(
title: const Text('Recipe Detail'),
),
body: SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.only(
left: 16,
right: 16,
bottom: 16,
),
child: Column(
children: [
SizedBox(
width: double.infinity,
height: 300,
child: Stack(
children: [
Hero(
tag: viewModel.args.id,
child: ClipRRect(
borderRadius: const BorderRadius.only(
bottomLeft: Radius.circular(16),
bottomRight: Radius.circular(16),
),
child: Image.network(
viewModel.args.imageUrl,
fit: BoxFit.fill,
width: double.infinity,
height: 300,
errorBuilder: (context, error, stackTrace) {
return const Center(
child: Icon(Icons.error),
);
},
),
),
),
Positioned(
bottom: 0,
right: 0,
child: Container(
decoration: const BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(16),
bottomRight: Radius.circular(16),
),
),
child: IconButton(
icon: Icon(
viewModel.isFavorite
? Icons.favorite
: Icons.favorite_border,
color: Colors.red,
),
onPressed: viewModel.toggleFavorite,
),
),
),
],
),
),
const Gap(8),
Text(
viewModel.args.name,
style: const TextStyle(
fontSize: 20,
fontWeight: FontWeight.bold,
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: ListView.builder(
padding: const EdgeInsets.only(top: 16),
itemCount: viewModel.args.ingredientLines.length,
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
itemBuilder: (context, index) {
final ingredient = viewModel.args.ingredientLines[index];
return Text(ingredient);
},
),
),
const Padding(
padding: EdgeInsets.symmetric(vertical: 8),
child: Text(
'Ingredients',
style: TextStyle(
fontSize: 20,
),
),
),
Wrap(
spacing: 8,
children: viewModel.args.ingredients
.map(
(label) => Chip(
label: Text(label),
),
)
.toList(),
),
],
),
),
),
);
}
@override
RecipeDetailViewModel createViewModel() {
return diContainer<RecipeDetailViewModel>();
}
}
| 0
|
mirrored_repositories/recipe_finder/modules/features/recipe_detail/lib
|
mirrored_repositories/recipe_finder/modules/features/recipe_detail/lib/presentation/recipe_detail_view_model.dart
|
import 'package:core/base/base_view_model.dart';
import 'package:domain/domain.dart';
import 'package:injectable/injectable.dart';
@injectable
class RecipeDetailViewModel extends BaseViewModel<RecipeEntity> {
RecipeDetailViewModel({
required this.addFavoriteRecipeUseCase,
required this.removeFavoriteRecipeUseCase,
required this.getFavoriteRecipesUseCase,
});
final AddFavoriteRecipeUseCase addFavoriteRecipeUseCase;
final RemoveFavoriteRecipe removeFavoriteRecipeUseCase;
final GetFavoriteRecipesUseCase getFavoriteRecipesUseCase;
@override
void initViewModel() {
_getFavoriteRecipes();
super.initViewModel();
}
final List<RecipeEntity> favoriteRecipes = [];
bool get isFavorite {
return favoriteRecipes
.where(
(element) => element.id == args.id,
)
.isNotEmpty;
}
Future<void> toggleFavorite() async {
if (isFavorite) {
await removeFavoriteRecipeUseCase(args);
favoriteRecipes.remove(args);
} else {
await addFavoriteRecipeUseCase(args);
favoriteRecipes.add(args);
}
notifyListeners();
}
Future<void> _getFavoriteRecipes() async {
final favoriteRecipeUseCase = await getFavoriteRecipesUseCase();
favoriteRecipes.clear();
favoriteRecipes.addAll(favoriteRecipeUseCase);
notifyListeners();
}
}
| 0
|
mirrored_repositories/recipe_finder/modules/data
|
mirrored_repositories/recipe_finder/modules/data/lib/data.dart
|
import 'package:injectable/injectable.dart';
export 'exports.dart';
@InjectableInit.microPackage(
preferRelativeImports: true,
usesNullSafety: true,
throwOnMissingDependencies: true,
)
void initMicroPackage() {}
| 0
|
mirrored_repositories/recipe_finder/modules/data
|
mirrored_repositories/recipe_finder/modules/data/lib/exports.dart
|
// GENERATED CODE - DO NOT MODIFY BY HAND
library data;
export 'data.dart';
export 'data_sources/constants/api_keys.dart';
export 'data_sources/constants/local_storage_keys.dart';
export 'data_sources/models/recipe_ingredient.dart';
export 'data_sources/models/recipe_response.dart';
export 'data_sources/remote/http_client.dart';
export 'di/modules/http_client_module.dart';
export 'di/modules/recipe_database_module.dart';
export 'di/modules/shared_preferences_module.dart';
export 'local/local_recipe_favorite_database.dart';
export 'local/recipes_cache_database_impl.dart';
export 'remote/remote_recipe_data_source_impl.dart';
| 0
|
mirrored_repositories/recipe_finder/modules/data/lib
|
mirrored_repositories/recipe_finder/modules/data/lib/remote/remote_recipe_data_source_impl.dart
|
import 'package:domain/domain.dart';
import 'package:injectable/injectable.dart';
import '../data_sources/remote/http_client.dart';
@LazySingleton(as: RemoteRecipeDataSource)
class RemoteRecipeDataSourceImpl extends RemoteRecipeDataSource {
final HttpClient _httpClient;
RemoteRecipeDataSourceImpl(this._httpClient);
@override
Future<Map<String, dynamic>> searchRecipes({
required String query,
}) async {
final response = await _httpClient.get(
queryParameters: {
'q': query,
'type': 'public',
},
);
final data = response.data;
if (data == null) {
// TODO: 13.04.2023 13:21 May create a custom exception
return {};
}
return data;
}
}
| 0
|
mirrored_repositories/recipe_finder/modules/data/lib
|
mirrored_repositories/recipe_finder/modules/data/lib/local/local_recipe_favorite_database.dart
|
import 'dart:async';
import 'dart:convert';
import 'package:domain/domain.dart';
import 'package:injectable/injectable.dart';
import 'package:shared_preferences/shared_preferences.dart';
import '../data_sources/constants/local_storage_keys.dart';
@LazySingleton(as: LocalRecipeFavoriteDataSource)
class LocalRecipeFavoriteDatabase extends LocalRecipeFavoriteDataSource {
final SharedPreferences _database;
LocalRecipeFavoriteDatabase(this._database);
@override
Future<List<Map<String, dynamic>>> getFavoriteRecipes() async {
final String? localRecipes = _database.getString(
LocalStorageKeys.recipes.name,
);
if (localRecipes == null) {
return [];
} else {
final List<dynamic> localRecipesList = json.decode(localRecipes);
return localRecipesList
.map(
(e) => e as Map<String, dynamic>,
)
.toList();
}
}
@override
Future<void> removeRecipe(String recipeId) async {
final String? localRecipes = _database.getString(
LocalStorageKeys.recipes.name,
);
if (localRecipes == null) {
return;
} else {
final List<dynamic> localRecipesList = json.decode(localRecipes);
final recipeIndex = localRecipesList.indexWhere(
(element) => element['id'] == recipeId,
);
if (recipeIndex == -1) {
return;
}
localRecipesList.removeAt(recipeIndex);
final encodedRecipes = json.encode(localRecipesList);
await _database.setString(LocalStorageKeys.recipes.name, encodedRecipes);
}
}
@override
Future<void> saveRecipe(Map<String, dynamic> recipe) async {
final String? localRecipes = _database.getString(
LocalStorageKeys.recipes.name,
);
if (localRecipes == null) {
final localRecipesList = <Map<String, dynamic>>[];
localRecipesList.add(recipe);
final encodedRecipes = json.encode(localRecipesList);
await _database.setString(LocalStorageKeys.recipes.name, encodedRecipes);
} else {
final List<dynamic> localRecipesList = json.decode(localRecipes);
localRecipesList.add(recipe);
final encodedRecipes = json.encode(localRecipesList);
await _database.setString(LocalStorageKeys.recipes.name, encodedRecipes);
}
}
}
| 0
|
mirrored_repositories/recipe_finder/modules/data/lib
|
mirrored_repositories/recipe_finder/modules/data/lib/local/recipes_cache_database_impl.dart
|
import 'dart:async';
import 'dart:convert';
import 'package:injectable/injectable.dart';
import 'package:sqflite/sqflite.dart';
import '../data_sources/constants/local_storage_keys.dart';
import 'package:domain/domain.dart';
@LazySingleton(as: RecipesCacheDatabase)
class RecipesCacheDatabaseImpl extends RecipesCacheDatabase {
static const _cacheExpirationDuration = Duration(hours: 1);
final Database _database;
RecipesCacheDatabaseImpl(this._database);
@override
Future<void> cacheRecipes(Iterable<RecipeEntity> recipes) async {
final expirationTime = DateTime.now().add(_cacheExpirationDuration);
final cacheData = _CacheData(expirationTime, recipes);
final cacheJson = jsonEncode(cacheData.toJson());
await clearCache();
await _database.rawInsert(
'INSERT INTO ${LocalStorageKeys.recipesCache.name} (data) VALUES (?)',
[cacheJson],
);
}
@override
Future<Iterable<RecipeEntity>> getRecipes() async {
final result = await _database.query(
LocalStorageKeys.recipesCache.name,
columns: ['data'],
);
if (result.isEmpty) {
return [];
}
final cacheJson = result.first['data'] as String;
final cacheData = _CacheData.fromJson(jsonDecode(cacheJson));
if (cacheData.expirationTime.isBefore(DateTime.now())) {
await clearCache();
return [];
}
return cacheData.recipes;
}
@override
Future<void> clearCache() async {
await _database.delete(LocalStorageKeys.recipesCache.name);
}
}
class _CacheData {
final DateTime expirationTime;
final Iterable<RecipeEntity> recipes;
_CacheData(this.expirationTime, this.recipes);
factory _CacheData.fromJson(Map<String, dynamic> json) {
final expirationTime = DateTime.parse(json['expirationTime']);
final recipes = (json['recipes'] as List<dynamic>)
.map((e) => RecipeEntity.fromJson(e))
.toList();
return _CacheData(expirationTime, recipes);
}
Map<String, dynamic> toJson() {
final recipesJson = recipes.map((e) => e.toJson()).toList();
return {
'expirationTime': expirationTime.toIso8601String(),
'recipes': recipesJson,
};
}
}
| 0
|
mirrored_repositories/recipe_finder/modules/data/lib/data_sources
|
mirrored_repositories/recipe_finder/modules/data/lib/data_sources/remote/http_client.dart
|
import 'package:dio/dio.dart';
import 'package:injectable/injectable.dart';
@Singleton()
class HttpClient {
final Dio _client;
HttpClient(this._client);
Future<Response> get({
String path = '',
Object? data,
Map<String, dynamic>? queryParameters,
}) async {
return await _client.get(
path,
data: data,
queryParameters: queryParameters,
);
}
}
| 0
|
mirrored_repositories/recipe_finder/modules/data/lib/data_sources
|
mirrored_repositories/recipe_finder/modules/data/lib/data_sources/constants/api_keys.dart
|
enum ApiKeys {
appId,
appKey,
recipesBaseUrl;
String get value {
switch (this) {
case ApiKeys.appId:
return const String.fromEnvironment('app_id', defaultValue: '');
case ApiKeys.appKey:
return const String.fromEnvironment('app_key', defaultValue: '');
case ApiKeys.recipesBaseUrl:
return 'https://api.edamam.com/api/recipes/v2';
}
}
String get apiKey {
switch (this) {
case ApiKeys.appId:
return 'app_id';
case ApiKeys.appKey:
return 'app_key';
case ApiKeys.recipesBaseUrl:
throw Exception('baseUrl is not an apiKey');
}
}
bool get isForHttpHeaders {
switch (this) {
case ApiKeys.appId:
return true;
case ApiKeys.appKey:
return true;
case ApiKeys.recipesBaseUrl:
return false;
}
}
}
| 0
|
mirrored_repositories/recipe_finder/modules/data/lib/data_sources
|
mirrored_repositories/recipe_finder/modules/data/lib/data_sources/constants/local_storage_keys.dart
|
enum LocalStorageKeys {
recipes,
recipesCache,
recipesCacheTable,
}
| 0
|
mirrored_repositories/recipe_finder/modules/data/lib/data_sources
|
mirrored_repositories/recipe_finder/modules/data/lib/data_sources/models/recipe_ingredient.g.dart
|
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'recipe_ingredient.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
RecipeIngredient _$RecipeIngredientFromJson(Map<String, dynamic> json) =>
RecipeIngredient(
text: json['text'] as String,
quantity: (json['quantity'] as num).toDouble(),
food: json['food'] as String,
);
Map<String, dynamic> _$RecipeIngredientToJson(RecipeIngredient instance) =>
<String, dynamic>{
'text': instance.text,
'quantity': instance.quantity,
'food': instance.food,
};
| 0
|
mirrored_repositories/recipe_finder/modules/data/lib/data_sources
|
mirrored_repositories/recipe_finder/modules/data/lib/data_sources/models/recipe_ingredient.dart
|
import 'package:json_annotation/json_annotation.dart';
part 'recipe_ingredient.g.dart';
@JsonSerializable()
class RecipeIngredient {
final String text;
final double quantity;
final String food;
RecipeIngredient({
required this.text,
required this.quantity,
required this.food,
});
factory RecipeIngredient.fromJson(Map<String, dynamic> json) =>
_$RecipeIngredientFromJson(json);
Map<String, dynamic> toJson() => _$RecipeIngredientToJson(this);
}
| 0
|
mirrored_repositories/recipe_finder/modules/data/lib/data_sources
|
mirrored_repositories/recipe_finder/modules/data/lib/data_sources/models/recipe_response.dart
|
import 'package:domain/models/recipe_entity/recipe_entity.dart';
import 'package:json_annotation/json_annotation.dart';
import 'recipe_ingredient.dart';
part 'recipe_response.g.dart';
@JsonSerializable()
class RecipeResponse {
@JsonKey(
name: 'uri',
fromJson: _fromJsonForId,
)
final String id;
@JsonKey(name: 'label')
final String name;
@JsonKey(name: 'image')
final String imageUrl;
final List<RecipeIngredient> ingredients;
final List<String> ingredientLines;
final String url;
const RecipeResponse({
required this.id,
required this.name,
required this.imageUrl,
required this.ingredients,
required this.ingredientLines,
required this.url,
});
RecipeEntity toRecipeEntity() {
return RecipeEntity(
id: id,
imageUrl: imageUrl,
ingredientLines: ingredientLines,
ingredients: ingredients.map((e) => e.food).toList(),
name: name,
url: url,
);
}
factory RecipeResponse.fromJson(Map<String, dynamic> json) =>
_$RecipeResponseFromJson(json);
Map<String, dynamic> toJson() => _$RecipeResponseToJson(this);
static String _fromJsonForId(String uri) {
final recipeId = uri.split('recipe_').last;
return recipeId;
}
}
| 0
|
mirrored_repositories/recipe_finder/modules/data/lib/data_sources
|
mirrored_repositories/recipe_finder/modules/data/lib/data_sources/models/recipe_response.g.dart
|
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'recipe_response.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
RecipeResponse _$RecipeResponseFromJson(Map<String, dynamic> json) =>
RecipeResponse(
id: RecipeResponse._fromJsonForId(json['uri'] as String),
name: json['label'] as String,
imageUrl: json['image'] as String,
ingredients: (json['ingredients'] as List<dynamic>)
.map((e) => RecipeIngredient.fromJson(e as Map<String, dynamic>))
.toList(),
ingredientLines: (json['ingredientLines'] as List<dynamic>)
.map((e) => e as String)
.toList(),
url: json['url'] as String,
);
Map<String, dynamic> _$RecipeResponseToJson(RecipeResponse instance) =>
<String, dynamic>{
'uri': instance.id,
'label': instance.name,
'image': instance.imageUrl,
'ingredients': instance.ingredients,
'ingredientLines': instance.ingredientLines,
'url': instance.url,
};
| 0
|
mirrored_repositories/recipe_finder/modules/data/lib/di
|
mirrored_repositories/recipe_finder/modules/data/lib/di/modules/http_client_module.dart
|
import 'package:dio/dio.dart';
import 'package:flutter/foundation.dart';
import 'package:injectable/injectable.dart';
import '../../data_sources/constants/api_keys.dart';
@module
abstract class HttpClientModule {
@singleton
@FactoryMethod(preResolve: true)
Dio dio() {
final dio = Dio();
dio.options.baseUrl = ApiKeys.recipesBaseUrl.value;
for (final apiKey in ApiKeys.values) {
if (apiKey.isForHttpHeaders) {
dio.options.queryParameters.addAll(
{
apiKey.apiKey: apiKey.value,
},
);
}
}
dio.interceptors.add(_logger);
return dio;
}
Interceptor get _logger {
return InterceptorsWrapper(
onRequest: (options, handler) {
if (kDebugMode) {
print('REQUEST[${options.method}] => '
'Endpoint: ${options.baseUrl}${options.path}');
print('HEADERS: ${options.headers}');
print('QUERY PARAMETERS: ${options.queryParameters}');
print('DATA: ${options.data}');
print('All Url with Query Parameters: ${options.uri}');
print('----------------------------------------');
}
return handler.next(options);
},
onResponse: (response, handler) {
if (kDebugMode) {
print('RESPONSE[${response.statusCode}] => '
'PATH: ${response.requestOptions.path}');
print('HEADERS: ${response.headers}');
print('DATA: ${response.data}');
}
return handler.next(response);
},
onError: (DioException e, handler) {
if (kDebugMode) {
print('ERROR[${e.response?.statusCode}] => '
'PATH: ${e.requestOptions.path}');
}
return handler.next(e);
},
);
}
}
| 0
|
mirrored_repositories/recipe_finder/modules/data/lib/di
|
mirrored_repositories/recipe_finder/modules/data/lib/di/modules/recipe_database_module.dart
|
import 'package:injectable/injectable.dart';
import 'package:sqflite/sqflite.dart';
import '../../data_sources/constants/local_storage_keys.dart';
@module
abstract class RecipeDatabaseModule {
@singleton
@preResolve
Future<Database> createDatabase() async {
final database = await openDatabase(
'recipe_database.db',
version: 1,
onCreate: (db, version) {
db.execute('CREATE TABLE ${LocalStorageKeys.recipesCache.name}'
' (id INTEGER PRIMARY KEY, data TEXT)');
},
);
return database;
}
}
| 0
|
mirrored_repositories/recipe_finder/modules/data/lib/di
|
mirrored_repositories/recipe_finder/modules/data/lib/di/modules/shared_preferences_module.dart
|
import 'package:injectable/injectable.dart';
import 'package:shared_preferences/shared_preferences.dart';
@module
abstract class SharedPreferencesModule {
@singleton
@preResolve
Future<SharedPreferences> createSharedPreferences() async {
return await SharedPreferences.getInstance();
}
}
| 0
|
mirrored_repositories/recipe_finder/modules/data/lib
|
mirrored_repositories/recipe_finder/modules/data/lib/repositories/recipe_repository_impl.dart
|
import 'package:data/data.dart';
import 'package:domain/domain.dart';
import 'package:injectable/injectable.dart';
@LazySingleton(as: RecipeRepository)
class RecipeRepositoryImpl extends RecipeRepository {
RecipeRepositoryImpl({
required super.remoteDataSource,
required super.localFavoriteDataSource,
required super.recipesCacheDatabase,
});
@override
Future<void> addFavoriteRecipe(RecipeEntity recipe) async {
await localFavoriteDataSource.saveRecipe(recipe.toJson());
}
@override
Future<Iterable<RecipeEntity>> getFavoriteRecipes() async {
final result = await localFavoriteDataSource.getFavoriteRecipes();
return result.map(
(recipe) => RecipeEntity.fromJson(recipe),
);
}
@override
Future<void> removeFavoriteRecipe(RecipeEntity recipe) {
return localFavoriteDataSource.removeRecipe(recipe.id);
}
@override
Future<Iterable<RecipeEntity>> searchRecipes({
required String query,
}) async {
final result = await remoteDataSource.searchRecipes(
query: query,
);
final recipeHits = result['hits'] as List<dynamic>;
final recipeResponses = recipeHits.map(
(recipe) => RecipeResponse.fromJson(
recipe['recipe'],
),
);
final recipes = recipeResponses.map(
(recipe) => recipe.toRecipeEntity(),
);
await recipesCacheDatabase.cacheRecipes(recipes);
return recipes;
}
@override
Future<Iterable<RecipeEntity>> getRecipes() async {
return await recipesCacheDatabase.getRecipes();
}
}
| 0
|
mirrored_repositories/recipe_finder/modules/core
|
mirrored_repositories/recipe_finder/modules/core/lib/core.dart
|
// GENERATED CODE - DO NOT MODIFY BY HAND
library core;
export 'base/application_starter.dart';
export 'base/base_exception.dart';
export 'base/base_view.dart';
export 'base/base_view_model.dart';
export 'base/reactive_base_view.dart';
export 'base/route_manager.dart';
export 'base/view_args.dart';
export 'di/di_container_provider.dart';
export 'enum/network_result.dart';
export 'extension/context_extension.dart';
export 'utils/debounce_manager.dart';
export 'utils/network_manager/base_network_manager.dart';
export 'utils/network_manager/network_manager.dart';
export 'widget/connectivity_widget/connectivity_widget.dart';
export 'widget/screen_working_manager/screen_working_manager.dart';
export 'widget/screen_working_manager/screen_working_manager_impl.dart';
| 0
|
mirrored_repositories/recipe_finder/modules/core/lib/widget
|
mirrored_repositories/recipe_finder/modules/core/lib/widget/connectivity_widget/connectivity_widget_state_mixin.dart
|
part of 'connectivity_widget.dart';
mixin NetworkStateAwareMixin on State<ConnectivityWidget> {
final NetworkStateManager _networkChange = NetworkStateManagerImpl.instance;
NetworkResult? networkResult;
StreamSubscription<NetworkResult>? _subscription;
@override
void initState() {
super.initState();
waitForScreen(() {
_subscription = _networkChange.listenNetworkChange().listen(_updateView);
_networkChange.checkNetworkOneTime().then(_updateView);
});
}
void waitForScreen(VoidCallback onComplete) {
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
onComplete.call();
});
}
void _updateView(NetworkResult result) {
setState(() {
networkResult = result;
});
}
@override
void dispose() {
_subscription?.cancel();
super.dispose();
}
}
| 0
|
mirrored_repositories/recipe_finder/modules/core/lib/widget
|
mirrored_repositories/recipe_finder/modules/core/lib/widget/connectivity_widget/connectivity_widget.dart
|
import 'dart:async';
import 'package:core/enum/network_result.dart';
import 'package:core/utils/network_manager/base_network_manager.dart';
import 'package:core/utils/network_manager/network_manager.dart';
import 'package:core/extension/context_extension.dart';
import 'package:flutter/material.dart';
part 'connectivity_widget_state_mixin.dart';
class ConnectivityWidget extends StatefulWidget {
const ConnectivityWidget({required this.child, super.key});
final Widget child;
@override
State<ConnectivityWidget> createState() => _ConnectivityWidgetState();
}
class _ConnectivityWidgetState extends State<ConnectivityWidget>
with NetworkStateAwareMixin {
@override
Widget build(BuildContext context) {
final bool isNetworkUnavailable = networkResult == NetworkResult.off;
return Stack(
children: <Widget>[
widget.child,
isNetworkUnavailable
? const _CheckYourInternetConnectionWidget()
: const SizedBox()
],
);
}
}
class _CheckYourInternetConnectionWidget extends StatelessWidget {
const _CheckYourInternetConnectionWidget();
@override
Widget build(BuildContext context) {
return Positioned.fill(
child: Align(
alignment: Alignment.bottomCenter,
child: Material(
child: Container(
height: context.screenHeight * .06,
color: Colors.black,
child: const Center(
child: Text(
"Please check your internet connection!",
style: TextStyle(color: Colors.white),
overflow: TextOverflow.visible,
textAlign: TextAlign.center,
),
),
),
),
),
);
}
}
| 0
|
mirrored_repositories/recipe_finder/modules/core/lib/widget
|
mirrored_repositories/recipe_finder/modules/core/lib/widget/screen_working_manager/screen_working_manager.dart
|
import 'package:flutter/material.dart' show BuildContext;
abstract class ScreenWorkingManager {
ScreenWorkingManager();
void showLoading(BuildContext context);
void hideLoading();
}
| 0
|
mirrored_repositories/recipe_finder/modules/core/lib/widget
|
mirrored_repositories/recipe_finder/modules/core/lib/widget/screen_working_manager/screen_working_manager_impl.dart
|
import 'package:flutter/material.dart';
import 'screen_working_manager.dart';
class ScreenWorkingManagerImpl extends ScreenWorkingManager {
ScreenWorkingManagerImpl();
OverlayEntry? _overlayEntry;
@override
void hideLoading() {
try {
_overlayEntry?.remove();
} catch (_) {
// ignore
} finally {
_overlayEntry = null;
}
}
@override
void showLoading(BuildContext context) {
if (_overlayEntry != null) {
return;
}
_overlayEntry = OverlayEntry(
builder: (context) => Stack(
alignment: Alignment.center,
children: [
Container(
color: Colors.black12.withOpacity(.2),
),
const CircularProgressIndicator(),
],
),
);
Overlay.of(context, rootOverlay: true).insert(_overlayEntry!);
}
}
| 0
|
mirrored_repositories/recipe_finder/modules/core/lib
|
mirrored_repositories/recipe_finder/modules/core/lib/di/di_container_provider.dart
|
import 'package:get_it/get_it.dart' show GetIt;
final diContainer = GetIt.instance;
| 0
|
mirrored_repositories/recipe_finder/modules/core/lib
|
mirrored_repositories/recipe_finder/modules/core/lib/extension/context_extension.dart
|
import 'package:flutter/material.dart';
import '../base/application_starter.dart';
import '../base/route_manager.dart';
import '../widget/screen_working_manager/screen_working_manager.dart';
extension BaseContextExtension on BuildContext {
RouteManager get routeManager => ApplicationStarter.ofRouteManager(this);
ScreenWorkingManager? get screenWorkingManager =>
ApplicationStarter.ofScreenWorkingManager(this);
MediaQueryData get mediaQuery => MediaQuery.of(this);
ThemeData get theme => Theme.of(this);
NavigatorState get nearestNavigator => Navigator.of(this);
Size get screenSize => mediaQuery.size;
double get screenWidth => screenSize.width;
double get screenHeight => screenSize.height;
}
| 0
|
mirrored_repositories/recipe_finder/modules/core/lib
|
mirrored_repositories/recipe_finder/modules/core/lib/utils/debounce_manager.dart
|
/*
*
* * debounce_manager.dart
* * Created by Salih Can Binboga on 13/04/2023.
*
*/
import 'dart:async';
class DebounceManager {
DebounceManager({
this.milliseconds = 500,
this.maxPendingEvent,
}) {
_duration = Duration(milliseconds: milliseconds);
}
final int milliseconds;
final int? maxPendingEvent;
Timer? _timer;
int _pendingEventCount = 0;
late final Duration _duration;
void run(void Function() action) {
if (maxPendingEvent != null && _pendingEventCount >= maxPendingEvent!) {
_timer?.cancel();
_pendingEventCount = 0;
action();
} else {
_timer?.cancel();
_timer = Timer(_duration, () {
_pendingEventCount = 0;
action();
});
_pendingEventCount++;
}
}
}
| 0
|
mirrored_repositories/recipe_finder/modules/core/lib/utils
|
mirrored_repositories/recipe_finder/modules/core/lib/utils/network_manager/base_network_manager.dart
|
import 'package:core/enum/network_result.dart';
typedef NetworkCallBack = void Function(NetworkResult result);
abstract class NetworkStateManager {
Future<NetworkResult> checkNetworkOneTime();
Stream<NetworkResult> listenNetworkChange();
void dispose();
}
| 0
|
mirrored_repositories/recipe_finder/modules/core/lib/utils
|
mirrored_repositories/recipe_finder/modules/core/lib/utils/network_manager/network_manager.dart
|
import 'dart:async';
import 'package:connectivity_plus/connectivity_plus.dart';
import 'package:core/enum/network_result.dart';
import 'package:core/utils/network_manager/base_network_manager.dart';
class NetworkStateManagerImpl extends NetworkStateManager {
static NetworkStateManagerImpl? _instance;
static NetworkStateManagerImpl get instance {
return _instance ??= NetworkStateManagerImpl._();
}
late final Connectivity _connectivity;
NetworkStateManagerImpl._() {
_connectivity = Connectivity();
}
@override
Future<NetworkResult> checkNetworkOneTime() async {
final connectivityResult = await (_connectivity.checkConnectivity());
return NetworkResult.checkConnectivityResult(connectivityResult);
}
@override
Stream<NetworkResult> listenNetworkChange() {
return _connectivity.onConnectivityChanged.map(
(event) => NetworkResult.checkConnectivityResult(event),
);
}
@override
void dispose() {
_instance = null;
}
}
| 0
|
mirrored_repositories/recipe_finder/modules/core/lib
|
mirrored_repositories/recipe_finder/modules/core/lib/base/reactive_base_view.dart
|
// ignore_for_file: cast_nullable_to_non_nullable
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'base_view_model.dart';
import 'view_args.dart';
abstract class ReactiveBaseView<T extends BaseViewModel>
extends StatefulWidget {
const ReactiveBaseView({
super.key,
});
T createViewModel();
Widget build(BuildContext context, T viewModel);
@override
State<ReactiveBaseView<T>> createState() {
return _ReactiveBaseViewState<T>();
}
}
class _ReactiveBaseViewState<T extends BaseViewModel>
extends State<ReactiveBaseView<T>> {
late T viewModel;
bool isInit = false;
@override
void didChangeDependencies() {
if (!isInit) {
viewModel = widget.createViewModel();
final Object? routeArgument = _getRouteArguments();
viewModel.args = routeArgument;
isInit = true;
}
super.didChangeDependencies();
}
Object? _getRouteArguments() {
final routeArgument = ModalRoute.of(context)?.settings.arguments;
if (routeArgument == null) {
return null;
}
final viewArgs = routeArgument as ViewArgs;
return viewArgs.data;
}
@override
Widget build(BuildContext context) {
return ChangeNotifierProvider<T>(
create: (context) {
viewModel.setContext(context);
return viewModel;
},
child: Consumer<T>(
builder: (BuildContext context, _, __) {
return widget.build(context, viewModel);
},
),
);
}
}
| 0
|
mirrored_repositories/recipe_finder/modules/core/lib
|
mirrored_repositories/recipe_finder/modules/core/lib/base/base_view_model.dart
|
// ignore_for_file: use_build_context_synchronously
import 'dart:async';
import 'dart:developer';
import 'package:core/extension/context_extension.dart';
import 'package:flutter/material.dart';
typedef SuspendCallback = Future<void> Function();
abstract class BaseViewModel<A> extends ChangeNotifier {
BaseViewModel() {
initViewModel();
}
A? _args;
A get args {
if (_args == null) {
throw Exception('Args is null');
}
return _args!;
}
set args(A value) {
_args = value;
}
final Completer<BuildContext> _contextCompleter = Completer<BuildContext>();
void initViewModel() {}
void onBindViewModel() {}
void setContext(BuildContext context) {
if (!_contextCompleter.isCompleted) {
_contextCompleter.complete(context);
onBindViewModel();
}
}
Future<T?> navigateTo<T extends Object?>(
String route, {
dynamic arguments,
}) async {
final context = await _contextCompleter.future;
final routeManager = context.routeManager;
return routeManager.navigateTo(
context,
route,
arguments: arguments,
);
}
Future<void> setWorkingStatus(bool status) async {
final context = await _contextCompleter.future;
final screenWorker = context.screenWorkingManager;
if (status) {
screenWorker?.showLoading(context);
} else {
screenWorker?.hideLoading();
}
}
int _workerCount = 0;
Future<void> suspend(final SuspendCallback callback) async {
try {
_workerCount++;
await setWorkingStatus(true);
await callback();
} catch (e, _) {
log(e.toString());
final context = await _contextCompleter.future;
showDialog(
context: context,
barrierDismissible: true,
builder: (context) {
return AlertDialog(
title: const Text('Error'),
content: Text(e.toString()),
actions: [
TextButton(
onPressed: Navigator.of(context).pop,
child: const Text('OK'),
),
],
);
},
);
} finally {
_workerCount--;
if (_workerCount == 0) {
await setWorkingStatus(false);
}
notifyListeners();
}
}
}
| 0
|
mirrored_repositories/recipe_finder/modules/core/lib
|
mirrored_repositories/recipe_finder/modules/core/lib/base/application_starter.dart
|
import 'package:flutter/material.dart' show BuildContext, InheritedWidget;
import '../utils/network_manager/base_network_manager.dart';
import '../utils/network_manager/network_manager.dart';
import '../widget/screen_working_manager/screen_working_manager.dart';
import 'route_manager.dart';
class ApplicationStarter extends InheritedWidget {
const ApplicationStarter({
required super.child,
required RouteManager routeManager,
NetworkStateManager? networkStateManager,
ScreenWorkingManager? screenWorkingManager,
super.key,
}) : _routeManager = routeManager,
_networkStateManager = networkStateManager,
_screenWorkingManager = screenWorkingManager;
final RouteManager _routeManager;
final NetworkStateManager? _networkStateManager;
final ScreenWorkingManager? _screenWorkingManager;
static RouteManager ofRouteManager(BuildContext context) {
return ApplicationStarter.of(context)._routeManager;
}
static NetworkStateManager ofNetworkManager(BuildContext context) {
final ApplicationStarter instance = ApplicationStarter.of(context);
final instanceNetworkStateManager = instance._networkStateManager;
return instanceNetworkStateManager ?? NetworkStateManagerImpl.instance;
}
static ScreenWorkingManager? ofScreenWorkingManager(BuildContext context) {
final ApplicationStarter instance = ApplicationStarter.of(context);
return instance._screenWorkingManager;
}
static ApplicationStarter of(BuildContext context) {
final ApplicationStarter? result =
context.dependOnInheritedWidgetOfExactType<ApplicationStarter>();
assert(result != null, 'No ApplicationStarter found in context');
return result!;
}
@override
bool updateShouldNotify(covariant ApplicationStarter oldWidget) {
return _routeManager != oldWidget._routeManager;
}
}
| 0
|
mirrored_repositories/recipe_finder/modules/core/lib
|
mirrored_repositories/recipe_finder/modules/core/lib/base/base_exception.dart
|
sealed class BaseException implements Exception {
const BaseException({this.message});
final String? message;
@override
String toString() => message ?? runtimeType.toString();
}
| 0
|
mirrored_repositories/recipe_finder/modules/core/lib
|
mirrored_repositories/recipe_finder/modules/core/lib/base/route_manager.dart
|
import 'package:core/base/view_args.dart';
import 'package:flutter/material.dart'
show BuildContext, Navigator, Route, RouteSettings;
abstract class RouteManager {
String get initialRoute;
Route<dynamic>? generateRoute(RouteSettings settings);
Future<T?> navigateTo<T extends Object?>(
BuildContext context,
String route, {
dynamic arguments,
}) {
return Navigator.pushNamed<T>(
context,
route,
arguments: _composeArguments<T>(arguments),
);
}
ViewArgs<T> _composeArguments<T extends Object?>(arguments) {
return ViewArgs<T>(
data: arguments,
);
}
void back(BuildContext context) {
Navigator.pop(context);
}
}
| 0
|
mirrored_repositories/recipe_finder/modules/core/lib
|
mirrored_repositories/recipe_finder/modules/core/lib/base/base_view.dart
|
import 'package:flutter/material.dart'
show BuildContext, Builder, StatelessWidget, Widget;
import 'package:provider/provider.dart'
show ChangeNotifierProvider, ReadContext;
import 'base_view_model.dart';
abstract class BaseView<T extends BaseViewModel> extends StatelessWidget {
const BaseView({super.key});
T viewModelBuilder(BuildContext context);
Widget builder(BuildContext context, T viewModel);
@override
Widget build(BuildContext context) {
return ChangeNotifierProvider<T>(
create: (context) {
return this.viewModelBuilder(context)..setContext(context);
},
child: Builder(
builder: (context) {
return builder(context, context.read<T>());
},
),
);
}
}
| 0
|
mirrored_repositories/recipe_finder/modules/core/lib
|
mirrored_repositories/recipe_finder/modules/core/lib/base/view_args.dart
|
import 'package:flutter/material.dart';
@immutable
final class ViewArgs<T extends Object?> {
const ViewArgs({
required this.data,
this.meta = const <String, dynamic>{},
});
final T data;
final Map<String, dynamic> meta;
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is ViewArgs &&
runtimeType == other.runtimeType &&
data == other.data;
@override
int get hashCode => data.hashCode;
ViewArgs<T> copyWith({
T? data,
Map<String, dynamic>? meta,
}) {
return ViewArgs<T>(
data: data ?? this.data,
meta: meta ?? this.meta,
);
}
}
| 0
|
mirrored_repositories/recipe_finder/modules/core/lib
|
mirrored_repositories/recipe_finder/modules/core/lib/enum/network_result.dart
|
import 'package:connectivity_plus/connectivity_plus.dart';
enum NetworkResult {
on,
off;
static NetworkResult checkConnectivityResult(ConnectivityResult result) {
switch (result) {
case ConnectivityResult.bluetooth:
case ConnectivityResult.wifi:
case ConnectivityResult.ethernet:
case ConnectivityResult.mobile:
case ConnectivityResult.vpn:
return NetworkResult.on;
case ConnectivityResult.other:
case ConnectivityResult.none:
return NetworkResult.off;
}
}
}
| 0
|
mirrored_repositories/recipe_finder/modules/common/route_information
|
mirrored_repositories/recipe_finder/modules/common/route_information/lib/route_information.dart
|
library route_information;
import 'package:flutter/material.dart' show RouteSettings;
enum Routes {
home('/'),
notFound('/not-found'),
recipeDetail('/recipe-detail'),
favouriteRecipes('/favourite-recipes');
const Routes(this.path);
final String path;
static Routes fromRouteSettings(RouteSettings settings) {
return Routes.values.firstWhere(
(route) => route.path == settings.name,
orElse: () => Routes.notFound,
);
}
}
| 0
|
mirrored_repositories/recipe_finder/modules/common/ui
|
mirrored_repositories/recipe_finder/modules/common/ui/lib/ui.dart
|
library ui;
| 0
|
mirrored_repositories/recipe_finder/modules/common/ui/lib
|
mirrored_repositories/recipe_finder/modules/common/ui/lib/components/recipe_list_item_widget.dart
|
import 'package:cached_network_image/cached_network_image.dart';
import 'package:domain/models/recipe_entity/recipe_entity.dart';
import 'package:flutter/material.dart';
class RecipeListItemWidget extends StatelessWidget {
const RecipeListItemWidget({
Key? key,
required this.recipe,
required this.onRecipePressed,
}) : super(key: key);
final RecipeEntity recipe;
final Function(RecipeEntity) onRecipePressed;
@override
Widget build(BuildContext context) {
return ListTile(
title: Text(recipe.name),
leading: Hero(
tag: recipe.id,
child: ClipRRect(
borderRadius: BorderRadius.circular(8),
child: CachedNetworkImage(
imageUrl: recipe.imageUrl,
progressIndicatorBuilder: (context, url, downloadProgress) {
return CircularProgressIndicator(
value: downloadProgress.progress,
);
},
errorWidget: (context, url, error) => const Icon(Icons.error),
),
),
),
minVerticalPadding: 32,
onTap: () {
onRecipePressed(recipe);
},
);
}
}
| 0
|
mirrored_repositories/recipe_finder/modules/domain
|
mirrored_repositories/recipe_finder/modules/domain/lib/domain.dart
|
library domain;
import 'package:injectable/injectable.dart';
export 'exports.dart';
@InjectableInit.microPackage(
preferRelativeImports: true,
usesNullSafety: true,
)
void initMicroPackage() {}
| 0
|
mirrored_repositories/recipe_finder/modules/domain
|
mirrored_repositories/recipe_finder/modules/domain/lib/exports.dart
|
// GENERATED CODE - DO NOT MODIFY BY HAND
library data;
export 'data_sources/local/local_recipe_favorite_data_source.dart';
export 'data_sources/local/recipes_cache_database.dart';
export 'data_sources/remote/remote_recipe_data_source.dart';
export 'domain.dart';
export 'models/recipe_entity/recipe_entity.dart';
export 'repositories/recipe_repository.dart';
export 'usecases/add_favorite_recipe_use_case.dart';
export 'usecases/get_favorite_recipes_use_case.dart';
export 'usecases/get_last_query_recipes_use_case.dart';
export 'usecases/remove_favorite_recipe_use_case.dart';
export 'usecases/search_recipes_use_case.dart';
| 0
|
mirrored_repositories/recipe_finder/modules/domain/lib/models
|
mirrored_repositories/recipe_finder/modules/domain/lib/models/recipe_entity/recipe_entity.dart
|
import 'package:json_annotation/json_annotation.dart';
part 'recipe_entity.g.dart';
@JsonSerializable()
class RecipeEntity {
final String id;
final String name;
final String imageUrl;
final List<String> ingredients;
final List<String> ingredientLines;
final String url;
const RecipeEntity({
required this.id,
required this.name,
required this.imageUrl,
required this.ingredients,
required this.ingredientLines,
required this.url,
});
factory RecipeEntity.fromJson(Map<String, dynamic> json) =>
_$RecipeEntityFromJson(json);
Map<String, dynamic> toJson() => _$RecipeEntityToJson(this);
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is RecipeEntity &&
runtimeType == other.runtimeType &&
id == other.id;
@override
int get hashCode => id.hashCode;
}
| 0
|
mirrored_repositories/recipe_finder/modules/domain/lib/models
|
mirrored_repositories/recipe_finder/modules/domain/lib/models/recipe_entity/recipe_entity.g.dart
|
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'recipe_entity.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
RecipeEntity _$RecipeEntityFromJson(Map<String, dynamic> json) => RecipeEntity(
id: json['id'] as String,
name: json['name'] as String,
imageUrl: json['imageUrl'] as String,
ingredients: (json['ingredients'] as List<dynamic>)
.map((e) => e as String)
.toList(),
ingredientLines: (json['ingredientLines'] as List<dynamic>)
.map((e) => e as String)
.toList(),
url: json['url'] as String,
);
Map<String, dynamic> _$RecipeEntityToJson(RecipeEntity instance) =>
<String, dynamic>{
'id': instance.id,
'name': instance.name,
'imageUrl': instance.imageUrl,
'ingredients': instance.ingredients,
'ingredientLines': instance.ingredientLines,
'url': instance.url,
};
| 0
|
mirrored_repositories/recipe_finder/modules/domain/lib/data_sources
|
mirrored_repositories/recipe_finder/modules/domain/lib/data_sources/remote/remote_recipe_data_source.dart
|
abstract class RemoteRecipeDataSource {
Future<Map<String, dynamic>> searchRecipes({
required String query,
});
}
| 0
|
mirrored_repositories/recipe_finder/modules/domain/lib/data_sources
|
mirrored_repositories/recipe_finder/modules/domain/lib/data_sources/local/local_recipe_favorite_data_source.dart
|
abstract class LocalRecipeFavoriteDataSource {
Future<void> saveRecipe(Map<String, dynamic> recipe);
Future<List<Map<String, dynamic>>> getFavoriteRecipes();
Future<void> removeRecipe(String recipeId);
}
| 0
|
mirrored_repositories/recipe_finder/modules/domain/lib/data_sources
|
mirrored_repositories/recipe_finder/modules/domain/lib/data_sources/local/recipes_cache_database.dart
|
import '../../models/recipe_entity/recipe_entity.dart';
abstract class RecipesCacheDatabase {
Future<Iterable<RecipeEntity>> getRecipes();
Future<void> cacheRecipes(Iterable<RecipeEntity> recipes);
Future<void> clearCache();
}
| 0
|
mirrored_repositories/recipe_finder/modules/domain/lib
|
mirrored_repositories/recipe_finder/modules/domain/lib/repositories/recipe_repository.dart
|
import '../domain.dart';
abstract class RecipeRepository {
final RemoteRecipeDataSource remoteDataSource;
final LocalRecipeFavoriteDataSource localFavoriteDataSource;
final RecipesCacheDatabase recipesCacheDatabase;
const RecipeRepository({
required this.remoteDataSource,
required this.localFavoriteDataSource,
required this.recipesCacheDatabase,
});
Future<Iterable<RecipeEntity>> searchRecipes({
required String query,
});
Future<Iterable<RecipeEntity>> getFavoriteRecipes();
Future<void> addFavoriteRecipe(RecipeEntity recipe);
Future<void> removeFavoriteRecipe(RecipeEntity recipe);
Future<Iterable<RecipeEntity>> getRecipes();
}
| 0
|
mirrored_repositories/recipe_finder/modules/domain/lib
|
mirrored_repositories/recipe_finder/modules/domain/lib/usecases/remove_favorite_recipe_use_case.dart
|
import 'package:injectable/injectable.dart';
import '../models/recipe_entity/recipe_entity.dart';
import '../repositories/recipe_repository.dart';
@LazySingleton()
class RemoveFavoriteRecipe {
final RecipeRepository repository;
RemoveFavoriteRecipe({required this.repository});
Future<void> call(RecipeEntity recipe) async {
return repository.removeFavoriteRecipe(recipe);
}
}
| 0
|
mirrored_repositories/recipe_finder/modules/domain/lib
|
mirrored_repositories/recipe_finder/modules/domain/lib/usecases/search_recipes_use_case.dart
|
import 'package:core/utils/debounce_manager.dart';
import 'package:injectable/injectable.dart';
import '../models/recipe_entity/recipe_entity.dart';
import '../repositories/recipe_repository.dart';
@LazySingleton()
class SearchRecipesUseCase {
final RecipeRepository repository;
final DebounceManager debounceManager;
SearchRecipesUseCase({
required this.repository,
required this.debounceManager,
});
void call({
required final String query,
required final Function(List<RecipeEntity>) onResult,
}) {
debounceManager.run(
() async {
final result = await repository.searchRecipes(
query: query,
);
onResult(result.toList());
},
);
}
}
| 0
|
mirrored_repositories/recipe_finder/modules/domain/lib
|
mirrored_repositories/recipe_finder/modules/domain/lib/usecases/get_favorite_recipes_use_case.dart
|
import 'package:injectable/injectable.dart';
import '../models/recipe_entity/recipe_entity.dart';
import '../repositories/recipe_repository.dart';
@LazySingleton()
class GetFavoriteRecipesUseCase {
final RecipeRepository repository;
GetFavoriteRecipesUseCase({required this.repository});
Future<List<RecipeEntity>> call() async {
final response = await repository.getFavoriteRecipes();
return response.toList();
}
}
| 0
|
mirrored_repositories/recipe_finder/modules/domain/lib
|
mirrored_repositories/recipe_finder/modules/domain/lib/usecases/get_last_query_recipes_use_case.dart
|
import 'package:injectable/injectable.dart';
import '../models/recipe_entity/recipe_entity.dart';
import '../repositories/recipe_repository.dart';
@lazySingleton
class GetLastQueryRecipesUseCase {
final RecipeRepository repository;
GetLastQueryRecipesUseCase({
required this.repository,
});
Future<Iterable<RecipeEntity>> call() async {
return await repository.getRecipes();
}
}
| 0
|
mirrored_repositories/recipe_finder/modules/domain/lib
|
mirrored_repositories/recipe_finder/modules/domain/lib/usecases/add_favorite_recipe_use_case.dart
|
import 'package:injectable/injectable.dart';
import '../models/recipe_entity/recipe_entity.dart';
import '../repositories/recipe_repository.dart';
@LazySingleton()
class AddFavoriteRecipeUseCase {
final RecipeRepository repository;
AddFavoriteRecipeUseCase({required this.repository});
Future<void> call(RecipeEntity recipe) async {
return repository.addFavoriteRecipe(recipe);
}
}
| 0
|
mirrored_repositories/recipe_finder/modules/domain/test/lib/data_sources
|
mirrored_repositories/recipe_finder/modules/domain/test/lib/data_sources/remote/mock_result_data.dart
|
part of 'remote_recipe_data_source_test.dart';
const mockRecipeResponse = '''
{
"from": 1,
"to": 4,
"count": 10000,
"_links": {
"next": {
"href": "https://api.edamam.com/api/recipes/v2?app_key=f7ce5672f67e97572eed94fb0984eeda&mealType=Lunch&_cont=CHcVQBtNNQphDmgVQntAEX4BY0t3AwEVX3dDUmIbYwciVwBVQTFCUDNFZgR1AlZTSmRHVWcVY1UnBRFqX3cWQT1OcV9xBB8VADQWVhFCPwoxXVZEITQeVDcBaR4-SQ%3D%3D&type=public&app_id=19c82497",
"title": "Next page"
}
},
"hits": [
{
"recipe": {
"uri": "http://www.edamam.com/ontologies/edamam.owl#recipe_bbfc1a248bd6fe277e35fe01027de91f",
"label": "Naomi Duguid's Fried Noodles",
"image": "https://edamam-product-images.s3.amazonaws.com/web-img/041/04158b5869398c899942336274f0e0f7.jpg?X-Amz-Security-Token=IQoJb3JpZ2luX2VjEOX%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FwEaCXVzLWVhc3QtMSJHMEUCIQCJQIhC4qkNQMT%2BsfZBBM6imfSCbhc00qVjzyisP5jbTQIgXMqQdGGlAXZiff%2BGvNSrIr36AHleRUl%2BGIfUD8bwygEqwgUI3f%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FARAAGgwxODcwMTcxNTA5ODYiDM3sys8nakzofhDwXiqWBccYz0YciF5X1grIj6gaZZuBtpTjI9IkWAubjd7sTVJlYoexV87XA%2FB87TzPV%2FfI2zqHVQy2GpGfkVwL3Ly1qnOQ2BpRk4flwSjo0yHTDkksTs%2BXD8v2KCAUwqUxYGaM7sPQkQC32Q060ESB%2BOBIAhD1ssM%2F5b8mCPiFQw2bgGD5m6B5lFjvhrJESgb9QibQZL8I0zmfFxsz5c5f3G2mMzKoq6lEj5mdozARyAAAJ5G0Kilhlc4g%2F11N5dtj92wp1xPXsKriknz3XtezFsj%2F0v0Tq0ExabUWLJ8f1C8e%2B8c21ncWf5U1cAIfgBQ9PmOEdduFwfXIdZssJ%2FU%2FGb%2BHMP4QS0azQGD0yXjcSjunbuguH%2Bea0E3C2lFcbVgtG%2BgY7S9J5k7dCBtYgAYReml1QtxfSucUeSxSIp8giBjBj0JPr9kvpzxk6TggV%2BZCc3grqQuouJ%2FIm6AXrokvVxm7esnuj7XhmLDdPta8NlLL9o0yz1x9kWA%2Be9EvQebBY%2BhPdSOAkpdaR5M8i7LNpYwnF1QKmX2e7eIl1zxkq3DcjQqaBcpGREQV3s3u8MwXgs0z5oADHuleswS%2FMQUjZFzvoIRMr57rW7RSFCY3beAT2twX%2FpxxzwDUCMjiyGHSKoi1FSlXO6ho7jibg2P%2FOsO2u7gzUev%2B0CE5KWUPYvlCXrT%2Bd30UvGrzhpwOavbrdZ5Cnk21nv1o6CIfE0ZBeSu7ko8X07HbMZ%2ByT9kewIecODZ9I%2Ft7Df5%2B4VdvrHrqBfTBvtO4MVee16JAorw%2FmolH7iVsgprBx0W1oiwEIwTVoZje1YrDPah%2FbOrqP9BpK3XKCPhaSDh3LBbrBDruK%2F1SGg0zMjzaRsR%2Bd80ZfeIrv71uxFDFaPQoMO%2BklqIGOrEBIXOcU5WqFpqOnHohJ6zsIdyW2cDKsUOjo%2BxSSRx%2FiycpoDlLhkBwgxFH7h2BC94mIgT5fufqg1OUYConhFOxIuFZ%2FGVBCn0eZWUTigGnHCc9XAetoMd8EWZ9NEK8lcUSFVVYqxlVwi4hU6%2BAf4TWxUyrYdcATxSyOXNSDY22dBaOMICi7DPZr3AwR0FkBzhF%2F0vnmv6Pq6452uYLSBB21ZNTkEm8VLVbhqlb4748z8eb&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20230423T213731Z&X-Amz-SignedHeaders=host&X-Amz-Expires=3600&X-Amz-Credential=ASIASXCYXIIFBHDLLY5C%2F20230423%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Signature=59607d6111e02a7624ba6aebef5e829b88f0c472ea301922f1cba6a0f002f21f",
"images": {
"THUMBNAIL": {
"url": "https://edamam-product-images.s3.amazonaws.com/web-img/041/04158b5869398c899942336274f0e0f7-s.jpg?X-Amz-Security-Token=IQoJb3JpZ2luX2VjEOX%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FwEaCXVzLWVhc3QtMSJHMEUCIQCJQIhC4qkNQMT%2BsfZBBM6imfSCbhc00qVjzyisP5jbTQIgXMqQdGGlAXZiff%2BGvNSrIr36AHleRUl%2BGIfUD8bwygEqwgUI3f%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FARAAGgwxODcwMTcxNTA5ODYiDM3sys8nakzofhDwXiqWBccYz0YciF5X1grIj6gaZZuBtpTjI9IkWAubjd7sTVJlYoexV87XA%2FB87TzPV%2FfI2zqHVQy2GpGfkVwL3Ly1qnOQ2BpRk4flwSjo0yHTDkksTs%2BXD8v2KCAUwqUxYGaM7sPQkQC32Q060ESB%2BOBIAhD1ssM%2F5b8mCPiFQw2bgGD5m6B5lFjvhrJESgb9QibQZL8I0zmfFxsz5c5f3G2mMzKoq6lEj5mdozARyAAAJ5G0Kilhlc4g%2F11N5dtj92wp1xPXsKriknz3XtezFsj%2F0v0Tq0ExabUWLJ8f1C8e%2B8c21ncWf5U1cAIfgBQ9PmOEdduFwfXIdZssJ%2FU%2FGb%2BHMP4QS0azQGD0yXjcSjunbuguH%2Bea0E3C2lFcbVgtG%2BgY7S9J5k7dCBtYgAYReml1QtxfSucUeSxSIp8giBjBj0JPr9kvpzxk6TggV%2BZCc3grqQuouJ%2FIm6AXrokvVxm7esnuj7XhmLDdPta8NlLL9o0yz1x9kWA%2Be9EvQebBY%2BhPdSOAkpdaR5M8i7LNpYwnF1QKmX2e7eIl1zxkq3DcjQqaBcpGREQV3s3u8MwXgs0z5oADHuleswS%2FMQUjZFzvoIRMr57rW7RSFCY3beAT2twX%2FpxxzwDUCMjiyGHSKoi1FSlXO6ho7jibg2P%2FOsO2u7gzUev%2B0CE5KWUPYvlCXrT%2Bd30UvGrzhpwOavbrdZ5Cnk21nv1o6CIfE0ZBeSu7ko8X07HbMZ%2ByT9kewIecODZ9I%2Ft7Df5%2B4VdvrHrqBfTBvtO4MVee16JAorw%2FmolH7iVsgprBx0W1oiwEIwTVoZje1YrDPah%2FbOrqP9BpK3XKCPhaSDh3LBbrBDruK%2F1SGg0zMjzaRsR%2Bd80ZfeIrv71uxFDFaPQoMO%2BklqIGOrEBIXOcU5WqFpqOnHohJ6zsIdyW2cDKsUOjo%2BxSSRx%2FiycpoDlLhkBwgxFH7h2BC94mIgT5fufqg1OUYConhFOxIuFZ%2FGVBCn0eZWUTigGnHCc9XAetoMd8EWZ9NEK8lcUSFVVYqxlVwi4hU6%2BAf4TWxUyrYdcATxSyOXNSDY22dBaOMICi7DPZr3AwR0FkBzhF%2F0vnmv6Pq6452uYLSBB21ZNTkEm8VLVbhqlb4748z8eb&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20230423T213731Z&X-Amz-SignedHeaders=host&X-Amz-Expires=3600&X-Amz-Credential=ASIASXCYXIIFBHDLLY5C%2F20230423%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Signature=08b3b40d300d0e0395711ddd3650f81a393433ba21be15b6c5e776e79278fe58",
"width": 100,
"height": 100
},
"SMALL": {
"url": "https://edamam-product-images.s3.amazonaws.com/web-img/041/04158b5869398c899942336274f0e0f7-m.jpg?X-Amz-Security-Token=IQoJb3JpZ2luX2VjEOX%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FwEaCXVzLWVhc3QtMSJHMEUCIQCJQIhC4qkNQMT%2BsfZBBM6imfSCbhc00qVjzyisP5jbTQIgXMqQdGGlAXZiff%2BGvNSrIr36AHleRUl%2BGIfUD8bwygEqwgUI3f%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FARAAGgwxODcwMTcxNTA5ODYiDM3sys8nakzofhDwXiqWBccYz0YciF5X1grIj6gaZZuBtpTjI9IkWAubjd7sTVJlYoexV87XA%2FB87TzPV%2FfI2zqHVQy2GpGfkVwL3Ly1qnOQ2BpRk4flwSjo0yHTDkksTs%2BXD8v2KCAUwqUxYGaM7sPQkQC32Q060ESB%2BOBIAhD1ssM%2F5b8mCPiFQw2bgGD5m6B5lFjvhrJESgb9QibQZL8I0zmfFxsz5c5f3G2mMzKoq6lEj5mdozARyAAAJ5G0Kilhlc4g%2F11N5dtj92wp1xPXsKriknz3XtezFsj%2F0v0Tq0ExabUWLJ8f1C8e%2B8c21ncWf5U1cAIfgBQ9PmOEdduFwfXIdZssJ%2FU%2FGb%2BHMP4QS0azQGD0yXjcSjunbuguH%2Bea0E3C2lFcbVgtG%2BgY7S9J5k7dCBtYgAYReml1QtxfSucUeSxSIp8giBjBj0JPr9kvpzxk6TggV%2BZCc3grqQuouJ%2FIm6AXrokvVxm7esnuj7XhmLDdPta8NlLL9o0yz1x9kWA%2Be9EvQebBY%2BhPdSOAkpdaR5M8i7LNpYwnF1QKmX2e7eIl1zxkq3DcjQqaBcpGREQV3s3u8MwXgs0z5oADHuleswS%2FMQUjZFzvoIRMr57rW7RSFCY3beAT2twX%2FpxxzwDUCMjiyGHSKoi1FSlXO6ho7jibg2P%2FOsO2u7gzUev%2B0CE5KWUPYvlCXrT%2Bd30UvGrzhpwOavbrdZ5Cnk21nv1o6CIfE0ZBeSu7ko8X07HbMZ%2ByT9kewIecODZ9I%2Ft7Df5%2B4VdvrHrqBfTBvtO4MVee16JAorw%2FmolH7iVsgprBx0W1oiwEIwTVoZje1YrDPah%2FbOrqP9BpK3XKCPhaSDh3LBbrBDruK%2F1SGg0zMjzaRsR%2Bd80ZfeIrv71uxFDFaPQoMO%2BklqIGOrEBIXOcU5WqFpqOnHohJ6zsIdyW2cDKsUOjo%2BxSSRx%2FiycpoDlLhkBwgxFH7h2BC94mIgT5fufqg1OUYConhFOxIuFZ%2FGVBCn0eZWUTigGnHCc9XAetoMd8EWZ9NEK8lcUSFVVYqxlVwi4hU6%2BAf4TWxUyrYdcATxSyOXNSDY22dBaOMICi7DPZr3AwR0FkBzhF%2F0vnmv6Pq6452uYLSBB21ZNTkEm8VLVbhqlb4748z8eb&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20230423T213731Z&X-Amz-SignedHeaders=host&X-Amz-Expires=3600&X-Amz-Credential=ASIASXCYXIIFBHDLLY5C%2F20230423%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Signature=a13c11bed4fbe45572ed3aa4d17bf0da68641b5ba80dce156972c3ba617a7a50",
"width": 200,
"height": 200
},
"REGULAR": {
"url": "https://edamam-product-images.s3.amazonaws.com/web-img/041/04158b5869398c899942336274f0e0f7.jpg?X-Amz-Security-Token=IQoJb3JpZ2luX2VjEOX%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FwEaCXVzLWVhc3QtMSJHMEUCIQCJQIhC4qkNQMT%2BsfZBBM6imfSCbhc00qVjzyisP5jbTQIgXMqQdGGlAXZiff%2BGvNSrIr36AHleRUl%2BGIfUD8bwygEqwgUI3f%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FARAAGgwxODcwMTcxNTA5ODYiDM3sys8nakzofhDwXiqWBccYz0YciF5X1grIj6gaZZuBtpTjI9IkWAubjd7sTVJlYoexV87XA%2FB87TzPV%2FfI2zqHVQy2GpGfkVwL3Ly1qnOQ2BpRk4flwSjo0yHTDkksTs%2BXD8v2KCAUwqUxYGaM7sPQkQC32Q060ESB%2BOBIAhD1ssM%2F5b8mCPiFQw2bgGD5m6B5lFjvhrJESgb9QibQZL8I0zmfFxsz5c5f3G2mMzKoq6lEj5mdozARyAAAJ5G0Kilhlc4g%2F11N5dtj92wp1xPXsKriknz3XtezFsj%2F0v0Tq0ExabUWLJ8f1C8e%2B8c21ncWf5U1cAIfgBQ9PmOEdduFwfXIdZssJ%2FU%2FGb%2BHMP4QS0azQGD0yXjcSjunbuguH%2Bea0E3C2lFcbVgtG%2BgY7S9J5k7dCBtYgAYReml1QtxfSucUeSxSIp8giBjBj0JPr9kvpzxk6TggV%2BZCc3grqQuouJ%2FIm6AXrokvVxm7esnuj7XhmLDdPta8NlLL9o0yz1x9kWA%2Be9EvQebBY%2BhPdSOAkpdaR5M8i7LNpYwnF1QKmX2e7eIl1zxkq3DcjQqaBcpGREQV3s3u8MwXgs0z5oADHuleswS%2FMQUjZFzvoIRMr57rW7RSFCY3beAT2twX%2FpxxzwDUCMjiyGHSKoi1FSlXO6ho7jibg2P%2FOsO2u7gzUev%2B0CE5KWUPYvlCXrT%2Bd30UvGrzhpwOavbrdZ5Cnk21nv1o6CIfE0ZBeSu7ko8X07HbMZ%2ByT9kewIecODZ9I%2Ft7Df5%2B4VdvrHrqBfTBvtO4MVee16JAorw%2FmolH7iVsgprBx0W1oiwEIwTVoZje1YrDPah%2FbOrqP9BpK3XKCPhaSDh3LBbrBDruK%2F1SGg0zMjzaRsR%2Bd80ZfeIrv71uxFDFaPQoMO%2BklqIGOrEBIXOcU5WqFpqOnHohJ6zsIdyW2cDKsUOjo%2BxSSRx%2FiycpoDlLhkBwgxFH7h2BC94mIgT5fufqg1OUYConhFOxIuFZ%2FGVBCn0eZWUTigGnHCc9XAetoMd8EWZ9NEK8lcUSFVVYqxlVwi4hU6%2BAf4TWxUyrYdcATxSyOXNSDY22dBaOMICi7DPZr3AwR0FkBzhF%2F0vnmv6Pq6452uYLSBB21ZNTkEm8VLVbhqlb4748z8eb&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20230423T213731Z&X-Amz-SignedHeaders=host&X-Amz-Expires=3600&X-Amz-Credential=ASIASXCYXIIFBHDLLY5C%2F20230423%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Signature=59607d6111e02a7624ba6aebef5e829b88f0c472ea301922f1cba6a0f002f21f",
"width": 300,
"height": 300
}
},
"source": "Serious Eats",
"url": "http://www.seriouseats.com/recipes/2012/10/naomi-duguids-fried-noodles.html",
"shareAs": "http://www.edamam.com/recipe/naomi-duguid-s-fried-noodles-bbfc1a248bd6fe277e35fe01027de91f/-",
"yield": 2,
"dietLabels": [
"Balanced",
"Low-Sodium"
],
"healthLabels": [
"Sugar-Conscious",
"Low Potassium",
"Kidney-Friendly",
"Vegetarian",
"Pescatarian",
"Dairy-Free",
"Tree-Nut-Free",
"Soy-Free",
"Fish-Free",
"Shellfish-Free",
"Pork-Free",
"Red-Meat-Free",
"Crustacean-Free",
"Celery-Free",
"Mustard-Free",
"Sesame-Free",
"Lupine-Free",
"Mollusk-Free",
"Alcohol-Free",
"Sulfite-Free",
"Kosher"
],
"cautions": [],
"ingredientLines": [
"1 cup dried egg noodles",
"Peanut oil, for frying"
],
"ingredients": [
{
"text": "1 cup dried egg noodles",
"quantity": 1,
"measure": "cup",
"food": "egg noodles",
"weight": 38,
"foodCategory": "grains",
"foodId": "food_aefg3gqa71nrtpbhjfo3yb36kd81",
"image": "https://www.edamam.com/food-img/800/800c9c0d7cef6b5474723682ffa2878d.jpg"
},
{
"text": "Peanut oil, for frying",
"quantity": 0,
"measure": null,
"food": "Peanut oil",
"weight": 0.5167999999999999,
"foodCategory": "Oils",
"foodId": "food_ackj525b2vo905bisrwjabfanm5t",
"image": "https://www.edamam.com/food-img/827/82725f6b015e75a059ba2569c768eb68.jpg"
}
],
"calories": 196.30800000000002,
"totalWeight": 43.7,
"totalTime": 20,
"cuisineType": [
"asian"
],
"mealType": [
"lunch/dinner"
],
"dishType": [
"main course"
],
"totalNutrients": {
"ENERC_KCAL": {
"label": "Energy",
"quantity": 196.30800000000002,
"unit": "kcal"
},
"FAT": {
"label": "Fat",
"quantity": 7.3872,
"unit": "g"
},
"FASAT": {
"label": "Saturated",
"quantity": 1.4117,
"unit": "g"
},
"FATRN": {
"label": "Trans",
"quantity": 0.02318,
"unit": "g"
},
"FAMS": {
"label": "Monounsaturated",
"quantity": 3.1091600000000006,
"unit": "g"
},
"FAPU": {
"label": "Polyunsaturated",
"quantity": 2.32978,
"unit": "g"
},
"CHOCDF": {
"label": "Carbs",
"quantity": 27.0826,
"unit": "g"
},
"CHOCDF.net": {
"label": "Carbohydrates (net)",
"quantity": 25.828599999999998,
"unit": "g"
},
"FIBTG": {
"label": "Fiber",
"quantity": 1.254,
"unit": "g"
},
"SUGAR": {
"label": "Sugars",
"quantity": 0.7143999999999999,
"unit": "g"
},
"SUGAR.added": {
"label": "Sugars, added",
"quantity": 0,
"unit": "g"
},
"PROCNT": {
"label": "Protein",
"quantity": 5.3808,
"unit": "g"
},
"CHOLE": {
"label": "Cholesterol",
"quantity": 31.92,
"unit": "mg"
},
"NA": {
"label": "Sodium",
"quantity": 7.98,
"unit": "mg"
},
"CA": {
"label": "Calcium",
"quantity": 13.3,
"unit": "mg"
},
"MG": {
"label": "Magnesium",
"quantity": 22.04,
"unit": "mg"
},
"K": {
"label": "Potassium",
"quantity": 92.72,
"unit": "mg"
},
"FE": {
"label": "Iron",
"quantity": 1.5255100000000001,
"unit": "mg"
},
"ZN": {
"label": "Zinc",
"quantity": 0.73017,
"unit": "mg"
},
"P": {
"label": "Phosphorus",
"quantity": 91.58,
"unit": "mg"
},
"VITA_RAE": {
"label": "Vitamin A",
"quantity": 6.46,
"unit": "µg"
},
"VITC": {
"label": "Vitamin C",
"quantity": 0,
"unit": "mg"
},
"THIA": {
"label": "Thiamin (B1)",
"quantity": 0.43054000000000003,
"unit": "mg"
},
"RIBF": {
"label": "Riboflavin (B2)",
"quantity": 0.16188,
"unit": "mg"
},
"NIA": {
"label": "Niacin (B3)",
"quantity": 3.1870600000000002,
"unit": "mg"
},
"VITB6A": {
"label": "Vitamin B6",
"quantity": 0.08208,
"unit": "mg"
},
"FOLDFE": {
"label": "Folate equivalent (total)",
"quantity": 140.6,
"unit": "µg"
},
"FOLFD": {
"label": "Folate (food)",
"quantity": 11.02,
"unit": "µg"
},
"FOLAC": {
"label": "Folic acid",
"quantity": 76.38,
"unit": "µg"
},
"VITB12": {
"label": "Vitamin B12",
"quantity": 0.11019999999999999,
"unit": "µg"
},
"VITD": {
"label": "Vitamin D",
"quantity": 0.11399999999999999,
"unit": "µg"
},
"TOCPHA": {
"label": "Vitamin E",
"quantity": 1.03493,
"unit": "mg"
},
"VITK1": {
"label": "Vitamin K",
"quantity": 0.2299,
"unit": "µg"
},
"Sugar.alcohol": {
"label": "Sugar alcohol",
"quantity": 0,
"unit": "g"
},
"WATER": {
"label": "Water",
"quantity": 3.4238,
"unit": "g"
}
},
"totalDaily": {
"ENERC_KCAL": {
"label": "Energy",
"quantity": 9.815400000000002,
"unit": "%"
},
"FAT": {
"label": "Fat",
"quantity": 11.364923076923077,
"unit": "%"
},
"FASAT": {
"label": "Saturated",
"quantity": 7.0584999999999996,
"unit": "%"
},
"CHOCDF": {
"label": "Carbs",
"quantity": 9.027533333333333,
"unit": "%"
},
"FIBTG": {
"label": "Fiber",
"quantity": 5.016,
"unit": "%"
},
"PROCNT": {
"label": "Protein",
"quantity": 10.761599999999998,
"unit": "%"
},
"CHOLE": {
"label": "Cholesterol",
"quantity": 10.64,
"unit": "%"
},
"NA": {
"label": "Sodium",
"quantity": 0.3325,
"unit": "%"
},
"CA": {
"label": "Calcium",
"quantity": 1.33,
"unit": "%"
},
"MG": {
"label": "Magnesium",
"quantity": 5.247619047619048,
"unit": "%"
},
"K": {
"label": "Potassium",
"quantity": 1.9727659574468086,
"unit": "%"
},
"FE": {
"label": "Iron",
"quantity": 8.475055555555556,
"unit": "%"
},
"ZN": {
"label": "Zinc",
"quantity": 6.6379090909090905,
"unit": "%"
},
"P": {
"label": "Phosphorus",
"quantity": 13.082857142857144,
"unit": "%"
},
"VITA_RAE": {
"label": "Vitamin A",
"quantity": 0.7177777777777777,
"unit": "%"
},
"VITC": {
"label": "Vitamin C",
"quantity": 0,
"unit": "%"
},
"THIA": {
"label": "Thiamin (B1)",
"quantity": 35.87833333333334,
"unit": "%"
},
"RIBF": {
"label": "Riboflavin (B2)",
"quantity": 12.452307692307691,
"unit": "%"
},
"NIA": {
"label": "Niacin (B3)",
"quantity": 19.919125,
"unit": "%"
},
"VITB6A": {
"label": "Vitamin B6",
"quantity": 6.313846153846153,
"unit": "%"
},
"FOLDFE": {
"label": "Folate equivalent (total)",
"quantity": 35.15,
"unit": "%"
},
"VITB12": {
"label": "Vitamin B12",
"quantity": 4.591666666666667,
"unit": "%"
},
"VITD": {
"label": "Vitamin D",
"quantity": 0.7599999999999999,
"unit": "%"
},
"TOCPHA": {
"label": "Vitamin E",
"quantity": 6.899533333333333,
"unit": "%"
},
"VITK1": {
"label": "Vitamin K",
"quantity": 0.19158333333333333,
"unit": "%"
}
},
"digest": [
{
"label": "Fat",
"tag": "FAT",
"schemaOrgTag": "fatContent",
"total": 7.3872,
"hasRDI": true,
"daily": 11.364923076923077,
"unit": "g",
"sub": [
{
"label": "Saturated",
"tag": "FASAT",
"schemaOrgTag": "saturatedFatContent",
"total": 1.4117,
"hasRDI": true,
"daily": 7.0584999999999996,
"unit": "g"
},
{
"label": "Trans",
"tag": "FATRN",
"schemaOrgTag": "transFatContent",
"total": 0.02318,
"hasRDI": false,
"daily": 0,
"unit": "g"
},
{
"label": "Monounsaturated",
"tag": "FAMS",
"schemaOrgTag": null,
"total": 3.1091600000000006,
"hasRDI": false,
"daily": 0,
"unit": "g"
},
{
"label": "Polyunsaturated",
"tag": "FAPU",
"schemaOrgTag": null,
"total": 2.32978,
"hasRDI": false,
"daily": 0,
"unit": "g"
}
]
},
{
"label": "Carbs",
"tag": "CHOCDF",
"schemaOrgTag": "carbohydrateContent",
"total": 27.0826,
"hasRDI": true,
"daily": 9.027533333333333,
"unit": "g",
"sub": [
{
"label": "Carbs (net)",
"tag": "CHOCDF.net",
"schemaOrgTag": null,
"total": 25.828599999999998,
"hasRDI": false,
"daily": 0,
"unit": "g"
},
{
"label": "Fiber",
"tag": "FIBTG",
"schemaOrgTag": "fiberContent",
"total": 1.254,
"hasRDI": true,
"daily": 5.016,
"unit": "g"
},
{
"label": "Sugars",
"tag": "SUGAR",
"schemaOrgTag": "sugarContent",
"total": 0.7143999999999999,
"hasRDI": false,
"daily": 0,
"unit": "g"
},
{
"label": "Sugars, added",
"tag": "SUGAR.added",
"schemaOrgTag": null,
"total": 0,
"hasRDI": false,
"daily": 0,
"unit": "g"
}
]
},
{
"label": "Protein",
"tag": "PROCNT",
"schemaOrgTag": "proteinContent",
"total": 5.3808,
"hasRDI": true,
"daily": 10.761599999999998,
"unit": "g"
},
{
"label": "Cholesterol",
"tag": "CHOLE",
"schemaOrgTag": "cholesterolContent",
"total": 31.92,
"hasRDI": true,
"daily": 10.64,
"unit": "mg"
},
{
"label": "Sodium",
"tag": "NA",
"schemaOrgTag": "sodiumContent",
"total": 7.98,
"hasRDI": true,
"daily": 0.3325,
"unit": "mg"
},
{
"label": "Calcium",
"tag": "CA",
"schemaOrgTag": null,
"total": 13.3,
"hasRDI": true,
"daily": 1.33,
"unit": "mg"
},
{
"label": "Magnesium",
"tag": "MG",
"schemaOrgTag": null,
"total": 22.04,
"hasRDI": true,
"daily": 5.247619047619048,
"unit": "mg"
},
{
"label": "Potassium",
"tag": "K",
"schemaOrgTag": null,
"total": 92.72,
"hasRDI": true,
"daily": 1.9727659574468086,
"unit": "mg"
},
{
"label": "Iron",
"tag": "FE",
"schemaOrgTag": null,
"total": 1.5255100000000001,
"hasRDI": true,
"daily": 8.475055555555556,
"unit": "mg"
},
{
"label": "Zinc",
"tag": "ZN",
"schemaOrgTag": null,
"total": 0.73017,
"hasRDI": true,
"daily": 6.6379090909090905,
"unit": "mg"
},
{
"label": "Phosphorus",
"tag": "P",
"schemaOrgTag": null,
"total": 91.58,
"hasRDI": true,
"daily": 13.082857142857144,
"unit": "mg"
},
{
"label": "Vitamin A",
"tag": "VITA_RAE",
"schemaOrgTag": null,
"total": 6.46,
"hasRDI": true,
"daily": 0.7177777777777777,
"unit": "µg"
},
{
"label": "Vitamin C",
"tag": "VITC",
"schemaOrgTag": null,
"total": 0,
"hasRDI": true,
"daily": 0,
"unit": "mg"
},
{
"label": "Thiamin (B1)",
"tag": "THIA",
"schemaOrgTag": null,
"total": 0.43054000000000003,
"hasRDI": true,
"daily": 35.87833333333334,
"unit": "mg"
},
{
"label": "Riboflavin (B2)",
"tag": "RIBF",
"schemaOrgTag": null,
"total": 0.16188,
"hasRDI": true,
"daily": 12.452307692307691,
"unit": "mg"
},
{
"label": "Niacin (B3)",
"tag": "NIA",
"schemaOrgTag": null,
"total": 3.1870600000000002,
"hasRDI": true,
"daily": 19.919125,
"unit": "mg"
},
{
"label": "Vitamin B6",
"tag": "VITB6A",
"schemaOrgTag": null,
"total": 0.08208,
"hasRDI": true,
"daily": 6.313846153846153,
"unit": "mg"
},
{
"label": "Folate equivalent (total)",
"tag": "FOLDFE",
"schemaOrgTag": null,
"total": 140.6,
"hasRDI": true,
"daily": 35.15,
"unit": "µg"
},
{
"label": "Folate (food)",
"tag": "FOLFD",
"schemaOrgTag": null,
"total": 11.02,
"hasRDI": false,
"daily": 0,
"unit": "µg"
},
{
"label": "Folic acid",
"tag": "FOLAC",
"schemaOrgTag": null,
"total": 76.38,
"hasRDI": false,
"daily": 0,
"unit": "µg"
},
{
"label": "Vitamin B12",
"tag": "VITB12",
"schemaOrgTag": null,
"total": 0.11019999999999999,
"hasRDI": true,
"daily": 4.591666666666667,
"unit": "µg"
},
{
"label": "Vitamin D",
"tag": "VITD",
"schemaOrgTag": null,
"total": 0.11399999999999999,
"hasRDI": true,
"daily": 0.7599999999999999,
"unit": "µg"
},
{
"label": "Vitamin E",
"tag": "TOCPHA",
"schemaOrgTag": null,
"total": 1.03493,
"hasRDI": true,
"daily": 6.899533333333333,
"unit": "mg"
},
{
"label": "Vitamin K",
"tag": "VITK1",
"schemaOrgTag": null,
"total": 0.2299,
"hasRDI": true,
"daily": 0.19158333333333333,
"unit": "µg"
},
{
"label": "Sugar alcohols",
"tag": "Sugar.alcohol",
"schemaOrgTag": null,
"total": 0,
"hasRDI": false,
"daily": 0,
"unit": "g"
},
{
"label": "Water",
"tag": "WATER",
"schemaOrgTag": null,
"total": 3.4238,
"hasRDI": false,
"daily": 0,
"unit": "g"
}
]
},
"_links": {
"self": {
"title": "Self",
"href": "https://api.edamam.com/api/recipes/v2/bbfc1a248bd6fe277e35fe01027de91f?type=public&app_id=19c82497&app_key=f7ce5672f67e97572eed94fb0984eeda"
}
}
},
{
"recipe": {
"uri": "http://www.edamam.com/ontologies/edamam.owl#recipe_84b8126a7e5c3ceea9dcaee0f4d8df00",
"label": "Strawberry Vodka",
"image": "https://edamam-product-images.s3.amazonaws.com/web-img/018/018c94e42ca9816d6800e22e1d967906.jpg?X-Amz-Security-Token=IQoJb3JpZ2luX2VjEOX%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FwEaCXVzLWVhc3QtMSJHMEUCIQCJQIhC4qkNQMT%2BsfZBBM6imfSCbhc00qVjzyisP5jbTQIgXMqQdGGlAXZiff%2BGvNSrIr36AHleRUl%2BGIfUD8bwygEqwgUI3f%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FARAAGgwxODcwMTcxNTA5ODYiDM3sys8nakzofhDwXiqWBccYz0YciF5X1grIj6gaZZuBtpTjI9IkWAubjd7sTVJlYoexV87XA%2FB87TzPV%2FfI2zqHVQy2GpGfkVwL3Ly1qnOQ2BpRk4flwSjo0yHTDkksTs%2BXD8v2KCAUwqUxYGaM7sPQkQC32Q060ESB%2BOBIAhD1ssM%2F5b8mCPiFQw2bgGD5m6B5lFjvhrJESgb9QibQZL8I0zmfFxsz5c5f3G2mMzKoq6lEj5mdozARyAAAJ5G0Kilhlc4g%2F11N5dtj92wp1xPXsKriknz3XtezFsj%2F0v0Tq0ExabUWLJ8f1C8e%2B8c21ncWf5U1cAIfgBQ9PmOEdduFwfXIdZssJ%2FU%2FGb%2BHMP4QS0azQGD0yXjcSjunbuguH%2Bea0E3C2lFcbVgtG%2BgY7S9J5k7dCBtYgAYReml1QtxfSucUeSxSIp8giBjBj0JPr9kvpzxk6TggV%2BZCc3grqQuouJ%2FIm6AXrokvVxm7esnuj7XhmLDdPta8NlLL9o0yz1x9kWA%2Be9EvQebBY%2BhPdSOAkpdaR5M8i7LNpYwnF1QKmX2e7eIl1zxkq3DcjQqaBcpGREQV3s3u8MwXgs0z5oADHuleswS%2FMQUjZFzvoIRMr57rW7RSFCY3beAT2twX%2FpxxzwDUCMjiyGHSKoi1FSlXO6ho7jibg2P%2FOsO2u7gzUev%2B0CE5KWUPYvlCXrT%2Bd30UvGrzhpwOavbrdZ5Cnk21nv1o6CIfE0ZBeSu7ko8X07HbMZ%2ByT9kewIecODZ9I%2Ft7Df5%2B4VdvrHrqBfTBvtO4MVee16JAorw%2FmolH7iVsgprBx0W1oiwEIwTVoZje1YrDPah%2FbOrqP9BpK3XKCPhaSDh3LBbrBDruK%2F1SGg0zMjzaRsR%2Bd80ZfeIrv71uxFDFaPQoMO%2BklqIGOrEBIXOcU5WqFpqOnHohJ6zsIdyW2cDKsUOjo%2BxSSRx%2FiycpoDlLhkBwgxFH7h2BC94mIgT5fufqg1OUYConhFOxIuFZ%2FGVBCn0eZWUTigGnHCc9XAetoMd8EWZ9NEK8lcUSFVVYqxlVwi4hU6%2BAf4TWxUyrYdcATxSyOXNSDY22dBaOMICi7DPZr3AwR0FkBzhF%2F0vnmv6Pq6452uYLSBB21ZNTkEm8VLVbhqlb4748z8eb&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20230423T213731Z&X-Amz-SignedHeaders=host&X-Amz-Expires=3600&X-Amz-Credential=ASIASXCYXIIFBHDLLY5C%2F20230423%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Signature=90f142d3e733d0ac80f9c0908a84196fb584c3d9978820a3863592245eac04d7",
"images": {
"THUMBNAIL": {
"url": "https://edamam-product-images.s3.amazonaws.com/web-img/018/018c94e42ca9816d6800e22e1d967906-s.jpg?X-Amz-Security-Token=IQoJb3JpZ2luX2VjEOX%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FwEaCXVzLWVhc3QtMSJHMEUCIQCJQIhC4qkNQMT%2BsfZBBM6imfSCbhc00qVjzyisP5jbTQIgXMqQdGGlAXZiff%2BGvNSrIr36AHleRUl%2BGIfUD8bwygEqwgUI3f%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FARAAGgwxODcwMTcxNTA5ODYiDM3sys8nakzofhDwXiqWBccYz0YciF5X1grIj6gaZZuBtpTjI9IkWAubjd7sTVJlYoexV87XA%2FB87TzPV%2FfI2zqHVQy2GpGfkVwL3Ly1qnOQ2BpRk4flwSjo0yHTDkksTs%2BXD8v2KCAUwqUxYGaM7sPQkQC32Q060ESB%2BOBIAhD1ssM%2F5b8mCPiFQw2bgGD5m6B5lFjvhrJESgb9QibQZL8I0zmfFxsz5c5f3G2mMzKoq6lEj5mdozARyAAAJ5G0Kilhlc4g%2F11N5dtj92wp1xPXsKriknz3XtezFsj%2F0v0Tq0ExabUWLJ8f1C8e%2B8c21ncWf5U1cAIfgBQ9PmOEdduFwfXIdZssJ%2FU%2FGb%2BHMP4QS0azQGD0yXjcSjunbuguH%2Bea0E3C2lFcbVgtG%2BgY7S9J5k7dCBtYgAYReml1QtxfSucUeSxSIp8giBjBj0JPr9kvpzxk6TggV%2BZCc3grqQuouJ%2FIm6AXrokvVxm7esnuj7XhmLDdPta8NlLL9o0yz1x9kWA%2Be9EvQebBY%2BhPdSOAkpdaR5M8i7LNpYwnF1QKmX2e7eIl1zxkq3DcjQqaBcpGREQV3s3u8MwXgs0z5oADHuleswS%2FMQUjZFzvoIRMr57rW7RSFCY3beAT2twX%2FpxxzwDUCMjiyGHSKoi1FSlXO6ho7jibg2P%2FOsO2u7gzUev%2B0CE5KWUPYvlCXrT%2Bd30UvGrzhpwOavbrdZ5Cnk21nv1o6CIfE0ZBeSu7ko8X07HbMZ%2ByT9kewIecODZ9I%2Ft7Df5%2B4VdvrHrqBfTBvtO4MVee16JAorw%2FmolH7iVsgprBx0W1oiwEIwTVoZje1YrDPah%2FbOrqP9BpK3XKCPhaSDh3LBbrBDruK%2F1SGg0zMjzaRsR%2Bd80ZfeIrv71uxFDFaPQoMO%2BklqIGOrEBIXOcU5WqFpqOnHohJ6zsIdyW2cDKsUOjo%2BxSSRx%2FiycpoDlLhkBwgxFH7h2BC94mIgT5fufqg1OUYConhFOxIuFZ%2FGVBCn0eZWUTigGnHCc9XAetoMd8EWZ9NEK8lcUSFVVYqxlVwi4hU6%2BAf4TWxUyrYdcATxSyOXNSDY22dBaOMICi7DPZr3AwR0FkBzhF%2F0vnmv6Pq6452uYLSBB21ZNTkEm8VLVbhqlb4748z8eb&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20230423T213731Z&X-Amz-SignedHeaders=host&X-Amz-Expires=3600&X-Amz-Credential=ASIASXCYXIIFBHDLLY5C%2F20230423%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Signature=200ccf0ffce65ff74f1346dc69f49412c450bb20299d228698fe5561aaac9fac",
"width": 100,
"height": 100
},
"SMALL": {
"url": "https://edamam-product-images.s3.amazonaws.com/web-img/018/018c94e42ca9816d6800e22e1d967906-m.jpg?X-Amz-Security-Token=IQoJb3JpZ2luX2VjEOX%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FwEaCXVzLWVhc3QtMSJHMEUCIQCJQIhC4qkNQMT%2BsfZBBM6imfSCbhc00qVjzyisP5jbTQIgXMqQdGGlAXZiff%2BGvNSrIr36AHleRUl%2BGIfUD8bwygEqwgUI3f%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FARAAGgwxODcwMTcxNTA5ODYiDM3sys8nakzofhDwXiqWBccYz0YciF5X1grIj6gaZZuBtpTjI9IkWAubjd7sTVJlYoexV87XA%2FB87TzPV%2FfI2zqHVQy2GpGfkVwL3Ly1qnOQ2BpRk4flwSjo0yHTDkksTs%2BXD8v2KCAUwqUxYGaM7sPQkQC32Q060ESB%2BOBIAhD1ssM%2F5b8mCPiFQw2bgGD5m6B5lFjvhrJESgb9QibQZL8I0zmfFxsz5c5f3G2mMzKoq6lEj5mdozARyAAAJ5G0Kilhlc4g%2F11N5dtj92wp1xPXsKriknz3XtezFsj%2F0v0Tq0ExabUWLJ8f1C8e%2B8c21ncWf5U1cAIfgBQ9PmOEdduFwfXIdZssJ%2FU%2FGb%2BHMP4QS0azQGD0yXjcSjunbuguH%2Bea0E3C2lFcbVgtG%2BgY7S9J5k7dCBtYgAYReml1QtxfSucUeSxSIp8giBjBj0JPr9kvpzxk6TggV%2BZCc3grqQuouJ%2FIm6AXrokvVxm7esnuj7XhmLDdPta8NlLL9o0yz1x9kWA%2Be9EvQebBY%2BhPdSOAkpdaR5M8i7LNpYwnF1QKmX2e7eIl1zxkq3DcjQqaBcpGREQV3s3u8MwXgs0z5oADHuleswS%2FMQUjZFzvoIRMr57rW7RSFCY3beAT2twX%2FpxxzwDUCMjiyGHSKoi1FSlXO6ho7jibg2P%2FOsO2u7gzUev%2B0CE5KWUPYvlCXrT%2Bd30UvGrzhpwOavbrdZ5Cnk21nv1o6CIfE0ZBeSu7ko8X07HbMZ%2ByT9kewIecODZ9I%2Ft7Df5%2B4VdvrHrqBfTBvtO4MVee16JAorw%2FmolH7iVsgprBx0W1oiwEIwTVoZje1YrDPah%2FbOrqP9BpK3XKCPhaSDh3LBbrBDruK%2F1SGg0zMjzaRsR%2Bd80ZfeIrv71uxFDFaPQoMO%2BklqIGOrEBIXOcU5WqFpqOnHohJ6zsIdyW2cDKsUOjo%2BxSSRx%2FiycpoDlLhkBwgxFH7h2BC94mIgT5fufqg1OUYConhFOxIuFZ%2FGVBCn0eZWUTigGnHCc9XAetoMd8EWZ9NEK8lcUSFVVYqxlVwi4hU6%2BAf4TWxUyrYdcATxSyOXNSDY22dBaOMICi7DPZr3AwR0FkBzhF%2F0vnmv6Pq6452uYLSBB21ZNTkEm8VLVbhqlb4748z8eb&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20230423T213731Z&X-Amz-SignedHeaders=host&X-Amz-Expires=3600&X-Amz-Credential=ASIASXCYXIIFBHDLLY5C%2F20230423%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Signature=2cf3ebf3b3a79eaf24e0f82c8855946fdae76002b0c1464d1387955865eca0d1",
"width": 200,
"height": 200
},
"REGULAR": {
"url": "https://edamam-product-images.s3.amazonaws.com/web-img/018/018c94e42ca9816d6800e22e1d967906.jpg?X-Amz-Security-Token=IQoJb3JpZ2luX2VjEOX%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FwEaCXVzLWVhc3QtMSJHMEUCIQCJQIhC4qkNQMT%2BsfZBBM6imfSCbhc00qVjzyisP5jbTQIgXMqQdGGlAXZiff%2BGvNSrIr36AHleRUl%2BGIfUD8bwygEqwgUI3f%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FARAAGgwxODcwMTcxNTA5ODYiDM3sys8nakzofhDwXiqWBccYz0YciF5X1grIj6gaZZuBtpTjI9IkWAubjd7sTVJlYoexV87XA%2FB87TzPV%2FfI2zqHVQy2GpGfkVwL3Ly1qnOQ2BpRk4flwSjo0yHTDkksTs%2BXD8v2KCAUwqUxYGaM7sPQkQC32Q060ESB%2BOBIAhD1ssM%2F5b8mCPiFQw2bgGD5m6B5lFjvhrJESgb9QibQZL8I0zmfFxsz5c5f3G2mMzKoq6lEj5mdozARyAAAJ5G0Kilhlc4g%2F11N5dtj92wp1xPXsKriknz3XtezFsj%2F0v0Tq0ExabUWLJ8f1C8e%2B8c21ncWf5U1cAIfgBQ9PmOEdduFwfXIdZssJ%2FU%2FGb%2BHMP4QS0azQGD0yXjcSjunbuguH%2Bea0E3C2lFcbVgtG%2BgY7S9J5k7dCBtYgAYReml1QtxfSucUeSxSIp8giBjBj0JPr9kvpzxk6TggV%2BZCc3grqQuouJ%2FIm6AXrokvVxm7esnuj7XhmLDdPta8NlLL9o0yz1x9kWA%2Be9EvQebBY%2BhPdSOAkpdaR5M8i7LNpYwnF1QKmX2e7eIl1zxkq3DcjQqaBcpGREQV3s3u8MwXgs0z5oADHuleswS%2FMQUjZFzvoIRMr57rW7RSFCY3beAT2twX%2FpxxzwDUCMjiyGHSKoi1FSlXO6ho7jibg2P%2FOsO2u7gzUev%2B0CE5KWUPYvlCXrT%2Bd30UvGrzhpwOavbrdZ5Cnk21nv1o6CIfE0ZBeSu7ko8X07HbMZ%2ByT9kewIecODZ9I%2Ft7Df5%2B4VdvrHrqBfTBvtO4MVee16JAorw%2FmolH7iVsgprBx0W1oiwEIwTVoZje1YrDPah%2FbOrqP9BpK3XKCPhaSDh3LBbrBDruK%2F1SGg0zMjzaRsR%2Bd80ZfeIrv71uxFDFaPQoMO%2BklqIGOrEBIXOcU5WqFpqOnHohJ6zsIdyW2cDKsUOjo%2BxSSRx%2FiycpoDlLhkBwgxFH7h2BC94mIgT5fufqg1OUYConhFOxIuFZ%2FGVBCn0eZWUTigGnHCc9XAetoMd8EWZ9NEK8lcUSFVVYqxlVwi4hU6%2BAf4TWxUyrYdcATxSyOXNSDY22dBaOMICi7DPZr3AwR0FkBzhF%2F0vnmv6Pq6452uYLSBB21ZNTkEm8VLVbhqlb4748z8eb&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20230423T213731Z&X-Amz-SignedHeaders=host&X-Amz-Expires=3600&X-Amz-Credential=ASIASXCYXIIFBHDLLY5C%2F20230423%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Signature=90f142d3e733d0ac80f9c0908a84196fb584c3d9978820a3863592245eac04d7",
"width": 300,
"height": 300
}
},
"source": "David Lebovitz",
"url": "http://www.davidlebovitz.com/strawberry-vodka-recipe-infusion/",
"shareAs": "http://www.edamam.com/recipe/strawberry-vodka-84b8126a7e5c3ceea9dcaee0f4d8df00/-",
"yield": 14,
"dietLabels": [
"Low-Fat",
"Low-Sodium"
],
"healthLabels": [
"Sugar-Conscious",
"Low Potassium",
"Kidney-Friendly",
"Keto-Friendly",
"Vegan",
"Vegetarian",
"Pescatarian",
"Paleo",
"Mediterranean",
"Dairy-Free",
"Gluten-Free",
"Wheat-Free",
"Egg-Free",
"Peanut-Free",
"Tree-Nut-Free",
"Soy-Free",
"Fish-Free",
"Shellfish-Free",
"Pork-Free",
"Red-Meat-Free",
"Crustacean-Free",
"Celery-Free",
"Mustard-Free",
"Sesame-Free",
"Lupine-Free",
"Mollusk-Free",
"No oil added",
"Sulfite-Free",
"Kosher",
"Alcohol-Cocktail"
],
"cautions": [
"Wheat",
"Sulfites"
],
"ingredientLines": [
"One bottle (750ml) vodka",
"2 pints (about 1 1/4 pounds, 575g) strawberries, organic or unsprayed"
],
"ingredients": [
{
"text": "One bottle (750ml) vodka",
"quantity": 750,
"measure": "milliliter",
"food": "vodka",
"weight": 705.0223733334266,
"foodCategory": "liquors and cocktails",
"foodId": "food_aqnx4i8aieyph2athk58cb3cr69w",
"image": "https://www.edamam.com/food-img/e1a/e1a4708099e89fdadeb81c2d95deaa34.jpg"
},
{
"text": "2 pints (about 1 1/4 pounds, 575g) strawberries, organic or unsprayed",
"quantity": 2,
"measure": "pint",
"food": "strawberries",
"weight": 714,
"foodCategory": "fruit",
"foodId": "food_b4s2ibkbrrucmbabbaxhfau8ay42",
"image": "https://www.edamam.com/food-img/00c/00c8851e401bf7975be7f73499b4b573.jpg"
}
],
"calories": 1857.0816824002154,
"totalWeight": 1419.0223733334265,
"totalTime": 36,
"cuisineType": [
"world"
],
"mealType": [
"lunch/dinner"
],
"dishType": [
"alcohol cocktail"
],
"totalNutrients": {
"ENERC_KCAL": {
"label": "Energy",
"quantity": 1857.0816824002154,
"unit": "kcal"
},
"FAT": {
"label": "Fat",
"quantity": 2.142,
"unit": "g"
},
"FASAT": {
"label": "Saturated",
"quantity": 0.1071,
"unit": "g"
},
"FATRN": {
"label": "Trans",
"quantity": 0,
"unit": "g"
},
"FAMS": {
"label": "Monounsaturated",
"quantity": 0.30702,
"unit": "g"
},
"FAPU": {
"label": "Polyunsaturated",
"quantity": 1.1067,
"unit": "g"
},
"CHOCDF": {
"label": "Carbs",
"quantity": 54.8352,
"unit": "g"
},
"CHOCDF.net": {
"label": "Carbohydrates (net)",
"quantity": 40.5552,
"unit": "g"
},
"FIBTG": {
"label": "Fiber",
"quantity": 14.280000000000001,
"unit": "g"
},
"SUGAR": {
"label": "Sugars",
"quantity": 34.9146,
"unit": "g"
},
"SUGAR.added": {
"label": "Sugars, added",
"quantity": 0,
"unit": "g"
},
"PROCNT": {
"label": "Protein",
"quantity": 4.7838,
"unit": "g"
},
"CHOLE": {
"label": "Cholesterol",
"quantity": 0,
"unit": "mg"
},
"NA": {
"label": "Sodium",
"quantity": 14.190223733334266,
"unit": "mg"
},
"CA": {
"label": "Calcium",
"quantity": 114.24000000000001,
"unit": "mg"
},
"MG": {
"label": "Magnesium",
"quantity": 92.82000000000001,
"unit": "mg"
},
"K": {
"label": "Potassium",
"quantity": 1099.4702237333343,
"unit": "mg"
},
"FE": {
"label": "Iron",
"quantity": 2.9979022373333426,
"unit": "mg"
},
"ZN": {
"label": "Zinc",
"quantity": 0.9996,
"unit": "mg"
},
"P": {
"label": "Phosphorus",
"quantity": 206.61111866667136,
"unit": "mg"
},
"VITA_RAE": {
"label": "Vitamin A",
"quantity": 7.140000000000001,
"unit": "µg"
},
"VITC": {
"label": "Vitamin C",
"quantity": 419.832,
"unit": "mg"
},
"THIA": {
"label": "Thiamin (B1)",
"quantity": 0.20661111866667134,
"unit": "mg"
},
"RIBF": {
"label": "Riboflavin (B2)",
"quantity": 0.20643156613333985,
"unit": "mg"
},
"NIA": {
"label": "Niacin (B3)",
"quantity": 2.7560400000000005,
"unit": "mg"
},
"VITB6A": {
"label": "Vitamin B6",
"quantity": 0.33558000000000004,
"unit": "mg"
},
"FOLDFE": {
"label": "Folate equivalent (total)",
"quantity": 171.36,
"unit": "µg"
},
"FOLFD": {
"label": "Folate (food)",
"quantity": 171.36,
"unit": "µg"
},
"FOLAC": {
"label": "Folic acid",
"quantity": 0,
"unit": "µg"
},
"VITB12": {
"label": "Vitamin B12",
"quantity": 0,
"unit": "µg"
},
"VITD": {
"label": "Vitamin D",
"quantity": 0,
"unit": "µg"
},
"TOCPHA": {
"label": "Vitamin E",
"quantity": 2.0706,
"unit": "mg"
},
"VITK1": {
"label": "Vitamin K",
"quantity": 15.708000000000002,
"unit": "µg"
},
"Sugar.alcohol": {
"label": "Sugar alcohol",
"quantity": 0,
"unit": "g"
},
"WATER": {
"label": "Water",
"quantity": 1118.927900640062,
"unit": "g"
}
},
"totalDaily": {
"ENERC_KCAL": {
"label": "Energy",
"quantity": 92.85408412001077,
"unit": "%"
},
"FAT": {
"label": "Fat",
"quantity": 3.295384615384615,
"unit": "%"
},
"FASAT": {
"label": "Saturated",
"quantity": 0.5355000000000001,
"unit": "%"
},
"CHOCDF": {
"label": "Carbs",
"quantity": 18.2784,
"unit": "%"
},
"FIBTG": {
"label": "Fiber",
"quantity": 57.12,
"unit": "%"
},
"PROCNT": {
"label": "Protein",
"quantity": 9.5676,
"unit": "%"
},
"CHOLE": {
"label": "Cholesterol",
"quantity": 0,
"unit": "%"
},
"NA": {
"label": "Sodium",
"quantity": 0.5912593222222611,
"unit": "%"
},
"CA": {
"label": "Calcium",
"quantity": 11.424,
"unit": "%"
},
"MG": {
"label": "Magnesium",
"quantity": 22.1,
"unit": "%"
},
"K": {
"label": "Potassium",
"quantity": 23.392983483687964,
"unit": "%"
},
"FE": {
"label": "Iron",
"quantity": 16.65501242962968,
"unit": "%"
},
"ZN": {
"label": "Zinc",
"quantity": 9.087272727272728,
"unit": "%"
},
"P": {
"label": "Phosphorus",
"quantity": 29.515874095238765,
"unit": "%"
},
"VITA_RAE": {
"label": "Vitamin A",
"quantity": 0.7933333333333333,
"unit": "%"
},
"VITC": {
"label": "Vitamin C",
"quantity": 466.47999999999996,
"unit": "%"
},
"THIA": {
"label": "Thiamin (B1)",
"quantity": 17.217593222222614,
"unit": "%"
},
"RIBF": {
"label": "Riboflavin (B2)",
"quantity": 15.879351241026143,
"unit": "%"
},
"NIA": {
"label": "Niacin (B3)",
"quantity": 17.225250000000003,
"unit": "%"
},
"VITB6A": {
"label": "Vitamin B6",
"quantity": 25.813846153846157,
"unit": "%"
},
"FOLDFE": {
"label": "Folate equivalent (total)",
"quantity": 42.84,
"unit": "%"
},
"VITB12": {
"label": "Vitamin B12",
"quantity": 0,
"unit": "%"
},
"VITD": {
"label": "Vitamin D",
"quantity": 0,
"unit": "%"
},
"TOCPHA": {
"label": "Vitamin E",
"quantity": 13.804000000000002,
"unit": "%"
},
"VITK1": {
"label": "Vitamin K",
"quantity": 13.090000000000002,
"unit": "%"
}
},
"digest": [
{
"label": "Fat",
"tag": "FAT",
"schemaOrgTag": "fatContent",
"total": 2.142,
"hasRDI": true,
"daily": 3.295384615384615,
"unit": "g",
"sub": [
{
"label": "Saturated",
"tag": "FASAT",
"schemaOrgTag": "saturatedFatContent",
"total": 0.1071,
"hasRDI": true,
"daily": 0.5355000000000001,
"unit": "g"
},
{
"label": "Trans",
"tag": "FATRN",
"schemaOrgTag": "transFatContent",
"total": 0,
"hasRDI": false,
"daily": 0,
"unit": "g"
},
{
"label": "Monounsaturated",
"tag": "FAMS",
"schemaOrgTag": null,
"total": 0.30702,
"hasRDI": false,
"daily": 0,
"unit": "g"
},
{
"label": "Polyunsaturated",
"tag": "FAPU",
"schemaOrgTag": null,
"total": 1.1067,
"hasRDI": false,
"daily": 0,
"unit": "g"
}
]
},
{
"label": "Carbs",
"tag": "CHOCDF",
"schemaOrgTag": "carbohydrateContent",
"total": 54.8352,
"hasRDI": true,
"daily": 18.2784,
"unit": "g",
"sub": [
{
"label": "Carbs (net)",
"tag": "CHOCDF.net",
"schemaOrgTag": null,
"total": 40.5552,
"hasRDI": false,
"daily": 0,
"unit": "g"
},
{
"label": "Fiber",
"tag": "FIBTG",
"schemaOrgTag": "fiberContent",
"total": 14.280000000000001,
"hasRDI": true,
"daily": 57.12,
"unit": "g"
},
{
"label": "Sugars",
"tag": "SUGAR",
"schemaOrgTag": "sugarContent",
"total": 34.9146,
"hasRDI": false,
"daily": 0,
"unit": "g"
},
{
"label": "Sugars, added",
"tag": "SUGAR.added",
"schemaOrgTag": null,
"total": 0,
"hasRDI": false,
"daily": 0,
"unit": "g"
}
]
},
{
"label": "Protein",
"tag": "PROCNT",
"schemaOrgTag": "proteinContent",
"total": 4.7838,
"hasRDI": true,
"daily": 9.5676,
"unit": "g"
},
{
"label": "Cholesterol",
"tag": "CHOLE",
"schemaOrgTag": "cholesterolContent",
"total": 0,
"hasRDI": true,
"daily": 0,
"unit": "mg"
},
{
"label": "Sodium",
"tag": "NA",
"schemaOrgTag": "sodiumContent",
"total": 14.190223733334266,
"hasRDI": true,
"daily": 0.5912593222222611,
"unit": "mg"
},
{
"label": "Calcium",
"tag": "CA",
"schemaOrgTag": null,
"total": 114.24000000000001,
"hasRDI": true,
"daily": 11.424,
"unit": "mg"
},
{
"label": "Magnesium",
"tag": "MG",
"schemaOrgTag": null,
"total": 92.82000000000001,
"hasRDI": true,
"daily": 22.1,
"unit": "mg"
},
{
"label": "Potassium",
"tag": "K",
"schemaOrgTag": null,
"total": 1099.4702237333343,
"hasRDI": true,
"daily": 23.392983483687964,
"unit": "mg"
},
{
"label": "Iron",
"tag": "FE",
"schemaOrgTag": null,
"total": 2.9979022373333426,
"hasRDI": true,
"daily": 16.65501242962968,
"unit": "mg"
},
{
"label": "Zinc",
"tag": "ZN",
"schemaOrgTag": null,
"total": 0.9996,
"hasRDI": true,
"daily": 9.087272727272728,
"unit": "mg"
},
{
"label": "Phosphorus",
"tag": "P",
"schemaOrgTag": null,
"total": 206.61111866667136,
"hasRDI": true,
"daily": 29.515874095238765,
"unit": "mg"
},
{
"label": "Vitamin A",
"tag": "VITA_RAE",
"schemaOrgTag": null,
"total": 7.140000000000001,
"hasRDI": true,
"daily": 0.7933333333333333,
"unit": "µg"
},
{
"label": "Vitamin C",
"tag": "VITC",
"schemaOrgTag": null,
"total": 419.832,
"hasRDI": true,
"daily": 466.47999999999996,
"unit": "mg"
},
{
"label": "Thiamin (B1)",
"tag": "THIA",
"schemaOrgTag": null,
"total": 0.20661111866667134,
"hasRDI": true,
"daily": 17.217593222222614,
"unit": "mg"
},
{
"label": "Riboflavin (B2)",
"tag": "RIBF",
"schemaOrgTag": null,
"total": 0.20643156613333985,
"hasRDI": true,
"daily": 15.879351241026143,
"unit": "mg"
},
{
"label": "Niacin (B3)",
"tag": "NIA",
"schemaOrgTag": null,
"total": 2.7560400000000005,
"hasRDI": true,
"daily": 17.225250000000003,
"unit": "mg"
},
{
"label": "Vitamin B6",
"tag": "VITB6A",
"schemaOrgTag": null,
"total": 0.33558000000000004,
"hasRDI": true,
"daily": 25.813846153846157,
"unit": "mg"
},
{
"label": "Folate equivalent (total)",
"tag": "FOLDFE",
"schemaOrgTag": null,
"total": 171.36,
"hasRDI": true,
"daily": 42.84,
"unit": "µg"
},
{
"label": "Folate (food)",
"tag": "FOLFD",
"schemaOrgTag": null,
"total": 171.36,
"hasRDI": false,
"daily": 0,
"unit": "µg"
},
{
"label": "Folic acid",
"tag": "FOLAC",
"schemaOrgTag": null,
"total": 0,
"hasRDI": false,
"daily": 0,
"unit": "µg"
},
{
"label": "Vitamin B12",
"tag": "VITB12",
"schemaOrgTag": null,
"total": 0,
"hasRDI": true,
"daily": 0,
"unit": "µg"
},
{
"label": "Vitamin D",
"tag": "VITD",
"schemaOrgTag": null,
"total": 0,
"hasRDI": true,
"daily": 0,
"unit": "µg"
},
{
"label": "Vitamin E",
"tag": "TOCPHA",
"schemaOrgTag": null,
"total": 2.0706,
"hasRDI": true,
"daily": 13.804000000000002,
"unit": "mg"
},
{
"label": "Vitamin K",
"tag": "VITK1",
"schemaOrgTag": null,
"total": 15.708000000000002,
"hasRDI": true,
"daily": 13.090000000000002,
"unit": "µg"
},
{
"label": "Sugar alcohols",
"tag": "Sugar.alcohol",
"schemaOrgTag": null,
"total": 0,
"hasRDI": false,
"daily": 0,
"unit": "g"
},
{
"label": "Water",
"tag": "WATER",
"schemaOrgTag": null,
"total": 1118.927900640062,
"hasRDI": false,
"daily": 0,
"unit": "g"
}
]
},
"_links": {
"self": {
"title": "Self",
"href": "https://api.edamam.com/api/recipes/v2/84b8126a7e5c3ceea9dcaee0f4d8df00?type=public&app_id=19c82497&app_key=f7ce5672f67e97572eed94fb0984eeda"
}
}
},
{
"recipe": {
"uri": "http://www.edamam.com/ontologies/edamam.owl#recipe_067f0b7be628ae847366e4f3e614b319",
"label": "Maple Banana Frozen Yogurt",
"image": "https://edamam-product-images.s3.amazonaws.com/web-img/b2d/b2dbd9ac524a41cae54682d3b5dc8d10.jpg?X-Amz-Security-Token=IQoJb3JpZ2luX2VjEOX%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FwEaCXVzLWVhc3QtMSJHMEUCIQCJQIhC4qkNQMT%2BsfZBBM6imfSCbhc00qVjzyisP5jbTQIgXMqQdGGlAXZiff%2BGvNSrIr36AHleRUl%2BGIfUD8bwygEqwgUI3f%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FARAAGgwxODcwMTcxNTA5ODYiDM3sys8nakzofhDwXiqWBccYz0YciF5X1grIj6gaZZuBtpTjI9IkWAubjd7sTVJlYoexV87XA%2FB87TzPV%2FfI2zqHVQy2GpGfkVwL3Ly1qnOQ2BpRk4flwSjo0yHTDkksTs%2BXD8v2KCAUwqUxYGaM7sPQkQC32Q060ESB%2BOBIAhD1ssM%2F5b8mCPiFQw2bgGD5m6B5lFjvhrJESgb9QibQZL8I0zmfFxsz5c5f3G2mMzKoq6lEj5mdozARyAAAJ5G0Kilhlc4g%2F11N5dtj92wp1xPXsKriknz3XtezFsj%2F0v0Tq0ExabUWLJ8f1C8e%2B8c21ncWf5U1cAIfgBQ9PmOEdduFwfXIdZssJ%2FU%2FGb%2BHMP4QS0azQGD0yXjcSjunbuguH%2Bea0E3C2lFcbVgtG%2BgY7S9J5k7dCBtYgAYReml1QtxfSucUeSxSIp8giBjBj0JPr9kvpzxk6TggV%2BZCc3grqQuouJ%2FIm6AXrokvVxm7esnuj7XhmLDdPta8NlLL9o0yz1x9kWA%2Be9EvQebBY%2BhPdSOAkpdaR5M8i7LNpYwnF1QKmX2e7eIl1zxkq3DcjQqaBcpGREQV3s3u8MwXgs0z5oADHuleswS%2FMQUjZFzvoIRMr57rW7RSFCY3beAT2twX%2FpxxzwDUCMjiyGHSKoi1FSlXO6ho7jibg2P%2FOsO2u7gzUev%2B0CE5KWUPYvlCXrT%2Bd30UvGrzhpwOavbrdZ5Cnk21nv1o6CIfE0ZBeSu7ko8X07HbMZ%2ByT9kewIecODZ9I%2Ft7Df5%2B4VdvrHrqBfTBvtO4MVee16JAorw%2FmolH7iVsgprBx0W1oiwEIwTVoZje1YrDPah%2FbOrqP9BpK3XKCPhaSDh3LBbrBDruK%2F1SGg0zMjzaRsR%2Bd80ZfeIrv71uxFDFaPQoMO%2BklqIGOrEBIXOcU5WqFpqOnHohJ6zsIdyW2cDKsUOjo%2BxSSRx%2FiycpoDlLhkBwgxFH7h2BC94mIgT5fufqg1OUYConhFOxIuFZ%2FGVBCn0eZWUTigGnHCc9XAetoMd8EWZ9NEK8lcUSFVVYqxlVwi4hU6%2BAf4TWxUyrYdcATxSyOXNSDY22dBaOMICi7DPZr3AwR0FkBzhF%2F0vnmv6Pq6452uYLSBB21ZNTkEm8VLVbhqlb4748z8eb&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20230423T213731Z&X-Amz-SignedHeaders=host&X-Amz-Expires=3600&X-Amz-Credential=ASIASXCYXIIFBHDLLY5C%2F20230423%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Signature=d4fcf9ca4d8fdd7e8cc5fce988ba339e7ceece8922896ee1ff09186e3ab16aff",
"images": {
"THUMBNAIL": {
"url": "https://edamam-product-images.s3.amazonaws.com/web-img/b2d/b2dbd9ac524a41cae54682d3b5dc8d10-s.jpg?X-Amz-Security-Token=IQoJb3JpZ2luX2VjEOX%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FwEaCXVzLWVhc3QtMSJHMEUCIQCJQIhC4qkNQMT%2BsfZBBM6imfSCbhc00qVjzyisP5jbTQIgXMqQdGGlAXZiff%2BGvNSrIr36AHleRUl%2BGIfUD8bwygEqwgUI3f%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FARAAGgwxODcwMTcxNTA5ODYiDM3sys8nakzofhDwXiqWBccYz0YciF5X1grIj6gaZZuBtpTjI9IkWAubjd7sTVJlYoexV87XA%2FB87TzPV%2FfI2zqHVQy2GpGfkVwL3Ly1qnOQ2BpRk4flwSjo0yHTDkksTs%2BXD8v2KCAUwqUxYGaM7sPQkQC32Q060ESB%2BOBIAhD1ssM%2F5b8mCPiFQw2bgGD5m6B5lFjvhrJESgb9QibQZL8I0zmfFxsz5c5f3G2mMzKoq6lEj5mdozARyAAAJ5G0Kilhlc4g%2F11N5dtj92wp1xPXsKriknz3XtezFsj%2F0v0Tq0ExabUWLJ8f1C8e%2B8c21ncWf5U1cAIfgBQ9PmOEdduFwfXIdZssJ%2FU%2FGb%2BHMP4QS0azQGD0yXjcSjunbuguH%2Bea0E3C2lFcbVgtG%2BgY7S9J5k7dCBtYgAYReml1QtxfSucUeSxSIp8giBjBj0JPr9kvpzxk6TggV%2BZCc3grqQuouJ%2FIm6AXrokvVxm7esnuj7XhmLDdPta8NlLL9o0yz1x9kWA%2Be9EvQebBY%2BhPdSOAkpdaR5M8i7LNpYwnF1QKmX2e7eIl1zxkq3DcjQqaBcpGREQV3s3u8MwXgs0z5oADHuleswS%2FMQUjZFzvoIRMr57rW7RSFCY3beAT2twX%2FpxxzwDUCMjiyGHSKoi1FSlXO6ho7jibg2P%2FOsO2u7gzUev%2B0CE5KWUPYvlCXrT%2Bd30UvGrzhpwOavbrdZ5Cnk21nv1o6CIfE0ZBeSu7ko8X07HbMZ%2ByT9kewIecODZ9I%2Ft7Df5%2B4VdvrHrqBfTBvtO4MVee16JAorw%2FmolH7iVsgprBx0W1oiwEIwTVoZje1YrDPah%2FbOrqP9BpK3XKCPhaSDh3LBbrBDruK%2F1SGg0zMjzaRsR%2Bd80ZfeIrv71uxFDFaPQoMO%2BklqIGOrEBIXOcU5WqFpqOnHohJ6zsIdyW2cDKsUOjo%2BxSSRx%2FiycpoDlLhkBwgxFH7h2BC94mIgT5fufqg1OUYConhFOxIuFZ%2FGVBCn0eZWUTigGnHCc9XAetoMd8EWZ9NEK8lcUSFVVYqxlVwi4hU6%2BAf4TWxUyrYdcATxSyOXNSDY22dBaOMICi7DPZr3AwR0FkBzhF%2F0vnmv6Pq6452uYLSBB21ZNTkEm8VLVbhqlb4748z8eb&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20230423T213731Z&X-Amz-SignedHeaders=host&X-Amz-Expires=3600&X-Amz-Credential=ASIASXCYXIIFBHDLLY5C%2F20230423%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Signature=282fada8a8f7fe11292f5e74ce53f3fb2a371ba3bc21c95567bd6b7dc3bf5f4b",
"width": 100,
"height": 100
},
"SMALL": {
"url": "https://edamam-product-images.s3.amazonaws.com/web-img/b2d/b2dbd9ac524a41cae54682d3b5dc8d10-m.jpg?X-Amz-Security-Token=IQoJb3JpZ2luX2VjEOX%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FwEaCXVzLWVhc3QtMSJHMEUCIQCJQIhC4qkNQMT%2BsfZBBM6imfSCbhc00qVjzyisP5jbTQIgXMqQdGGlAXZiff%2BGvNSrIr36AHleRUl%2BGIfUD8bwygEqwgUI3f%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FARAAGgwxODcwMTcxNTA5ODYiDM3sys8nakzofhDwXiqWBccYz0YciF5X1grIj6gaZZuBtpTjI9IkWAubjd7sTVJlYoexV87XA%2FB87TzPV%2FfI2zqHVQy2GpGfkVwL3Ly1qnOQ2BpRk4flwSjo0yHTDkksTs%2BXD8v2KCAUwqUxYGaM7sPQkQC32Q060ESB%2BOBIAhD1ssM%2F5b8mCPiFQw2bgGD5m6B5lFjvhrJESgb9QibQZL8I0zmfFxsz5c5f3G2mMzKoq6lEj5mdozARyAAAJ5G0Kilhlc4g%2F11N5dtj92wp1xPXsKriknz3XtezFsj%2F0v0Tq0ExabUWLJ8f1C8e%2B8c21ncWf5U1cAIfgBQ9PmOEdduFwfXIdZssJ%2FU%2FGb%2BHMP4QS0azQGD0yXjcSjunbuguH%2Bea0E3C2lFcbVgtG%2BgY7S9J5k7dCBtYgAYReml1QtxfSucUeSxSIp8giBjBj0JPr9kvpzxk6TggV%2BZCc3grqQuouJ%2FIm6AXrokvVxm7esnuj7XhmLDdPta8NlLL9o0yz1x9kWA%2Be9EvQebBY%2BhPdSOAkpdaR5M8i7LNpYwnF1QKmX2e7eIl1zxkq3DcjQqaBcpGREQV3s3u8MwXgs0z5oADHuleswS%2FMQUjZFzvoIRMr57rW7RSFCY3beAT2twX%2FpxxzwDUCMjiyGHSKoi1FSlXO6ho7jibg2P%2FOsO2u7gzUev%2B0CE5KWUPYvlCXrT%2Bd30UvGrzhpwOavbrdZ5Cnk21nv1o6CIfE0ZBeSu7ko8X07HbMZ%2ByT9kewIecODZ9I%2Ft7Df5%2B4VdvrHrqBfTBvtO4MVee16JAorw%2FmolH7iVsgprBx0W1oiwEIwTVoZje1YrDPah%2FbOrqP9BpK3XKCPhaSDh3LBbrBDruK%2F1SGg0zMjzaRsR%2Bd80ZfeIrv71uxFDFaPQoMO%2BklqIGOrEBIXOcU5WqFpqOnHohJ6zsIdyW2cDKsUOjo%2BxSSRx%2FiycpoDlLhkBwgxFH7h2BC94mIgT5fufqg1OUYConhFOxIuFZ%2FGVBCn0eZWUTigGnHCc9XAetoMd8EWZ9NEK8lcUSFVVYqxlVwi4hU6%2BAf4TWxUyrYdcATxSyOXNSDY22dBaOMICi7DPZr3AwR0FkBzhF%2F0vnmv6Pq6452uYLSBB21ZNTkEm8VLVbhqlb4748z8eb&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20230423T213731Z&X-Amz-SignedHeaders=host&X-Amz-Expires=3600&X-Amz-Credential=ASIASXCYXIIFBHDLLY5C%2F20230423%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Signature=c20b0775c768699c972230c688206ad866f7d9508173b8039ecb315e0d7742ea",
"width": 200,
"height": 200
},
"REGULAR": {
"url": "https://edamam-product-images.s3.amazonaws.com/web-img/b2d/b2dbd9ac524a41cae54682d3b5dc8d10.jpg?X-Amz-Security-Token=IQoJb3JpZ2luX2VjEOX%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FwEaCXVzLWVhc3QtMSJHMEUCIQCJQIhC4qkNQMT%2BsfZBBM6imfSCbhc00qVjzyisP5jbTQIgXMqQdGGlAXZiff%2BGvNSrIr36AHleRUl%2BGIfUD8bwygEqwgUI3f%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FARAAGgwxODcwMTcxNTA5ODYiDM3sys8nakzofhDwXiqWBccYz0YciF5X1grIj6gaZZuBtpTjI9IkWAubjd7sTVJlYoexV87XA%2FB87TzPV%2FfI2zqHVQy2GpGfkVwL3Ly1qnOQ2BpRk4flwSjo0yHTDkksTs%2BXD8v2KCAUwqUxYGaM7sPQkQC32Q060ESB%2BOBIAhD1ssM%2F5b8mCPiFQw2bgGD5m6B5lFjvhrJESgb9QibQZL8I0zmfFxsz5c5f3G2mMzKoq6lEj5mdozARyAAAJ5G0Kilhlc4g%2F11N5dtj92wp1xPXsKriknz3XtezFsj%2F0v0Tq0ExabUWLJ8f1C8e%2B8c21ncWf5U1cAIfgBQ9PmOEdduFwfXIdZssJ%2FU%2FGb%2BHMP4QS0azQGD0yXjcSjunbuguH%2Bea0E3C2lFcbVgtG%2BgY7S9J5k7dCBtYgAYReml1QtxfSucUeSxSIp8giBjBj0JPr9kvpzxk6TggV%2BZCc3grqQuouJ%2FIm6AXrokvVxm7esnuj7XhmLDdPta8NlLL9o0yz1x9kWA%2Be9EvQebBY%2BhPdSOAkpdaR5M8i7LNpYwnF1QKmX2e7eIl1zxkq3DcjQqaBcpGREQV3s3u8MwXgs0z5oADHuleswS%2FMQUjZFzvoIRMr57rW7RSFCY3beAT2twX%2FpxxzwDUCMjiyGHSKoi1FSlXO6ho7jibg2P%2FOsO2u7gzUev%2B0CE5KWUPYvlCXrT%2Bd30UvGrzhpwOavbrdZ5Cnk21nv1o6CIfE0ZBeSu7ko8X07HbMZ%2ByT9kewIecODZ9I%2Ft7Df5%2B4VdvrHrqBfTBvtO4MVee16JAorw%2FmolH7iVsgprBx0W1oiwEIwTVoZje1YrDPah%2FbOrqP9BpK3XKCPhaSDh3LBbrBDruK%2F1SGg0zMjzaRsR%2Bd80ZfeIrv71uxFDFaPQoMO%2BklqIGOrEBIXOcU5WqFpqOnHohJ6zsIdyW2cDKsUOjo%2BxSSRx%2FiycpoDlLhkBwgxFH7h2BC94mIgT5fufqg1OUYConhFOxIuFZ%2FGVBCn0eZWUTigGnHCc9XAetoMd8EWZ9NEK8lcUSFVVYqxlVwi4hU6%2BAf4TWxUyrYdcATxSyOXNSDY22dBaOMICi7DPZr3AwR0FkBzhF%2F0vnmv6Pq6452uYLSBB21ZNTkEm8VLVbhqlb4748z8eb&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20230423T213731Z&X-Amz-SignedHeaders=host&X-Amz-Expires=3600&X-Amz-Credential=ASIASXCYXIIFBHDLLY5C%2F20230423%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Signature=d4fcf9ca4d8fdd7e8cc5fce988ba339e7ceece8922896ee1ff09186e3ab16aff",
"width": 300,
"height": 300
},
"LARGE": {
"url": "https://edamam-product-images.s3.amazonaws.com/web-img/b2d/b2dbd9ac524a41cae54682d3b5dc8d10-l.jpg?X-Amz-Security-Token=IQoJb3JpZ2luX2VjEOX%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FwEaCXVzLWVhc3QtMSJHMEUCIQCJQIhC4qkNQMT%2BsfZBBM6imfSCbhc00qVjzyisP5jbTQIgXMqQdGGlAXZiff%2BGvNSrIr36AHleRUl%2BGIfUD8bwygEqwgUI3f%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FARAAGgwxODcwMTcxNTA5ODYiDM3sys8nakzofhDwXiqWBccYz0YciF5X1grIj6gaZZuBtpTjI9IkWAubjd7sTVJlYoexV87XA%2FB87TzPV%2FfI2zqHVQy2GpGfkVwL3Ly1qnOQ2BpRk4flwSjo0yHTDkksTs%2BXD8v2KCAUwqUxYGaM7sPQkQC32Q060ESB%2BOBIAhD1ssM%2F5b8mCPiFQw2bgGD5m6B5lFjvhrJESgb9QibQZL8I0zmfFxsz5c5f3G2mMzKoq6lEj5mdozARyAAAJ5G0Kilhlc4g%2F11N5dtj92wp1xPXsKriknz3XtezFsj%2F0v0Tq0ExabUWLJ8f1C8e%2B8c21ncWf5U1cAIfgBQ9PmOEdduFwfXIdZssJ%2FU%2FGb%2BHMP4QS0azQGD0yXjcSjunbuguH%2Bea0E3C2lFcbVgtG%2BgY7S9J5k7dCBtYgAYReml1QtxfSucUeSxSIp8giBjBj0JPr9kvpzxk6TggV%2BZCc3grqQuouJ%2FIm6AXrokvVxm7esnuj7XhmLDdPta8NlLL9o0yz1x9kWA%2Be9EvQebBY%2BhPdSOAkpdaR5M8i7LNpYwnF1QKmX2e7eIl1zxkq3DcjQqaBcpGREQV3s3u8MwXgs0z5oADHuleswS%2FMQUjZFzvoIRMr57rW7RSFCY3beAT2twX%2FpxxzwDUCMjiyGHSKoi1FSlXO6ho7jibg2P%2FOsO2u7gzUev%2B0CE5KWUPYvlCXrT%2Bd30UvGrzhpwOavbrdZ5Cnk21nv1o6CIfE0ZBeSu7ko8X07HbMZ%2ByT9kewIecODZ9I%2Ft7Df5%2B4VdvrHrqBfTBvtO4MVee16JAorw%2FmolH7iVsgprBx0W1oiwEIwTVoZje1YrDPah%2FbOrqP9BpK3XKCPhaSDh3LBbrBDruK%2F1SGg0zMjzaRsR%2Bd80ZfeIrv71uxFDFaPQoMO%2BklqIGOrEBIXOcU5WqFpqOnHohJ6zsIdyW2cDKsUOjo%2BxSSRx%2FiycpoDlLhkBwgxFH7h2BC94mIgT5fufqg1OUYConhFOxIuFZ%2FGVBCn0eZWUTigGnHCc9XAetoMd8EWZ9NEK8lcUSFVVYqxlVwi4hU6%2BAf4TWxUyrYdcATxSyOXNSDY22dBaOMICi7DPZr3AwR0FkBzhF%2F0vnmv6Pq6452uYLSBB21ZNTkEm8VLVbhqlb4748z8eb&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20230423T213731Z&X-Amz-SignedHeaders=host&X-Amz-Expires=3600&X-Amz-Credential=ASIASXCYXIIFBHDLLY5C%2F20230423%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Signature=6557b5ff6fb9218a74cabf52aac85dc227f2198d4565d15a7ea05cd3e2adb021",
"width": 600,
"height": 600
}
},
"source": "No Recipes",
"url": "http://norecipes.com/blog/2008/04/26/maple-banana-frozen-yogurt/",
"shareAs": "http://www.edamam.com/recipe/maple-banana-frozen-yogurt-067f0b7be628ae847366e4f3e614b319/-",
"yield": 4,
"dietLabels": [
"Balanced",
"Low-Sodium"
],
"healthLabels": [
"Vegetarian",
"Pescatarian",
"Mediterranean",
"Gluten-Free",
"Wheat-Free",
"Egg-Free",
"Peanut-Free",
"Tree-Nut-Free",
"Soy-Free",
"Fish-Free",
"Shellfish-Free",
"Pork-Free",
"Red-Meat-Free",
"Crustacean-Free",
"Celery-Free",
"Mustard-Free",
"Sesame-Free",
"Lupine-Free",
"Mollusk-Free",
"Alcohol-Free",
"No oil added",
"Sulfite-Free",
"Kosher"
],
"cautions": [
"Sulfites"
],
"ingredientLines": [
"2 rice bananas",
"16 oz maple yogurt (I use Brown Cow Cream Top)",
"1 tsp vanilla"
],
"ingredients": [
{
"text": "2 rice bananas",
"quantity": 2,
"measure": "<unit>",
"food": "bananas",
"weight": 231.4,
"foodCategory": "fruit",
"foodId": "food_bjsfxtcaidvmhaa3afrbna43q3hu",
"image": "https://www.edamam.com/food-img/9f6/9f6181163a25c96022ee3fc66d9ebb11.jpg"
},
{
"text": "16 oz maple yogurt (I use Brown Cow Cream Top)",
"quantity": 16,
"measure": "ounce",
"food": "yogurt",
"weight": 453.59237,
"foodCategory": "yogurt",
"foodId": "food_a79ojfkbgdeekgblqmky9bunr8f6",
"image": "https://www.edamam.com/food-img/933/933eb3791b3a2175e007f1607d56b7e2.jpg"
},
{
"text": "1 tsp vanilla",
"quantity": 1,
"measure": "teaspoon",
"food": "vanilla",
"weight": 4.2,
"foodCategory": "Condiments and sauces",
"foodId": "food_bh1wvnqaw3q7ciascfoygaabax2a",
"image": "https://www.edamam.com/food-img/90f/90f910b0bf82750d4f6528263e014cca.jpg"
}
],
"calories": 494.7333457000001,
"totalWeight": 689.1923700000001,
"totalTime": 0,
"cuisineType": [
"american"
],
"mealType": [
"lunch/dinner"
],
"dishType": [
"desserts"
],
"totalNutrients": {
"ENERC_KCAL": {
"label": "Energy",
"quantity": 494.7333457000001,
"unit": "kcal"
},
"FAT": {
"label": "Fat",
"quantity": 15.507892025000002,
"unit": "g"
},
"FASAT": {
"label": "Saturated",
"quantity": 9.766884075200002,
"unit": "g"
},
"FATRN": {
"label": "Trans",
"quantity": 0,
"unit": "g"
},
"FAMS": {
"label": "Monounsaturated",
"quantity": 4.125047864100001,
"unit": "g"
},
"FAPU": {
"label": "Polyunsaturated",
"quantity": 0.5863949803999999,
"unit": "g"
},
"CHOCDF": {
"label": "Carbs",
"quantity": 74.520464442,
"unit": "g"
},
"CHOCDF.net": {
"label": "Carbohydrates (net)",
"quantity": 68.504064442,
"unit": "g"
},
"FIBTG": {
"label": "Fiber",
"quantity": 6.0164,
"unit": "g"
},
"SUGAR": {
"label": "Sugars",
"quantity": 49.96892444200001,
"unit": "g"
},
"SUGAR.added": {
"label": "Sugars, added",
"quantity": 0,
"unit": "g"
},
"PROCNT": {
"label": "Protein",
"quantity": 18.264435239000004,
"unit": "g"
},
"CHOLE": {
"label": "Cholesterol",
"quantity": 58.96700810000001,
"unit": "mg"
},
"NA": {
"label": "Sodium",
"quantity": 211.3444902,
"unit": "mg"
},
"CA": {
"label": "Calcium",
"quantity": 560.8787677000001,
"unit": "mg"
},
"MG": {
"label": "Magnesium",
"quantity": 117.41308440000002,
"unit": "mg"
},
"K": {
"label": "Potassium",
"quantity": 1537.6961735,
"unit": "mg"
},
"FE": {
"label": "Iron",
"quantity": 0.8334761850000002,
"unit": "mg"
},
"ZN": {
"label": "Zinc",
"quantity": 3.0279149830000005,
"unit": "mg"
},
"P": {
"label": "Phosphorus",
"quantity": 482.0727515000001,
"unit": "mg"
},
"VITA_RAE": {
"label": "Vitamin A",
"quantity": 129.41193990000002,
"unit": "µg"
},
"VITC": {
"label": "Vitamin C",
"quantity": 22.399761849999997,
"unit": "mg"
},
"THIA": {
"label": "Thiamin (B1)",
"quantity": 0.2037377873,
"unit": "mg"
},
"RIBF": {
"label": "Riboflavin (B2)",
"quantity": 0.8170131654000001,
"unit": "mg"
},
"NIA": {
"label": "Niacin (B3)",
"quantity": 1.8968542775,
"unit": "mg"
},
"VITB6A": {
"label": "Vitamin B6",
"quantity": 0.9954795584,
"unit": "mg"
},
"FOLDFE": {
"label": "Folate equivalent (total)",
"quantity": 78.0314659,
"unit": "µg"
},
"FOLFD": {
"label": "Folate (food)",
"quantity": 78.0314659,
"unit": "µg"
},
"FOLAC": {
"label": "Folic acid",
"quantity": 0,
"unit": "µg"
},
"VITB12": {
"label": "Vitamin B12",
"quantity": 1.678291769,
"unit": "µg"
},
"VITD": {
"label": "Vitamin D",
"quantity": 0.4535923700000001,
"unit": "µg"
},
"TOCPHA": {
"label": "Vitamin E",
"quantity": 0.503555422,
"unit": "mg"
},
"VITK1": {
"label": "Vitamin K",
"quantity": 2.06418474,
"unit": "µg"
},
"Sugar.alcohol": {
"label": "Sugar alcohol",
"quantity": 0,
"unit": "g"
},
"WATER": {
"label": "Water",
"quantity": 574.2577932300001,
"unit": "g"
}
},
"totalDaily": {
"ENERC_KCAL": {
"label": "Energy",
"quantity": 24.736667285000003,
"unit": "%"
},
"FAT": {
"label": "Fat",
"quantity": 23.858295423076925,
"unit": "%"
},
"FASAT": {
"label": "Saturated",
"quantity": 48.83442037600001,
"unit": "%"
},
"CHOCDF": {
"label": "Carbs",
"quantity": 24.840154814,
"unit": "%"
},
"FIBTG": {
"label": "Fiber",
"quantity": 24.0656,
"unit": "%"
},
"PROCNT": {
"label": "Protein",
"quantity": 36.52887047800001,
"unit": "%"
},
"CHOLE": {
"label": "Cholesterol",
"quantity": 19.65566936666667,
"unit": "%"
},
"NA": {
"label": "Sodium",
"quantity": 8.806020425,
"unit": "%"
},
"CA": {
"label": "Calcium",
"quantity": 56.087876770000015,
"unit": "%"
},
"MG": {
"label": "Magnesium",
"quantity": 27.955496285714293,
"unit": "%"
},
"K": {
"label": "Potassium",
"quantity": 32.71693986170212,
"unit": "%"
},
"FE": {
"label": "Iron",
"quantity": 4.6304232500000015,
"unit": "%"
},
"ZN": {
"label": "Zinc",
"quantity": 27.526499845454552,
"unit": "%"
},
"P": {
"label": "Phosphorus",
"quantity": 68.86753592857144,
"unit": "%"
},
"VITA_RAE": {
"label": "Vitamin A",
"quantity": 14.379104433333335,
"unit": "%"
},
"VITC": {
"label": "Vitamin C",
"quantity": 24.888624277777772,
"unit": "%"
},
"THIA": {
"label": "Thiamin (B1)",
"quantity": 16.978148941666667,
"unit": "%"
},
"RIBF": {
"label": "Riboflavin (B2)",
"quantity": 62.84716656923077,
"unit": "%"
},
"NIA": {
"label": "Niacin (B3)",
"quantity": 11.855339234375,
"unit": "%"
},
"VITB6A": {
"label": "Vitamin B6",
"quantity": 76.57535064615385,
"unit": "%"
},
"FOLDFE": {
"label": "Folate equivalent (total)",
"quantity": 19.507866475,
"unit": "%"
},
"VITB12": {
"label": "Vitamin B12",
"quantity": 69.92882370833334,
"unit": "%"
},
"VITD": {
"label": "Vitamin D",
"quantity": 3.0239491333333337,
"unit": "%"
},
"TOCPHA": {
"label": "Vitamin E",
"quantity": 3.3570361466666667,
"unit": "%"
},
"VITK1": {
"label": "Vitamin K",
"quantity": 1.72015395,
"unit": "%"
}
},
"digest": [
{
"label": "Fat",
"tag": "FAT",
"schemaOrgTag": "fatContent",
"total": 15.507892025000002,
"hasRDI": true,
"daily": 23.858295423076925,
"unit": "g",
"sub": [
{
"label": "Saturated",
"tag": "FASAT",
"schemaOrgTag": "saturatedFatContent",
"total": 9.766884075200002,
"hasRDI": true,
"daily": 48.83442037600001,
"unit": "g"
},
{
"label": "Trans",
"tag": "FATRN",
"schemaOrgTag": "transFatContent",
"total": 0,
"hasRDI": false,
"daily": 0,
"unit": "g"
},
{
"label": "Monounsaturated",
"tag": "FAMS",
"schemaOrgTag": null,
"total": 4.125047864100001,
"hasRDI": false,
"daily": 0,
"unit": "g"
},
{
"label": "Polyunsaturated",
"tag": "FAPU",
"schemaOrgTag": null,
"total": 0.5863949803999999,
"hasRDI": false,
"daily": 0,
"unit": "g"
}
]
},
{
"label": "Carbs",
"tag": "CHOCDF",
"schemaOrgTag": "carbohydrateContent",
"total": 74.520464442,
"hasRDI": true,
"daily": 24.840154814,
"unit": "g",
"sub": [
{
"label": "Carbs (net)",
"tag": "CHOCDF.net",
"schemaOrgTag": null,
"total": 68.504064442,
"hasRDI": false,
"daily": 0,
"unit": "g"
},
{
"label": "Fiber",
"tag": "FIBTG",
"schemaOrgTag": "fiberContent",
"total": 6.0164,
"hasRDI": true,
"daily": 24.0656,
"unit": "g"
},
{
"label": "Sugars",
"tag": "SUGAR",
"schemaOrgTag": "sugarContent",
"total": 49.96892444200001,
"hasRDI": false,
"daily": 0,
"unit": "g"
},
{
"label": "Sugars, added",
"tag": "SUGAR.added",
"schemaOrgTag": null,
"total": 0,
"hasRDI": false,
"daily": 0,
"unit": "g"
}
]
},
{
"label": "Protein",
"tag": "PROCNT",
"schemaOrgTag": "proteinContent",
"total": 18.264435239000004,
"hasRDI": true,
"daily": 36.52887047800001,
"unit": "g"
},
{
"label": "Cholesterol",
"tag": "CHOLE",
"schemaOrgTag": "cholesterolContent",
"total": 58.96700810000001,
"hasRDI": true,
"daily": 19.65566936666667,
"unit": "mg"
},
{
"label": "Sodium",
"tag": "NA",
"schemaOrgTag": "sodiumContent",
"total": 211.3444902,
"hasRDI": true,
"daily": 8.806020425,
"unit": "mg"
},
{
"label": "Calcium",
"tag": "CA",
"schemaOrgTag": null,
"total": 560.8787677000001,
"hasRDI": true,
"daily": 56.087876770000015,
"unit": "mg"
},
{
"label": "Magnesium",
"tag": "MG",
"schemaOrgTag": null,
"total": 117.41308440000002,
"hasRDI": true,
"daily": 27.955496285714293,
"unit": "mg"
},
{
"label": "Potassium",
"tag": "K",
"schemaOrgTag": null,
"total": 1537.6961735,
"hasRDI": true,
"daily": 32.71693986170212,
"unit": "mg"
},
{
"label": "Iron",
"tag": "FE",
"schemaOrgTag": null,
"total": 0.8334761850000002,
"hasRDI": true,
"daily": 4.6304232500000015,
"unit": "mg"
},
{
"label": "Zinc",
"tag": "ZN",
"schemaOrgTag": null,
"total": 3.0279149830000005,
"hasRDI": true,
"daily": 27.526499845454552,
"unit": "mg"
},
{
"label": "Phosphorus",
"tag": "P",
"schemaOrgTag": null,
"total": 482.0727515000001,
"hasRDI": true,
"daily": 68.86753592857144,
"unit": "mg"
},
{
"label": "Vitamin A",
"tag": "VITA_RAE",
"schemaOrgTag": null,
"total": 129.41193990000002,
"hasRDI": true,
"daily": 14.379104433333335,
"unit": "µg"
},
{
"label": "Vitamin C",
"tag": "VITC",
"schemaOrgTag": null,
"total": 22.399761849999997,
"hasRDI": true,
"daily": 24.888624277777772,
"unit": "mg"
},
{
"label": "Thiamin (B1)",
"tag": "THIA",
"schemaOrgTag": null,
"total": 0.2037377873,
"hasRDI": true,
"daily": 16.978148941666667,
"unit": "mg"
},
{
"label": "Riboflavin (B2)",
"tag": "RIBF",
"schemaOrgTag": null,
"total": 0.8170131654000001,
"hasRDI": true,
"daily": 62.84716656923077,
"unit": "mg"
},
{
"label": "Niacin (B3)",
"tag": "NIA",
"schemaOrgTag": null,
"total": 1.8968542775,
"hasRDI": true,
"daily": 11.855339234375,
"unit": "mg"
},
{
"label": "Vitamin B6",
"tag": "VITB6A",
"schemaOrgTag": null,
"total": 0.9954795584,
"hasRDI": true,
"daily": 76.57535064615385,
"unit": "mg"
},
{
"label": "Folate equivalent (total)",
"tag": "FOLDFE",
"schemaOrgTag": null,
"total": 78.0314659,
"hasRDI": true,
"daily": 19.507866475,
"unit": "µg"
},
{
"label": "Folate (food)",
"tag": "FOLFD",
"schemaOrgTag": null,
"total": 78.0314659,
"hasRDI": false,
"daily": 0,
"unit": "µg"
},
{
"label": "Folic acid",
"tag": "FOLAC",
"schemaOrgTag": null,
"total": 0,
"hasRDI": false,
"daily": 0,
"unit": "µg"
},
{
"label": "Vitamin B12",
"tag": "VITB12",
"schemaOrgTag": null,
"total": 1.678291769,
"hasRDI": true,
"daily": 69.92882370833334,
"unit": "µg"
},
{
"label": "Vitamin D",
"tag": "VITD",
"schemaOrgTag": null,
"total": 0.4535923700000001,
"hasRDI": true,
"daily": 3.0239491333333337,
"unit": "µg"
},
{
"label": "Vitamin E",
"tag": "TOCPHA",
"schemaOrgTag": null,
"total": 0.503555422,
"hasRDI": true,
"daily": 3.3570361466666667,
"unit": "mg"
},
{
"label": "Vitamin K",
"tag": "VITK1",
"schemaOrgTag": null,
"total": 2.06418474,
"hasRDI": true,
"daily": 1.72015395,
"unit": "µg"
},
{
"label": "Sugar alcohols",
"tag": "Sugar.alcohol",
"schemaOrgTag": null,
"total": 0,
"hasRDI": false,
"daily": 0,
"unit": "g"
},
{
"label": "Water",
"tag": "WATER",
"schemaOrgTag": null,
"total": 574.2577932300001,
"hasRDI": false,
"daily": 0,
"unit": "g"
}
]
},
"_links": {
"self": {
"title": "Self",
"href": "https://api.edamam.com/api/recipes/v2/067f0b7be628ae847366e4f3e614b319?type=public&app_id=19c82497&app_key=f7ce5672f67e97572eed94fb0984eeda"
}
}
},
{
"recipe": {
"uri": "http://www.edamam.com/ontologies/edamam.owl#recipe_845a9adf81bb22f3b76ead2981a872a0",
"label": "Vanilla Ice Cream With Grilled Corn And Lime",
"image": "https://edamam-product-images.s3.amazonaws.com/web-img/270/270c9aae056587c1f176ae6eafdb4c0d.jpg?X-Amz-Security-Token=IQoJb3JpZ2luX2VjEOX%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FwEaCXVzLWVhc3QtMSJHMEUCIQCJQIhC4qkNQMT%2BsfZBBM6imfSCbhc00qVjzyisP5jbTQIgXMqQdGGlAXZiff%2BGvNSrIr36AHleRUl%2BGIfUD8bwygEqwgUI3f%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FARAAGgwxODcwMTcxNTA5ODYiDM3sys8nakzofhDwXiqWBccYz0YciF5X1grIj6gaZZuBtpTjI9IkWAubjd7sTVJlYoexV87XA%2FB87TzPV%2FfI2zqHVQy2GpGfkVwL3Ly1qnOQ2BpRk4flwSjo0yHTDkksTs%2BXD8v2KCAUwqUxYGaM7sPQkQC32Q060ESB%2BOBIAhD1ssM%2F5b8mCPiFQw2bgGD5m6B5lFjvhrJESgb9QibQZL8I0zmfFxsz5c5f3G2mMzKoq6lEj5mdozARyAAAJ5G0Kilhlc4g%2F11N5dtj92wp1xPXsKriknz3XtezFsj%2F0v0Tq0ExabUWLJ8f1C8e%2B8c21ncWf5U1cAIfgBQ9PmOEdduFwfXIdZssJ%2FU%2FGb%2BHMP4QS0azQGD0yXjcSjunbuguH%2Bea0E3C2lFcbVgtG%2BgY7S9J5k7dCBtYgAYReml1QtxfSucUeSxSIp8giBjBj0JPr9kvpzxk6TggV%2BZCc3grqQuouJ%2FIm6AXrokvVxm7esnuj7XhmLDdPta8NlLL9o0yz1x9kWA%2Be9EvQebBY%2BhPdSOAkpdaR5M8i7LNpYwnF1QKmX2e7eIl1zxkq3DcjQqaBcpGREQV3s3u8MwXgs0z5oADHuleswS%2FMQUjZFzvoIRMr57rW7RSFCY3beAT2twX%2FpxxzwDUCMjiyGHSKoi1FSlXO6ho7jibg2P%2FOsO2u7gzUev%2B0CE5KWUPYvlCXrT%2Bd30UvGrzhpwOavbrdZ5Cnk21nv1o6CIfE0ZBeSu7ko8X07HbMZ%2ByT9kewIecODZ9I%2Ft7Df5%2B4VdvrHrqBfTBvtO4MVee16JAorw%2FmolH7iVsgprBx0W1oiwEIwTVoZje1YrDPah%2FbOrqP9BpK3XKCPhaSDh3LBbrBDruK%2F1SGg0zMjzaRsR%2Bd80ZfeIrv71uxFDFaPQoMO%2BklqIGOrEBIXOcU5WqFpqOnHohJ6zsIdyW2cDKsUOjo%2BxSSRx%2FiycpoDlLhkBwgxFH7h2BC94mIgT5fufqg1OUYConhFOxIuFZ%2FGVBCn0eZWUTigGnHCc9XAetoMd8EWZ9NEK8lcUSFVVYqxlVwi4hU6%2BAf4TWxUyrYdcATxSyOXNSDY22dBaOMICi7DPZr3AwR0FkBzhF%2F0vnmv6Pq6452uYLSBB21ZNTkEm8VLVbhqlb4748z8eb&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20230423T213731Z&X-Amz-SignedHeaders=host&X-Amz-Expires=3600&X-Amz-Credential=ASIASXCYXIIFBHDLLY5C%2F20230423%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Signature=fbef19acc8354ed816771b2e3782f822b4a260b675000953aeda26ccb30c8499",
"images": {
"THUMBNAIL": {
"url": "https://edamam-product-images.s3.amazonaws.com/web-img/270/270c9aae056587c1f176ae6eafdb4c0d-s.jpg?X-Amz-Security-Token=IQoJb3JpZ2luX2VjEOX%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FwEaCXVzLWVhc3QtMSJHMEUCIQCJQIhC4qkNQMT%2BsfZBBM6imfSCbhc00qVjzyisP5jbTQIgXMqQdGGlAXZiff%2BGvNSrIr36AHleRUl%2BGIfUD8bwygEqwgUI3f%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FARAAGgwxODcwMTcxNTA5ODYiDM3sys8nakzofhDwXiqWBccYz0YciF5X1grIj6gaZZuBtpTjI9IkWAubjd7sTVJlYoexV87XA%2FB87TzPV%2FfI2zqHVQy2GpGfkVwL3Ly1qnOQ2BpRk4flwSjo0yHTDkksTs%2BXD8v2KCAUwqUxYGaM7sPQkQC32Q060ESB%2BOBIAhD1ssM%2F5b8mCPiFQw2bgGD5m6B5lFjvhrJESgb9QibQZL8I0zmfFxsz5c5f3G2mMzKoq6lEj5mdozARyAAAJ5G0Kilhlc4g%2F11N5dtj92wp1xPXsKriknz3XtezFsj%2F0v0Tq0ExabUWLJ8f1C8e%2B8c21ncWf5U1cAIfgBQ9PmOEdduFwfXIdZssJ%2FU%2FGb%2BHMP4QS0azQGD0yXjcSjunbuguH%2Bea0E3C2lFcbVgtG%2BgY7S9J5k7dCBtYgAYReml1QtxfSucUeSxSIp8giBjBj0JPr9kvpzxk6TggV%2BZCc3grqQuouJ%2FIm6AXrokvVxm7esnuj7XhmLDdPta8NlLL9o0yz1x9kWA%2Be9EvQebBY%2BhPdSOAkpdaR5M8i7LNpYwnF1QKmX2e7eIl1zxkq3DcjQqaBcpGREQV3s3u8MwXgs0z5oADHuleswS%2FMQUjZFzvoIRMr57rW7RSFCY3beAT2twX%2FpxxzwDUCMjiyGHSKoi1FSlXO6ho7jibg2P%2FOsO2u7gzUev%2B0CE5KWUPYvlCXrT%2Bd30UvGrzhpwOavbrdZ5Cnk21nv1o6CIfE0ZBeSu7ko8X07HbMZ%2ByT9kewIecODZ9I%2Ft7Df5%2B4VdvrHrqBfTBvtO4MVee16JAorw%2FmolH7iVsgprBx0W1oiwEIwTVoZje1YrDPah%2FbOrqP9BpK3XKCPhaSDh3LBbrBDruK%2F1SGg0zMjzaRsR%2Bd80ZfeIrv71uxFDFaPQoMO%2BklqIGOrEBIXOcU5WqFpqOnHohJ6zsIdyW2cDKsUOjo%2BxSSRx%2FiycpoDlLhkBwgxFH7h2BC94mIgT5fufqg1OUYConhFOxIuFZ%2FGVBCn0eZWUTigGnHCc9XAetoMd8EWZ9NEK8lcUSFVVYqxlVwi4hU6%2BAf4TWxUyrYdcATxSyOXNSDY22dBaOMICi7DPZr3AwR0FkBzhF%2F0vnmv6Pq6452uYLSBB21ZNTkEm8VLVbhqlb4748z8eb&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20230423T213731Z&X-Amz-SignedHeaders=host&X-Amz-Expires=3600&X-Amz-Credential=ASIASXCYXIIFBHDLLY5C%2F20230423%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Signature=351a8bac49e0fe9c8d2fe4f9fbee253df3dff18c1070c98b8758e23f5a5e061a",
"width": 100,
"height": 100
},
"SMALL": {
"url": "https://edamam-product-images.s3.amazonaws.com/web-img/270/270c9aae056587c1f176ae6eafdb4c0d-m.jpg?X-Amz-Security-Token=IQoJb3JpZ2luX2VjEOX%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FwEaCXVzLWVhc3QtMSJHMEUCIQCJQIhC4qkNQMT%2BsfZBBM6imfSCbhc00qVjzyisP5jbTQIgXMqQdGGlAXZiff%2BGvNSrIr36AHleRUl%2BGIfUD8bwygEqwgUI3f%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FARAAGgwxODcwMTcxNTA5ODYiDM3sys8nakzofhDwXiqWBccYz0YciF5X1grIj6gaZZuBtpTjI9IkWAubjd7sTVJlYoexV87XA%2FB87TzPV%2FfI2zqHVQy2GpGfkVwL3Ly1qnOQ2BpRk4flwSjo0yHTDkksTs%2BXD8v2KCAUwqUxYGaM7sPQkQC32Q060ESB%2BOBIAhD1ssM%2F5b8mCPiFQw2bgGD5m6B5lFjvhrJESgb9QibQZL8I0zmfFxsz5c5f3G2mMzKoq6lEj5mdozARyAAAJ5G0Kilhlc4g%2F11N5dtj92wp1xPXsKriknz3XtezFsj%2F0v0Tq0ExabUWLJ8f1C8e%2B8c21ncWf5U1cAIfgBQ9PmOEdduFwfXIdZssJ%2FU%2FGb%2BHMP4QS0azQGD0yXjcSjunbuguH%2Bea0E3C2lFcbVgtG%2BgY7S9J5k7dCBtYgAYReml1QtxfSucUeSxSIp8giBjBj0JPr9kvpzxk6TggV%2BZCc3grqQuouJ%2FIm6AXrokvVxm7esnuj7XhmLDdPta8NlLL9o0yz1x9kWA%2Be9EvQebBY%2BhPdSOAkpdaR5M8i7LNpYwnF1QKmX2e7eIl1zxkq3DcjQqaBcpGREQV3s3u8MwXgs0z5oADHuleswS%2FMQUjZFzvoIRMr57rW7RSFCY3beAT2twX%2FpxxzwDUCMjiyGHSKoi1FSlXO6ho7jibg2P%2FOsO2u7gzUev%2B0CE5KWUPYvlCXrT%2Bd30UvGrzhpwOavbrdZ5Cnk21nv1o6CIfE0ZBeSu7ko8X07HbMZ%2ByT9kewIecODZ9I%2Ft7Df5%2B4VdvrHrqBfTBvtO4MVee16JAorw%2FmolH7iVsgprBx0W1oiwEIwTVoZje1YrDPah%2FbOrqP9BpK3XKCPhaSDh3LBbrBDruK%2F1SGg0zMjzaRsR%2Bd80ZfeIrv71uxFDFaPQoMO%2BklqIGOrEBIXOcU5WqFpqOnHohJ6zsIdyW2cDKsUOjo%2BxSSRx%2FiycpoDlLhkBwgxFH7h2BC94mIgT5fufqg1OUYConhFOxIuFZ%2FGVBCn0eZWUTigGnHCc9XAetoMd8EWZ9NEK8lcUSFVVYqxlVwi4hU6%2BAf4TWxUyrYdcATxSyOXNSDY22dBaOMICi7DPZr3AwR0FkBzhF%2F0vnmv6Pq6452uYLSBB21ZNTkEm8VLVbhqlb4748z8eb&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20230423T213731Z&X-Amz-SignedHeaders=host&X-Amz-Expires=3600&X-Amz-Credential=ASIASXCYXIIFBHDLLY5C%2F20230423%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Signature=940ec22ede1387face7cc1ce6a7371b7dd49f055c61a7ebfc42a0561e7be6c2d",
"width": 200,
"height": 200
},
"REGULAR": {
"url": "https://edamam-product-images.s3.amazonaws.com/web-img/270/270c9aae056587c1f176ae6eafdb4c0d.jpg?X-Amz-Security-Token=IQoJb3JpZ2luX2VjEOX%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FwEaCXVzLWVhc3QtMSJHMEUCIQCJQIhC4qkNQMT%2BsfZBBM6imfSCbhc00qVjzyisP5jbTQIgXMqQdGGlAXZiff%2BGvNSrIr36AHleRUl%2BGIfUD8bwygEqwgUI3f%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FARAAGgwxODcwMTcxNTA5ODYiDM3sys8nakzofhDwXiqWBccYz0YciF5X1grIj6gaZZuBtpTjI9IkWAubjd7sTVJlYoexV87XA%2FB87TzPV%2FfI2zqHVQy2GpGfkVwL3Ly1qnOQ2BpRk4flwSjo0yHTDkksTs%2BXD8v2KCAUwqUxYGaM7sPQkQC32Q060ESB%2BOBIAhD1ssM%2F5b8mCPiFQw2bgGD5m6B5lFjvhrJESgb9QibQZL8I0zmfFxsz5c5f3G2mMzKoq6lEj5mdozARyAAAJ5G0Kilhlc4g%2F11N5dtj92wp1xPXsKriknz3XtezFsj%2F0v0Tq0ExabUWLJ8f1C8e%2B8c21ncWf5U1cAIfgBQ9PmOEdduFwfXIdZssJ%2FU%2FGb%2BHMP4QS0azQGD0yXjcSjunbuguH%2Bea0E3C2lFcbVgtG%2BgY7S9J5k7dCBtYgAYReml1QtxfSucUeSxSIp8giBjBj0JPr9kvpzxk6TggV%2BZCc3grqQuouJ%2FIm6AXrokvVxm7esnuj7XhmLDdPta8NlLL9o0yz1x9kWA%2Be9EvQebBY%2BhPdSOAkpdaR5M8i7LNpYwnF1QKmX2e7eIl1zxkq3DcjQqaBcpGREQV3s3u8MwXgs0z5oADHuleswS%2FMQUjZFzvoIRMr57rW7RSFCY3beAT2twX%2FpxxzwDUCMjiyGHSKoi1FSlXO6ho7jibg2P%2FOsO2u7gzUev%2B0CE5KWUPYvlCXrT%2Bd30UvGrzhpwOavbrdZ5Cnk21nv1o6CIfE0ZBeSu7ko8X07HbMZ%2ByT9kewIecODZ9I%2Ft7Df5%2B4VdvrHrqBfTBvtO4MVee16JAorw%2FmolH7iVsgprBx0W1oiwEIwTVoZje1YrDPah%2FbOrqP9BpK3XKCPhaSDh3LBbrBDruK%2F1SGg0zMjzaRsR%2Bd80ZfeIrv71uxFDFaPQoMO%2BklqIGOrEBIXOcU5WqFpqOnHohJ6zsIdyW2cDKsUOjo%2BxSSRx%2FiycpoDlLhkBwgxFH7h2BC94mIgT5fufqg1OUYConhFOxIuFZ%2FGVBCn0eZWUTigGnHCc9XAetoMd8EWZ9NEK8lcUSFVVYqxlVwi4hU6%2BAf4TWxUyrYdcATxSyOXNSDY22dBaOMICi7DPZr3AwR0FkBzhF%2F0vnmv6Pq6452uYLSBB21ZNTkEm8VLVbhqlb4748z8eb&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20230423T213731Z&X-Amz-SignedHeaders=host&X-Amz-Expires=3600&X-Amz-Credential=ASIASXCYXIIFBHDLLY5C%2F20230423%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Signature=fbef19acc8354ed816771b2e3782f822b4a260b675000953aeda26ccb30c8499",
"width": 300,
"height": 300
},
"LARGE": {
"url": "https://edamam-product-images.s3.amazonaws.com/web-img/270/270c9aae056587c1f176ae6eafdb4c0d-l.jpg?X-Amz-Security-Token=IQoJb3JpZ2luX2VjEOX%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FwEaCXVzLWVhc3QtMSJHMEUCIQCJQIhC4qkNQMT%2BsfZBBM6imfSCbhc00qVjzyisP5jbTQIgXMqQdGGlAXZiff%2BGvNSrIr36AHleRUl%2BGIfUD8bwygEqwgUI3f%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FARAAGgwxODcwMTcxNTA5ODYiDM3sys8nakzofhDwXiqWBccYz0YciF5X1grIj6gaZZuBtpTjI9IkWAubjd7sTVJlYoexV87XA%2FB87TzPV%2FfI2zqHVQy2GpGfkVwL3Ly1qnOQ2BpRk4flwSjo0yHTDkksTs%2BXD8v2KCAUwqUxYGaM7sPQkQC32Q060ESB%2BOBIAhD1ssM%2F5b8mCPiFQw2bgGD5m6B5lFjvhrJESgb9QibQZL8I0zmfFxsz5c5f3G2mMzKoq6lEj5mdozARyAAAJ5G0Kilhlc4g%2F11N5dtj92wp1xPXsKriknz3XtezFsj%2F0v0Tq0ExabUWLJ8f1C8e%2B8c21ncWf5U1cAIfgBQ9PmOEdduFwfXIdZssJ%2FU%2FGb%2BHMP4QS0azQGD0yXjcSjunbuguH%2Bea0E3C2lFcbVgtG%2BgY7S9J5k7dCBtYgAYReml1QtxfSucUeSxSIp8giBjBj0JPr9kvpzxk6TggV%2BZCc3grqQuouJ%2FIm6AXrokvVxm7esnuj7XhmLDdPta8NlLL9o0yz1x9kWA%2Be9EvQebBY%2BhPdSOAkpdaR5M8i7LNpYwnF1QKmX2e7eIl1zxkq3DcjQqaBcpGREQV3s3u8MwXgs0z5oADHuleswS%2FMQUjZFzvoIRMr57rW7RSFCY3beAT2twX%2FpxxzwDUCMjiyGHSKoi1FSlXO6ho7jibg2P%2FOsO2u7gzUev%2B0CE5KWUPYvlCXrT%2Bd30UvGrzhpwOavbrdZ5Cnk21nv1o6CIfE0ZBeSu7ko8X07HbMZ%2ByT9kewIecODZ9I%2Ft7Df5%2B4VdvrHrqBfTBvtO4MVee16JAorw%2FmolH7iVsgprBx0W1oiwEIwTVoZje1YrDPah%2FbOrqP9BpK3XKCPhaSDh3LBbrBDruK%2F1SGg0zMjzaRsR%2Bd80ZfeIrv71uxFDFaPQoMO%2BklqIGOrEBIXOcU5WqFpqOnHohJ6zsIdyW2cDKsUOjo%2BxSSRx%2FiycpoDlLhkBwgxFH7h2BC94mIgT5fufqg1OUYConhFOxIuFZ%2FGVBCn0eZWUTigGnHCc9XAetoMd8EWZ9NEK8lcUSFVVYqxlVwi4hU6%2BAf4TWxUyrYdcATxSyOXNSDY22dBaOMICi7DPZr3AwR0FkBzhF%2F0vnmv6Pq6452uYLSBB21ZNTkEm8VLVbhqlb4748z8eb&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20230423T213731Z&X-Amz-SignedHeaders=host&X-Amz-Expires=3600&X-Amz-Credential=ASIASXCYXIIFBHDLLY5C%2F20230423%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Signature=d4a2df8cac4fc198ac3598919ee4131df6800509102b54b6994e5e85c1e00155",
"width": 600,
"height": 600
}
},
"source": "Ruhlman",
"url": "http://ruhlman.com/2011/07/how-to-grill-corn/",
"shareAs": "http://www.edamam.com/recipe/vanilla-ice-cream-with-grilled-corn-and-lime-845a9adf81bb22f3b76ead2981a872a0/-",
"yield": 2,
"dietLabels": [
"Balanced",
"Low-Sodium"
],
"healthLabels": [
"Vegetarian",
"Pescatarian",
"Gluten-Free",
"Wheat-Free",
"Egg-Free",
"Peanut-Free",
"Tree-Nut-Free",
"Soy-Free",
"Fish-Free",
"Shellfish-Free",
"Pork-Free",
"Red-Meat-Free",
"Crustacean-Free",
"Celery-Free",
"Mustard-Free",
"Sesame-Free",
"Lupine-Free",
"Mollusk-Free",
"Alcohol-Free",
"Sulfite-Free",
"Kosher"
],
"cautions": [
"Sulfites"
],
"ingredientLines": [
"Good vanilla ice cream (about 1/2 cup per person, or as you wish)",
"Grilled corn (1/2 ear per person)",
"1 lime (for every four servings)"
],
"ingredients": [
{
"text": "Good vanilla ice cream (about 1/2 cup per person, or as you wish)",
"quantity": 0.5,
"measure": "cup",
"food": "vanilla ice cream",
"weight": 66,
"foodCategory": "frozen treats",
"foodId": "food_bsg87una16tr8waipd66na9drm1k",
"image": "https://www.edamam.com/food-img/1be/1be43587dc55730fc761aedf4f3df090.jpg"
},
{
"text": "Grilled corn (1/2 ear per person)",
"quantity": 2,
"measure": "ear",
"food": "corn",
"weight": 204,
"foodCategory": "vegetables",
"foodId": "food_b4wvre6b14mmkpaa22d8ybup8q51",
"image": "https://www.edamam.com/food-img/eb5/eb5e11afb9f697720b2de2e0e0e27d8d.jpg"
},
{
"text": "1 lime (for every four servings)",
"quantity": 1,
"measure": "<unit>",
"food": "lime",
"weight": 67,
"foodCategory": "fruit",
"foodId": "food_av58muyb8kg92fbk0g8g8aui5knv",
"image": "https://www.edamam.com/food-img/48a/48a123c9576647c4ada6a41df5eeb22a.jpg"
}
],
"calories": 332.16,
"totalWeight": 337,
"totalTime": 0,
"cuisineType": [
"american"
],
"mealType": [
"lunch/dinner"
],
"dishType": [
"desserts"
],
"totalNutrients": {
"ENERC_KCAL": {
"label": "Energy",
"quantity": 332.16,
"unit": "kcal"
},
"FAT": {
"label": "Fat",
"quantity": 10.148000000000001,
"unit": "g"
},
"FASAT": {
"label": "Saturated",
"quantity": 5.15914,
"unit": "g"
},
"FATRN": {
"label": "Trans",
"quantity": 0.014280000000000001,
"unit": "g"
},
"FAMS": {
"label": "Monounsaturated",
"quantity": 2.85355,
"unit": "g"
},
"FAPU": {
"label": "Polyunsaturated",
"quantity": 1.32865,
"unit": "g"
},
"CHOCDF": {
"label": "Carbs",
"quantity": 60.785799999999995,
"unit": "g"
},
"CHOCDF.net": {
"label": "Carbohydrates (net)",
"quantity": 54.367799999999995,
"unit": "g"
},
"FIBTG": {
"label": "Fiber",
"quantity": 6.417999999999999,
"unit": "g"
},
"SUGAR": {
"label": "Sugars",
"quantity": 27.9079,
"unit": "g"
},
"SUGAR.added": {
"label": "Sugars, added",
"quantity": 14.0052,
"unit": "g"
},
"PROCNT": {
"label": "Protein",
"quantity": 9.4498,
"unit": "g"
},
"CHOLE": {
"label": "Cholesterol",
"quantity": 29.040000000000003,
"unit": "mg"
},
"NA": {
"label": "Sodium",
"quantity": 84.74000000000001,
"unit": "mg"
},
"CA": {
"label": "Calcium",
"quantity": 110.67,
"unit": "mg"
},
"MG": {
"label": "Magnesium",
"quantity": 88.74,
"unit": "mg"
},
"K": {
"label": "Potassium",
"quantity": 750.48,
"unit": "mg"
},
"FE": {
"label": "Iron",
"quantity": 1.5221999999999998,
"unit": "mg"
},
"ZN": {
"label": "Zinc",
"quantity": 1.4675,
"unit": "mg"
},
"P": {
"label": "Phosphorus",
"quantity": 262.92,
"unit": "mg"
},
"VITA_RAE": {
"label": "Vitamin A",
"quantity": 97.58000000000001,
"unit": "µg"
},
"VITC": {
"label": "Vitamin C",
"quantity": 33.765,
"unit": "mg"
},
"THIA": {
"label": "Thiamin (B1)",
"quantity": 0.36336,
"unit": "mg"
},
"RIBF": {
"label": "Riboflavin (B2)",
"quantity": 0.28400000000000003,
"unit": "mg"
},
"NIA": {
"label": "Niacin (B3)",
"quantity": 3.8213600000000003,
"unit": "mg"
},
"VITB6A": {
"label": "Vitamin B6",
"quantity": 0.25021,
"unit": "mg"
},
"FOLDFE": {
"label": "Folate equivalent (total)",
"quantity": 94.34,
"unit": "µg"
},
"FOLFD": {
"label": "Folate (food)",
"quantity": 94.34,
"unit": "µg"
},
"FOLAC": {
"label": "Folic acid",
"quantity": 0,
"unit": "µg"
},
"VITB12": {
"label": "Vitamin B12",
"quantity": 0.2574,
"unit": "µg"
},
"VITD": {
"label": "Vitamin D",
"quantity": 0.132,
"unit": "µg"
},
"TOCPHA": {
"label": "Vitamin E",
"quantity": 0.48819999999999997,
"unit": "mg"
},
"VITK1": {
"label": "Vitamin K",
"quantity": 1.2120000000000002,
"unit": "µg"
},
"Sugar.alcohol": {
"label": "Sugar alcohol",
"quantity": 0,
"unit": "g"
},
"WATER": {
"label": "Water",
"quantity": 254.5362,
"unit": "g"
}
},
"totalDaily": {
"ENERC_KCAL": {
"label": "Energy",
"quantity": 16.608,
"unit": "%"
},
"FAT": {
"label": "Fat",
"quantity": 15.612307692307695,
"unit": "%"
},
"FASAT": {
"label": "Saturated",
"quantity": 25.7957,
"unit": "%"
},
"CHOCDF": {
"label": "Carbs",
"quantity": 20.26193333333333,
"unit": "%"
},
"FIBTG": {
"label": "Fiber",
"quantity": 25.671999999999997,
"unit": "%"
},
"PROCNT": {
"label": "Protein",
"quantity": 18.8996,
"unit": "%"
},
"CHOLE": {
"label": "Cholesterol",
"quantity": 9.680000000000001,
"unit": "%"
},
"NA": {
"label": "Sodium",
"quantity": 3.5308333333333333,
"unit": "%"
},
"CA": {
"label": "Calcium",
"quantity": 11.067,
"unit": "%"
},
"MG": {
"label": "Magnesium",
"quantity": 21.12857142857143,
"unit": "%"
},
"K": {
"label": "Potassium",
"quantity": 15.967659574468085,
"unit": "%"
},
"FE": {
"label": "Iron",
"quantity": 8.456666666666665,
"unit": "%"
},
"ZN": {
"label": "Zinc",
"quantity": 13.340909090909092,
"unit": "%"
},
"P": {
"label": "Phosphorus",
"quantity": 37.56,
"unit": "%"
},
"VITA_RAE": {
"label": "Vitamin A",
"quantity": 10.842222222222224,
"unit": "%"
},
"VITC": {
"label": "Vitamin C",
"quantity": 37.516666666666666,
"unit": "%"
},
"THIA": {
"label": "Thiamin (B1)",
"quantity": 30.28,
"unit": "%"
},
"RIBF": {
"label": "Riboflavin (B2)",
"quantity": 21.846153846153847,
"unit": "%"
},
"NIA": {
"label": "Niacin (B3)",
"quantity": 23.8835,
"unit": "%"
},
"VITB6A": {
"label": "Vitamin B6",
"quantity": 19.246923076923075,
"unit": "%"
},
"FOLDFE": {
"label": "Folate equivalent (total)",
"quantity": 23.585,
"unit": "%"
},
"VITB12": {
"label": "Vitamin B12",
"quantity": 10.725000000000001,
"unit": "%"
},
"VITD": {
"label": "Vitamin D",
"quantity": 0.8800000000000001,
"unit": "%"
},
"TOCPHA": {
"label": "Vitamin E",
"quantity": 3.254666666666666,
"unit": "%"
},
"VITK1": {
"label": "Vitamin K",
"quantity": 1.0100000000000002,
"unit": "%"
}
},
"digest": [
{
"label": "Fat",
"tag": "FAT",
"schemaOrgTag": "fatContent",
"total": 10.148000000000001,
"hasRDI": true,
"daily": 15.612307692307695,
"unit": "g",
"sub": [
{
"label": "Saturated",
"tag": "FASAT",
"schemaOrgTag": "saturatedFatContent",
"total": 5.15914,
"hasRDI": true,
"daily": 25.7957,
"unit": "g"
},
{
"label": "Trans",
"tag": "FATRN",
"schemaOrgTag": "transFatContent",
"total": 0.014280000000000001,
"hasRDI": false,
"daily": 0,
"unit": "g"
},
{
"label": "Monounsaturated",
"tag": "FAMS",
"schemaOrgTag": null,
"total": 2.85355,
"hasRDI": false,
"daily": 0,
"unit": "g"
},
{
"label": "Polyunsaturated",
"tag": "FAPU",
"schemaOrgTag": null,
"total": 1.32865,
"hasRDI": false,
"daily": 0,
"unit": "g"
}
]
},
{
"label": "Carbs",
"tag": "CHOCDF",
"schemaOrgTag": "carbohydrateContent",
"total": 60.785799999999995,
"hasRDI": true,
"daily": 20.26193333333333,
"unit": "g",
"sub": [
{
"label": "Carbs (net)",
"tag": "CHOCDF.net",
"schemaOrgTag": null,
"total": 54.367799999999995,
"hasRDI": false,
"daily": 0,
"unit": "g"
},
{
"label": "Fiber",
"tag": "FIBTG",
"schemaOrgTag": "fiberContent",
"total": 6.417999999999999,
"hasRDI": true,
"daily": 25.671999999999997,
"unit": "g"
},
{
"label": "Sugars",
"tag": "SUGAR",
"schemaOrgTag": "sugarContent",
"total": 27.9079,
"hasRDI": false,
"daily": 0,
"unit": "g"
},
{
"label": "Sugars, added",
"tag": "SUGAR.added",
"schemaOrgTag": null,
"total": 14.0052,
"hasRDI": false,
"daily": 0,
"unit": "g"
}
]
},
{
"label": "Protein",
"tag": "PROCNT",
"schemaOrgTag": "proteinContent",
"total": 9.4498,
"hasRDI": true,
"daily": 18.8996,
"unit": "g"
},
{
"label": "Cholesterol",
"tag": "CHOLE",
"schemaOrgTag": "cholesterolContent",
"total": 29.040000000000003,
"hasRDI": true,
"daily": 9.680000000000001,
"unit": "mg"
},
{
"label": "Sodium",
"tag": "NA",
"schemaOrgTag": "sodiumContent",
"total": 84.74000000000001,
"hasRDI": true,
"daily": 3.5308333333333333,
"unit": "mg"
},
{
"label": "Calcium",
"tag": "CA",
"schemaOrgTag": null,
"total": 110.67,
"hasRDI": true,
"daily": 11.067,
"unit": "mg"
},
{
"label": "Magnesium",
"tag": "MG",
"schemaOrgTag": null,
"total": 88.74,
"hasRDI": true,
"daily": 21.12857142857143,
"unit": "mg"
},
{
"label": "Potassium",
"tag": "K",
"schemaOrgTag": null,
"total": 750.48,
"hasRDI": true,
"daily": 15.967659574468085,
"unit": "mg"
},
{
"label": "Iron",
"tag": "FE",
"schemaOrgTag": null,
"total": 1.5221999999999998,
"hasRDI": true,
"daily": 8.456666666666665,
"unit": "mg"
},
{
"label": "Zinc",
"tag": "ZN",
"schemaOrgTag": null,
"total": 1.4675,
"hasRDI": true,
"daily": 13.340909090909092,
"unit": "mg"
},
{
"label": "Phosphorus",
"tag": "P",
"schemaOrgTag": null,
"total": 262.92,
"hasRDI": true,
"daily": 37.56,
"unit": "mg"
},
{
"label": "Vitamin A",
"tag": "VITA_RAE",
"schemaOrgTag": null,
"total": 97.58000000000001,
"hasRDI": true,
"daily": 10.842222222222224,
"unit": "µg"
},
{
"label": "Vitamin C",
"tag": "VITC",
"schemaOrgTag": null,
"total": 33.765,
"hasRDI": true,
"daily": 37.516666666666666,
"unit": "mg"
},
{
"label": "Thiamin (B1)",
"tag": "THIA",
"schemaOrgTag": null,
"total": 0.36336,
"hasRDI": true,
"daily": 30.28,
"unit": "mg"
},
{
"label": "Riboflavin (B2)",
"tag": "RIBF",
"schemaOrgTag": null,
"total": 0.28400000000000003,
"hasRDI": true,
"daily": 21.846153846153847,
"unit": "mg"
},
{
"label": "Niacin (B3)",
"tag": "NIA",
"schemaOrgTag": null,
"total": 3.8213600000000003,
"hasRDI": true,
"daily": 23.8835,
"unit": "mg"
},
{
"label": "Vitamin B6",
"tag": "VITB6A",
"schemaOrgTag": null,
"total": 0.25021,
"hasRDI": true,
"daily": 19.246923076923075,
"unit": "mg"
},
{
"label": "Folate equivalent (total)",
"tag": "FOLDFE",
"schemaOrgTag": null,
"total": 94.34,
"hasRDI": true,
"daily": 23.585,
"unit": "µg"
},
{
"label": "Folate (food)",
"tag": "FOLFD",
"schemaOrgTag": null,
"total": 94.34,
"hasRDI": false,
"daily": 0,
"unit": "µg"
},
{
"label": "Folic acid",
"tag": "FOLAC",
"schemaOrgTag": null,
"total": 0,
"hasRDI": false,
"daily": 0,
"unit": "µg"
},
{
"label": "Vitamin B12",
"tag": "VITB12",
"schemaOrgTag": null,
"total": 0.2574,
"hasRDI": true,
"daily": 10.725000000000001,
"unit": "µg"
},
{
"label": "Vitamin D",
"tag": "VITD",
"schemaOrgTag": null,
"total": 0.132,
"hasRDI": true,
"daily": 0.8800000000000001,
"unit": "µg"
},
{
"label": "Vitamin E",
"tag": "TOCPHA",
"schemaOrgTag": null,
"total": 0.48819999999999997,
"hasRDI": true,
"daily": 3.254666666666666,
"unit": "mg"
},
{
"label": "Vitamin K",
"tag": "VITK1",
"schemaOrgTag": null,
"total": 1.2120000000000002,
"hasRDI": true,
"daily": 1.0100000000000002,
"unit": "µg"
},
{
"label": "Sugar alcohols",
"tag": "Sugar.alcohol",
"schemaOrgTag": null,
"total": 0,
"hasRDI": false,
"daily": 0,
"unit": "g"
},
{
"label": "Water",
"tag": "WATER",
"schemaOrgTag": null,
"total": 254.5362,
"hasRDI": false,
"daily": 0,
"unit": "g"
}
]
},
"_links": {
"self": {
"title": "Self",
"href": "https://api.edamam.com/api/recipes/v2/845a9adf81bb22f3b76ead2981a872a0?type=public&app_id=19c82497&app_key=f7ce5672f67e97572eed94fb0984eeda"
}
}
}
]
}
''';
| 0
|
mirrored_repositories/recipe_finder/modules/domain/test/lib/data_sources
|
mirrored_repositories/recipe_finder/modules/domain/test/lib/data_sources/remote/remote_recipe_data_source_test.mocks.dart
|
// Mocks generated by Mockito 5.4.2 from annotations
// in domain/test/lib/data_sources/remote/remote_recipe_data_source_test.dart.
// Do not manually edit this file.
// ignore_for_file: no_leading_underscores_for_library_prefixes
import 'dart:async' as _i3;
import 'package:domain/data_sources/remote/remote_recipe_data_source.dart'
as _i2;
import 'package:mockito/mockito.dart' as _i1;
// ignore_for_file: type=lint
// ignore_for_file: avoid_redundant_argument_values
// ignore_for_file: avoid_setters_without_getters
// ignore_for_file: comment_references
// ignore_for_file: implementation_imports
// ignore_for_file: invalid_use_of_visible_for_testing_member
// ignore_for_file: prefer_const_constructors
// ignore_for_file: unnecessary_parenthesis
// ignore_for_file: camel_case_types
// ignore_for_file: subtype_of_sealed_class
/// A class which mocks [RemoteRecipeDataSource].
///
/// See the documentation for Mockito's code generation for more information.
class MockRemoteRecipeDataSource extends _i1.Mock
implements _i2.RemoteRecipeDataSource {
MockRemoteRecipeDataSource() {
_i1.throwOnMissingStub(this);
}
@override
_i3.Future<Map<String, dynamic>> searchRecipes({required String? query}) =>
(super.noSuchMethod(
Invocation.method(
#searchRecipes,
[],
{#query: query},
),
returnValue:
_i3.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
) as _i3.Future<Map<String, dynamic>>);
}
| 0
|
mirrored_repositories/recipe_finder/modules/domain/test/lib/data_sources
|
mirrored_repositories/recipe_finder/modules/domain/test/lib/data_sources/remote/remote_recipe_data_source_test.dart
|
import 'dart:convert';
import 'package:domain/domain.dart';
import 'package:mockito/annotations.dart';
import 'package:mockito/mockito.dart';
import 'package:test/test.dart';
import 'remote_recipe_data_source_test.mocks.dart';
part 'mock_result_data.dart';
@GenerateMocks([RemoteRecipeDataSource])
void main() {
group(
'RemoteRecipeDataSource',
() {
late final MockRemoteRecipeDataSource remoteDataSource;
setUp(() {
remoteDataSource = MockRemoteRecipeDataSource();
});
test(
'should return a Map of recipes when searchRecipes is called',
() async {
const query = 'mock query';
when(remoteDataSource.searchRecipes(query: query)).thenAnswer(
(_) async {
return Future.value(jsonDecode(mockRecipeResponse));
},
);
final result = await remoteDataSource.searchRecipes(query: query);
verify(remoteDataSource.searchRecipes(query: query)).called(1);
expect(result, isA<Map<String, dynamic>>());
expect(result, contains('hits'));
expect(result['hits'], isA<List>());
expect(result['hits'], isNotEmpty);
expect(result['hits'].first, isA<Map<String, dynamic>>());
expect(result['hits'].first, contains('recipe'));
expect(result['hits'].first['recipe'], isA<Map<String, dynamic>>());
},
);
},
);
}
| 0
|
mirrored_repositories/recipe_finder/modules/domain/test/lib/data_sources
|
mirrored_repositories/recipe_finder/modules/domain/test/lib/data_sources/local/local_recipe_favorite_data_source_test.dart
|
import 'dart:math';
import 'package:mockito/annotations.dart';
import 'package:test/test.dart';
import 'package:mockito/mockito.dart';
import 'package:domain/domain.dart';
import 'local_recipe_favorite_data_source_test.mocks.dart';
import 'recipes_cache_database_test.mocks.dart';
@GenerateMocks([LocalRecipeFavoriteDataSource])
void main() {
group('LocalRecipeFavoriteDataSource', () {
late final MockLocalRecipeFavoriteDataSource dataSource;
late final List<Map<String, dynamic>> favoriteRecipes;
final mockRecipe = MockRecipeEntity();
setUpAll(
() {
when(mockRecipe.toJson()).thenReturn(
{
'id': Random().nextInt(100).toString(),
'name': 'Mock Recipe',
'image': 'mock-image.jpg',
},
);
dataSource = MockLocalRecipeFavoriteDataSource();
favoriteRecipes = List.generate(
5,
(index) => mockRecipe.toJson(),
);
},
);
test('should save a recipe when saveRecipe is called', () async {
when(dataSource.saveRecipe(any)).thenAnswer(
(_) async {
favoriteRecipes.add(mockRecipe.toJson());
},
);
await dataSource.saveRecipe(mockRecipe.toJson());
verify(dataSource.saveRecipe(any)).called(1);
expect(favoriteRecipes, contains(mockRecipe.toJson()));
});
test(
'should return a list of favorite recipes when getFavoriteRecipes is called',
() async {
when(dataSource.getFavoriteRecipes()).thenAnswer(
(_) async => favoriteRecipes,
);
final result = await dataSource.getFavoriteRecipes();
verify(dataSource.getFavoriteRecipes()).called(1);
expect(result, equals(favoriteRecipes));
});
test('should remove a recipe when removeRecipe is called', () async {
when(dataSource.removeRecipe(any)).thenAnswer(
(_) async {
favoriteRecipes.removeLast();
},
);
await dataSource.removeRecipe('1');
verify(dataSource.removeRecipe(any)).called(1);
expect(favoriteRecipes.length, equals(5));
});
});
}
| 0
|
mirrored_repositories/recipe_finder/modules/domain/test/lib/data_sources
|
mirrored_repositories/recipe_finder/modules/domain/test/lib/data_sources/local/local_recipe_favorite_data_source_test.mocks.dart
|
// Mocks generated by Mockito 5.4.2 from annotations
// in domain/test/lib/data_sources/local/local_recipe_favorite_data_source_test.dart.
// Do not manually edit this file.
// ignore_for_file: no_leading_underscores_for_library_prefixes
import 'dart:async' as _i3;
import 'package:domain/data_sources/local/local_recipe_favorite_data_source.dart'
as _i2;
import 'package:mockito/mockito.dart' as _i1;
// ignore_for_file: type=lint
// ignore_for_file: avoid_redundant_argument_values
// ignore_for_file: avoid_setters_without_getters
// ignore_for_file: comment_references
// ignore_for_file: implementation_imports
// ignore_for_file: invalid_use_of_visible_for_testing_member
// ignore_for_file: prefer_const_constructors
// ignore_for_file: unnecessary_parenthesis
// ignore_for_file: camel_case_types
// ignore_for_file: subtype_of_sealed_class
/// A class which mocks [LocalRecipeFavoriteDataSource].
///
/// See the documentation for Mockito's code generation for more information.
class MockLocalRecipeFavoriteDataSource extends _i1.Mock
implements _i2.LocalRecipeFavoriteDataSource {
MockLocalRecipeFavoriteDataSource() {
_i1.throwOnMissingStub(this);
}
@override
_i3.Future<void> saveRecipe(Map<String, dynamic>? recipe) =>
(super.noSuchMethod(
Invocation.method(
#saveRecipe,
[recipe],
),
returnValue: _i3.Future<void>.value(),
returnValueForMissingStub: _i3.Future<void>.value(),
) as _i3.Future<void>);
@override
_i3.Future<List<Map<String, dynamic>>> getFavoriteRecipes() =>
(super.noSuchMethod(
Invocation.method(
#getFavoriteRecipes,
[],
),
returnValue: _i3.Future<List<Map<String, dynamic>>>.value(
<Map<String, dynamic>>[]),
) as _i3.Future<List<Map<String, dynamic>>>);
@override
_i3.Future<void> removeRecipe(String? recipeId) => (super.noSuchMethod(
Invocation.method(
#removeRecipe,
[recipeId],
),
returnValue: _i3.Future<void>.value(),
returnValueForMissingStub: _i3.Future<void>.value(),
) as _i3.Future<void>);
}
| 0
|
mirrored_repositories/recipe_finder/modules/domain/test/lib/data_sources
|
mirrored_repositories/recipe_finder/modules/domain/test/lib/data_sources/local/recipes_cache_database_test.dart
|
import 'package:domain/domain.dart';
import 'package:mockito/annotations.dart';
import 'package:mockito/mockito.dart';
import 'package:test/test.dart';
import 'recipes_cache_database_test.mocks.dart';
@GenerateMocks([RecipesCacheDatabase, RecipeEntity])
void main() {
group(
'RecipesCacheDatabase',
() {
late final MockRecipesCacheDatabase mockRecipesCacheDatabase;
late final List<MockRecipeEntity> mockRecipes;
setUpAll(
() {
mockRecipesCacheDatabase = MockRecipesCacheDatabase();
mockRecipes = List.generate(
5,
(index) => MockRecipeEntity(),
);
},
);
test(
'should return cached recipes when getRecipes is called',
() async {
final mockDatabase = MockRecipesCacheDatabase();
when(mockDatabase.getRecipes()).thenAnswer((_) async => mockRecipes);
final result = await mockDatabase.getRecipes();
expect(result, isA<Iterable<RecipeEntity>>());
expect(result, equals(mockRecipes));
verify(mockDatabase.getRecipes()).called(1);
},
);
test(
'should cache recipes when cacheRecipes is called',
() async {
when(mockRecipesCacheDatabase.cacheRecipes(mockRecipes)).thenAnswer(
(_) async {
mockRecipes.add(MockRecipeEntity());
},
);
await mockRecipesCacheDatabase.cacheRecipes(mockRecipes);
verify(mockRecipesCacheDatabase.cacheRecipes(mockRecipes)).called(1);
expect(mockRecipes.length, equals(6));
},
);
test(
'should clear the cached recipes',
() async {
when(mockRecipesCacheDatabase.clearCache()).thenAnswer(
(_) async {
mockRecipes.clear();
},
);
await mockRecipesCacheDatabase.clearCache();
verify(mockRecipesCacheDatabase.clearCache()).called(1);
expect(mockRecipes.length, equals(0));
},
);
},
);
}
| 0
|
mirrored_repositories/recipe_finder/modules/domain/test/lib/data_sources
|
mirrored_repositories/recipe_finder/modules/domain/test/lib/data_sources/local/recipes_cache_database_test.mocks.dart
|
// Mocks generated by Mockito 5.4.2 from annotations
// in domain/test/lib/data_sources/local/recipes_cache_database_test.dart.
// Do not manually edit this file.
// ignore_for_file: no_leading_underscores_for_library_prefixes
import 'dart:async' as _i3;
import 'package:domain/data_sources/local/recipes_cache_database.dart' as _i2;
import 'package:domain/models/recipe_entity/recipe_entity.dart' as _i4;
import 'package:mockito/mockito.dart' as _i1;
// ignore_for_file: type=lint
// ignore_for_file: avoid_redundant_argument_values
// ignore_for_file: avoid_setters_without_getters
// ignore_for_file: comment_references
// ignore_for_file: implementation_imports
// ignore_for_file: invalid_use_of_visible_for_testing_member
// ignore_for_file: prefer_const_constructors
// ignore_for_file: unnecessary_parenthesis
// ignore_for_file: camel_case_types
// ignore_for_file: subtype_of_sealed_class
/// A class which mocks [RecipesCacheDatabase].
///
/// See the documentation for Mockito's code generation for more information.
class MockRecipesCacheDatabase extends _i1.Mock
implements _i2.RecipesCacheDatabase {
MockRecipesCacheDatabase() {
_i1.throwOnMissingStub(this);
}
@override
_i3.Future<Iterable<_i4.RecipeEntity>> getRecipes() => (super.noSuchMethod(
Invocation.method(
#getRecipes,
[],
),
returnValue:
_i3.Future<Iterable<_i4.RecipeEntity>>.value(<_i4.RecipeEntity>[]),
) as _i3.Future<Iterable<_i4.RecipeEntity>>);
@override
_i3.Future<void> cacheRecipes(Iterable<_i4.RecipeEntity>? recipes) =>
(super.noSuchMethod(
Invocation.method(
#cacheRecipes,
[recipes],
),
returnValue: _i3.Future<void>.value(),
returnValueForMissingStub: _i3.Future<void>.value(),
) as _i3.Future<void>);
@override
_i3.Future<void> clearCache() => (super.noSuchMethod(
Invocation.method(
#clearCache,
[],
),
returnValue: _i3.Future<void>.value(),
returnValueForMissingStub: _i3.Future<void>.value(),
) as _i3.Future<void>);
}
/// A class which mocks [RecipeEntity].
///
/// See the documentation for Mockito's code generation for more information.
class MockRecipeEntity extends _i1.Mock implements _i4.RecipeEntity {
MockRecipeEntity() {
_i1.throwOnMissingStub(this);
}
@override
String get id => (super.noSuchMethod(
Invocation.getter(#id),
returnValue: '',
) as String);
@override
String get name => (super.noSuchMethod(
Invocation.getter(#name),
returnValue: '',
) as String);
@override
String get imageUrl => (super.noSuchMethod(
Invocation.getter(#imageUrl),
returnValue: '',
) as String);
@override
List<String> get ingredients => (super.noSuchMethod(
Invocation.getter(#ingredients),
returnValue: <String>[],
) as List<String>);
@override
List<String> get ingredientLines => (super.noSuchMethod(
Invocation.getter(#ingredientLines),
returnValue: <String>[],
) as List<String>);
@override
String get url => (super.noSuchMethod(
Invocation.getter(#url),
returnValue: '',
) as String);
@override
Map<String, dynamic> toJson() => (super.noSuchMethod(
Invocation.method(
#toJson,
[],
),
returnValue: <String, dynamic>{},
) as Map<String, dynamic>);
}
| 0
|
mirrored_repositories/recipe_finder/modules/domain/test/lib
|
mirrored_repositories/recipe_finder/modules/domain/test/lib/repositories/recipe_repository_test.dart
|
import 'package:domain/domain.dart';
import 'package:mockito/annotations.dart';
import 'package:mockito/mockito.dart';
import 'package:test/test.dart';
import 'recipe_repository_test.mocks.dart';
@GenerateMocks([RecipeRepository])
void main() {
group('RecipeRepository', () {
late final MockRecipeRepository repository;
late final List<RecipeEntity> mockRecipes;
late final List<RecipeEntity> favoriteRecipes;
setUpAll(() {
repository = MockRecipeRepository();
mockRecipes = [
const RecipeEntity(
id: '1',
name: 'Pasta',
imageUrl: 'https://example.com/pasta.jpg',
ingredients: ['flour', 'eggs', 'water', 'salt'],
ingredientLines: [
'1 cup flour',
'1 egg',
'1/2 cup water',
'1/2 tsp salt'
],
url: 'https://example.com/pasta',
),
const RecipeEntity(
id: '2',
name: 'Pizza',
imageUrl: 'https://example.com/pizza.jpg',
ingredients: ['flour', 'tomatoes', 'cheese', 'pepperoni'],
ingredientLines: [
'1 cup flour',
'1 tomato',
'1/2 cup cheese',
'6 slices pepperoni'
],
url: 'https://example.com/pizza',
),
const RecipeEntity(
id: '3',
name: 'Burger',
imageUrl: 'https://example.com/burger.jpg',
ingredients: ['beef', 'lettuce', 'tomato', 'bun'],
ingredientLines: [
'1/4 lb beef',
'1 leaf lettuce',
'1 tomato slice',
'1 bun'
],
url: 'https://example.com/burger',
),
];
favoriteRecipes = [];
});
test('searchRecipes returns matching recipes', () async {
const query = 'Pasta';
when(repository.searchRecipes(query: anyNamed('query'))).thenAnswer(
(realInvocation) {
return Future.value(
mockRecipes
.where(
(recipe) => recipe.name.contains(query),
)
.toList(),
);
},
);
final results = await repository.searchRecipes(query: query);
verify(repository.searchRecipes(query: query)).called(1);
expect(results, isA<List<RecipeEntity>>());
expect(results, hasLength(1));
expect(results.first.id, equals('1'));
});
test('getFavoriteRecipes returns favorite recipes', () async {
when(repository.getFavoriteRecipes()).thenAnswer(
(_) async => favoriteRecipes,
);
final results = await repository.getFavoriteRecipes();
expect(results, hasLength(0));
favoriteRecipes.add(mockRecipes[0]);
final newResults = await repository.getFavoriteRecipes();
expect(newResults, hasLength(1));
expect(newResults.first.id, equals(mockRecipes[0].id));
});
test('addFavoriteRecipe adds recipe to favorites', () async {
favoriteRecipes.clear();
final recipe = mockRecipes.first;
expect(favoriteRecipes, hasLength(0));
when(repository.addFavoriteRecipe(recipe)).thenAnswer(
(_) async {
favoriteRecipes.add(recipe);
},
);
await repository.addFavoriteRecipe(recipe);
expect(favoriteRecipes, hasLength(1));
});
test('removeFavoriteRecipe removes recipe from favorites', () async {
favoriteRecipes.clear();
favoriteRecipes.add(mockRecipes.first);
final recipe = mockRecipes.first;
expect(favoriteRecipes, hasLength(1));
when(repository.removeFavoriteRecipe(recipe)).thenAnswer(
(_) async {
favoriteRecipes.remove(recipe);
},
);
await repository.removeFavoriteRecipe(recipe);
expect(favoriteRecipes, hasLength(0));
});
test('getRecipes returns all recipes', () async {
when(repository.getRecipes()).thenAnswer((_) async => mockRecipes);
final results = await repository.getRecipes();
expect(results, hasLength(3));
expect(results.map((recipe) => recipe.id), containsAll(['1', '2', '3']));
expect(results.first.name, equals('Pasta'));
expect(results.first.imageUrl, equals('https://example.com/pasta.jpg'));
expect(results.first.ingredients,
containsAll(['flour', 'eggs', 'water', 'salt']));
expect(
results.first.ingredientLines,
containsAll(
['1 cup flour', '1 egg', '1/2 cup water', '1/2 tsp salt']));
expect(results.first.url, equals('https://example.com/pasta'));
});
});
}
| 0
|
mirrored_repositories/recipe_finder/modules/domain/test/lib
|
mirrored_repositories/recipe_finder/modules/domain/test/lib/repositories/recipe_repository_test.mocks.dart
|
// Mocks generated by Mockito 5.4.2 from annotations
// in domain/test/lib/repositories/recipe_repository_test.dart.
// Do not manually edit this file.
// ignore_for_file: no_leading_underscores_for_library_prefixes
import 'dart:async' as _i3;
import 'package:domain/domain.dart' as _i2;
import 'package:mockito/mockito.dart' as _i1;
// ignore_for_file: type=lint
// ignore_for_file: avoid_redundant_argument_values
// ignore_for_file: avoid_setters_without_getters
// ignore_for_file: comment_references
// ignore_for_file: implementation_imports
// ignore_for_file: invalid_use_of_visible_for_testing_member
// ignore_for_file: prefer_const_constructors
// ignore_for_file: unnecessary_parenthesis
// ignore_for_file: camel_case_types
// ignore_for_file: subtype_of_sealed_class
class _FakeRemoteRecipeDataSource_0 extends _i1.SmartFake
implements _i2.RemoteRecipeDataSource {
_FakeRemoteRecipeDataSource_0(
Object parent,
Invocation parentInvocation,
) : super(
parent,
parentInvocation,
);
}
class _FakeLocalRecipeFavoriteDataSource_1 extends _i1.SmartFake
implements _i2.LocalRecipeFavoriteDataSource {
_FakeLocalRecipeFavoriteDataSource_1(
Object parent,
Invocation parentInvocation,
) : super(
parent,
parentInvocation,
);
}
class _FakeRecipesCacheDatabase_2 extends _i1.SmartFake
implements _i2.RecipesCacheDatabase {
_FakeRecipesCacheDatabase_2(
Object parent,
Invocation parentInvocation,
) : super(
parent,
parentInvocation,
);
}
/// A class which mocks [RecipeRepository].
///
/// See the documentation for Mockito's code generation for more information.
class MockRecipeRepository extends _i1.Mock implements _i2.RecipeRepository {
MockRecipeRepository() {
_i1.throwOnMissingStub(this);
}
@override
_i2.RemoteRecipeDataSource get remoteDataSource => (super.noSuchMethod(
Invocation.getter(#remoteDataSource),
returnValue: _FakeRemoteRecipeDataSource_0(
this,
Invocation.getter(#remoteDataSource),
),
) as _i2.RemoteRecipeDataSource);
@override
_i2.LocalRecipeFavoriteDataSource get localFavoriteDataSource =>
(super.noSuchMethod(
Invocation.getter(#localFavoriteDataSource),
returnValue: _FakeLocalRecipeFavoriteDataSource_1(
this,
Invocation.getter(#localFavoriteDataSource),
),
) as _i2.LocalRecipeFavoriteDataSource);
@override
_i2.RecipesCacheDatabase get recipesCacheDatabase => (super.noSuchMethod(
Invocation.getter(#recipesCacheDatabase),
returnValue: _FakeRecipesCacheDatabase_2(
this,
Invocation.getter(#recipesCacheDatabase),
),
) as _i2.RecipesCacheDatabase);
@override
_i3.Future<Iterable<_i2.RecipeEntity>> searchRecipes(
{required String? query}) =>
(super.noSuchMethod(
Invocation.method(
#searchRecipes,
[],
{#query: query},
),
returnValue:
_i3.Future<Iterable<_i2.RecipeEntity>>.value(<_i2.RecipeEntity>[]),
) as _i3.Future<Iterable<_i2.RecipeEntity>>);
@override
_i3.Future<Iterable<_i2.RecipeEntity>> getFavoriteRecipes() =>
(super.noSuchMethod(
Invocation.method(
#getFavoriteRecipes,
[],
),
returnValue:
_i3.Future<Iterable<_i2.RecipeEntity>>.value(<_i2.RecipeEntity>[]),
) as _i3.Future<Iterable<_i2.RecipeEntity>>);
@override
_i3.Future<void> addFavoriteRecipe(_i2.RecipeEntity? recipe) =>
(super.noSuchMethod(
Invocation.method(
#addFavoriteRecipe,
[recipe],
),
returnValue: _i3.Future<void>.value(),
returnValueForMissingStub: _i3.Future<void>.value(),
) as _i3.Future<void>);
@override
_i3.Future<void> removeFavoriteRecipe(_i2.RecipeEntity? recipe) =>
(super.noSuchMethod(
Invocation.method(
#removeFavoriteRecipe,
[recipe],
),
returnValue: _i3.Future<void>.value(),
returnValueForMissingStub: _i3.Future<void>.value(),
) as _i3.Future<void>);
@override
_i3.Future<Iterable<_i2.RecipeEntity>> getRecipes() => (super.noSuchMethod(
Invocation.method(
#getRecipes,
[],
),
returnValue:
_i3.Future<Iterable<_i2.RecipeEntity>>.value(<_i2.RecipeEntity>[]),
) as _i3.Future<Iterable<_i2.RecipeEntity>>);
}
| 0
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.