Tushar Pol
Tushar Pol

Reputation: 7619

Is there any way to convert String into Dart functional code?

I'm getting conditions in an string.

For example: String conditions = "gender == 1 && gender == 3";

I want to convert it into If Conditional statement.

like if(gender == 1 && gender == 3) { }

How can I parse that string ?

Upvotes: 3

Views: 1945

Answers (1)

Sahil Hariyani
Sahil Hariyani

Reputation: 1178

You can use function_tree package to convert string to expression.

String conditions = "gender == 1 && gender == 3";
if(conditions.interpret()) {  }

Upvotes: 1

Related Questions