getEvaluatorContext method
Returns a Map with the evaluation context used when sanitizing properties of a NodeSpec. Used to resolve properties that use placeholders as values, like "${state.firstName}" or "${env.api_uri}".
Implementation
Map getEvaluatorContext(Object? value, Map state, Map? specContext) {
final mediaQueryData = MediaQueryData.fromView(
WidgetsBinding.instance.platformDispatcher.views.single);
Lowder.globalVariables.addAll({
"now": DateTime.now(),
"utcNow": DateTime.now().toUtc(),
"languages": Solution.languages,
"language": Solution.language,
});
final map = {};
if (specContext != null) map.addAll(specContext);
map.addAll({
"state": state,
"value": value,
"global": Lowder.globalVariables,
"env": Solution.environmentVariables,
"media": {
"isWeb": kIsWeb,
"isMobile": !kIsWeb && mediaQueryData.size.shortestSide < 600,
"isTablet": !kIsWeb && mediaQueryData.size.shortestSide >= 600,
"isAndroid": kIsWeb ? false : Platform.isAndroid,
"isIOS": kIsWeb ? false : Platform.isIOS,
"isWindows": kIsWeb ? false : Platform.isWindows,
"isMacOS": kIsWeb ? false : Platform.isMacOS,
"isLinux": kIsWeb ? false : Platform.isLinux,
"isFuchsia": kIsWeb ? false : Platform.isFuchsia,
"portrait": mediaQueryData.orientation == Orientation.portrait,
"landscape": mediaQueryData.orientation == Orientation.landscape,
// "version": Platform.version,
},
"null": null,
});
return map;
}