WEB_PORT, para juntar en master
This commit is contained in:
parent
1a076dff6c
commit
9ea3b88684
3 changed files with 16 additions and 4 deletions
4
Makefile
4
Makefile
|
|
@ -23,10 +23,10 @@ run-linux-debug-container: pub-get-container
|
|||
./docker-exec.sh exec flutter run -d linux
|
||||
|
||||
run-web-debug-container: pub-get-container
|
||||
./docker-exec.sh exec flutter run --web-port 8081 -d web-server
|
||||
./docker-exec.sh exec flutter run --web-port $${WEB_PORT:-8081} -d web-server
|
||||
|
||||
run-linux-debug-native: build-linux-debug-container
|
||||
./build/linux/x64/debug/bundle/d4rt_formulas
|
||||
|
||||
run-web-debug-native: build-web-debug-container
|
||||
cd build/web && python3 -m http.server 8081
|
||||
cd build/web && python3 -m http.server $${WEB_PORT:-8081}
|
||||
|
|
|
|||
|
|
@ -142,6 +142,8 @@ class FormulaEvaluator {
|
|||
import "package:d4rt_formulas.dart";
|
||||
""";
|
||||
|
||||
static const reservedVariableNames = { "variableValues", "indexOf", "variableAllowedValues"} ;
|
||||
|
||||
String _buildCompleteSource(Formula formula, Map<String, dynamic> inputValues) {
|
||||
final buffer = StringBuffer();
|
||||
|
||||
|
|
@ -220,10 +222,12 @@ class FormulaEvaluator {
|
|||
|
||||
// Some functions to deal with string values
|
||||
buffer.writeln("""
|
||||
int indexOf(String inputName) {
|
||||
// If return type is int, there is an error converting double to int 🤷
|
||||
dynamic indexOf(String inputName) {
|
||||
String value = variableValues[inputName];
|
||||
String allowedValues = variableAllowedValues[inputName];
|
||||
return allowedValues.indexOf(value);
|
||||
dynamic ret = allowedValues.indexOf(value) as int;
|
||||
return ret as int;
|
||||
}
|
||||
""");
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import 'package:d4rt/d4rt.dart';
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:d4rt_formulas/d4rt_formulas.dart';
|
||||
|
||||
abstract class SetUtils {
|
||||
static Object safeGet(Map<Object?, Object?> map, String key) {
|
||||
|
|
@ -105,6 +106,13 @@ class VariableSpec {
|
|||
final List<dynamic>? values;
|
||||
|
||||
VariableSpec({required this.name, this.unit, this.values}){
|
||||
validate();
|
||||
}
|
||||
|
||||
void validate(){
|
||||
if( FormulaEvaluator.reservedVariableNames.contains(name) ){
|
||||
throw ArgumentError("$name: is a reserved variable name for FormulaEvaluator");
|
||||
}
|
||||
final valuesValid = values != null && values?.isNotEmpty == true;
|
||||
if( unit == null && !valuesValid ){
|
||||
throw ArgumentError("$name: at least unit or allowedValues should be valid");
|
||||
|
|
|
|||
Loading…
Reference in a new issue