'I want to apply dynamic formula using query string for Map
I want to add calculation on Map dynamically using query string, as shown below. I will define variable:
Map<dynamic, dynamic> data= new Map();
data["qty"] = 12;
data["price"] = 18;
I want to write just like a string query like below
string string = "Content data["amount"] = data["qty"]*data["price"]";
I want to execute this string and it return Map values which I will add to data map code here, it is possible in flutter.
Solution 1:[1]
You can use this package Math_expressions
And solve math expressions using string like the following
Parser p = Parser();
Expression exp = p.parse("(x^2 + cos(y)) / 3");
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Kaushik Chandru |
