Parse JS SDKmatchesQuery() 返回应该被过滤掉的对象

问题描述

我有一个 User 表,其中 userRole 关系指向 UserRole 类 我想检索所有具有 userRole 的用户,字段“name”不等于“superadmin”

class AndroidDropdown extends StatefulWidget {
  final List dropDownData;
  final Function getSelectedValue;
  //valueFromDB: used for the edit case,when there is already saved value
  final int valueFromDB;

  AndroidDropdown(
      {@required this.dropDownData,@required this.getSelectedValue,this.valueFromDB});

  @override
  _AndroidDropdownState createState() => _AndroidDropdownState();
}

class _AndroidDropdownState extends State<AndroidDropdown> {
  String _selectedValue;
  int prevValueFromDB;

  @override
  void initState() {
    super.initState();
    //check if there a data from the DB (for update reasons)
    if (widget.valueFromDB != null) {
      int listIndex = widget.valueFromDB - 1;
      _selectedValue = widget.dropDownData[listIndex];
      widget.getSelectedValue(widget.valueFromDB);
      prevValueFromDB = widget.valueFromDB; //to use in checkIfNewValueAdded()
    } else {
      //make the default selected is the first value
      _selectedValue = widget.dropDownData[0];
      //assign a default value for the function in case the user didn't use onChange
      widget.getSelectedValue(1);
    }
  }

  @override
  Widget build(BuildContext context) {
    checkIfNewValueAdded();
    List<DropdownMenuItem<dynamic>> dropdownItems = [];
    //the items loop function
    for (var item in widget.dropDownData) {
      var newItem = DropdownMenuItem(
        child: Text(item),value: item,);
      dropdownItems.add(newItem);
    }

    return DropdownButton<dynamic>(
      value: _selectedValue,//for initial value
      items: dropdownItems,onChanged: (value) {
        setState(() {
          _selectedValue = value;
          widget.getSelectedValue(widget.dropDownData.indexOf(value) + 1);
          //I used this trick to get the ID of the item type that saved in the DB
        });
      },);
  }

  //this to check if there is a new value added in the list
  void checkIfNewValueAdded() {
    if (widget.valueFromDB != prevValueFromDB) {
      setState(() {
        int listIndex = widget.valueFromDB - 1;
        _selectedValue = widget.dropDownData[listIndex];
        prevValueFromDB = widget.valueFromDB;
      });
    }
  }
}

我仍然得到 UserRole 关系名称等于“超级管理员”的用户

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)