【问题标题】:Is there any way to convert String into Dart functional code?有什么方法可以将 String 转换为 Dart 功能代码?
【发布时间】:2021-03-18 21:48:23
【问题描述】:

我在字符串中获取条件。

例如:String conditions = "gender == 1 && gender == 3";

我想把它转换成 If 条件语句。

点赞if(gender == 1 && gender == 3) { }

我怎样才能解析那个字符串?

【问题讨论】:

    标签: flutter dart


    【解决方案1】:

    您可以使用function_tree 包将字符串转换为表达式。

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

    【讨论】:

      猜你喜欢
      • 2016-06-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-01-09
      • 2020-11-03
      • 1970-01-01
      相关资源
      最近更新 更多