flutter_exprtk

所属分类:Dart语言编程
开发工具:C++
文件大小:1949KB
下载次数:0
上传日期:2023-02-17 18:16:24
上 传 者sh-1993
说明:  exprtk数学表达式解析器的dart-ffi包装器
(dart ffi wrapper for exprtk math expression parser)

文件列表:
.vscode (0, 2023-08-20)
.vscode\launch.json (2675, 2023-08-20)
.vscode\settings.json (1404, 2023-08-20)
CHANGELOG.md (250, 2023-08-20)
LICENSE (1066, 2023-08-20)
flutter_exprtk (0, 2023-08-20)
flutter_exprtk\.metadata (309, 2023-08-20)
flutter_exprtk\CHANGELOG.md (571, 2023-08-20)
flutter_exprtk\LICENSE (1035, 2023-08-20)
flutter_exprtk\analysis_options.yaml (51, 2023-08-20)
flutter_exprtk\example (0, 2023-08-20)
flutter_exprtk\example\.metadata (305, 2023-08-20)
flutter_exprtk\example\analysis_options.yaml (51, 2023-08-20)
flutter_exprtk\example\android (0, 2023-08-20)
flutter_exprtk\example\android\app (0, 2023-08-20)
flutter_exprtk\example\android\app\build.gradle (1708, 2023-08-20)
flutter_exprtk\example\android\app\src (0, 2023-08-20)
flutter_exprtk\example\android\app\src\debug (0, 2023-08-20)
flutter_exprtk\example\android\app\src\debug\AndroidManifest.xml (327, 2023-08-20)
flutter_exprtk\example\android\app\src\main (0, 2023-08-20)
flutter_exprtk\example\android\app\src\main\AndroidManifest.xml (2142, 2023-08-20)
flutter_exprtk\example\android\app\src\main\kotlin (0, 2023-08-20)
flutter_exprtk\example\android\app\src\main\kotlin\com (0, 2023-08-20)
flutter_exprtk\example\android\app\src\main\kotlin\com\example (0, 2023-08-20)
flutter_exprtk\example\android\app\src\main\kotlin\com\example\example (0, 2023-08-20)
flutter_exprtk\example\android\app\src\main\kotlin\com\example\example\MainActivity.kt (124, 2023-08-20)
flutter_exprtk\example\android\app\src\main\res (0, 2023-08-20)
flutter_exprtk\example\android\app\src\main\res\drawable-v21 (0, 2023-08-20)
flutter_exprtk\example\android\app\src\main\res\drawable-v21\launch_background.xml (438, 2023-08-20)
flutter_exprtk\example\android\app\src\main\res\drawable (0, 2023-08-20)
flutter_exprtk\example\android\app\src\main\res\drawable\launch_background.xml (434, 2023-08-20)
flutter_exprtk\example\android\app\src\main\res\mipmap-hdpi (0, 2023-08-20)
... ...

# flutter_exprtk ffi wrapper for exprtk math expression parser See https://github.com/ArashPartow/exprtk for details ## Limitations Only works with doubles, not vectors etc. Currently supports Android, MacOS, iOS and Windows ## To install dependencies: flutter: sdk: flutter flutter_exprtk: ^0.0.5 Import the library: import 'package:flutter_exprtk/flutter_exprtk.dart'; ## Getting Started // Create a new expression final exp = Expression( expression: "a / b", // The expression variables: { "a": 4, "b": 2 }, // variables constants: {} // Optional constants can be omitted ); // Get the value print(exp.value); // -> 2 // Variables can be changed: exp["a"] = 100 print(exp.value); // -> 50 exp["b"] = 50 print(exp.value); // -> 2 // Call clear to free up memory expression.clear(); More complex example: final exp2 = Expression( expression: "clamp(-1.0,sin(2 * pi * x) + cos(x / 2 * pi),+1.0)", variables: { "x": 0 } ); for (double x = -5; x <= 5; x += 0.001) { exp2["x"] = x; print("${exp2.value}"); } // Call clear to free up memory exp2.clear(); In a separate Isolate: // Static or global function: Future> computeExpression (dynamic _) async { final exp2 = Expression( expression: "clamp(-1.0,sin(2 * pi * x) + cos(x / 2 * pi),+1.0)", variables: { "x": 0 } ); final List results = []; for (double x = -5; x <= 5; x += 0.001) { exp2["x"] = x; results.add(exp2.value); } exp2.clear(); return results; } // Then run it for example with compute from flutter:foundation: final results = await compute(computeExpression, null); print("Results $results"); ## Handling errors new Expression() will throw an "InvalidExpressionException" if the expression isn't valid. If you try to set a variable which hasn't been initialized an "UninitializedVariableException" will be thrown: try { final exp = Expression( expression: "///////", // will cause an InvalidExpressionException variables: {} ); final exp = Expression( expression: "a + b", variables: { "c": 0 } // will cause an UninitializedVariableException ); exp["d"] = 0; // will also cause an UninitializedVariableException } on InvalidExpressionException { // ... handle exception } on UninitializedVariableException { // ... handle exception }

近期下载者

相关文件


收藏者