Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/flutter/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jsf-2/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Flutter 如何修复代码,使我的计数值从函数更新_Flutter - Fatal编程技术网

Flutter 如何修复代码,使我的计数值从函数更新

Flutter 如何修复代码,使我的计数值从函数更新,flutter,Flutter,如何使\u handlerRadioValuegender()更新我在顶部声明为var count=3的count值 我尝试了我能做的,下面是所有debugprint()函数的结果。它现在总是采用我在顶部定义的值,这意味着我的\u处理程序函数对计数值没有影响 var count = 3; int _handleRadioValuegender(int value) { setState(() { _gender = value; switch (_gender) {

如何使
\u handlerRadioValuegender()
更新我在顶部声明为
var count=3
count

我尝试了我能做的,下面是所有
debugprint()
函数的结果。它现在总是采用我在顶部定义的值,这意味着我的
\u处理程序
函数对计数值没有影响

var count = 3;
int _handleRadioValuegender(int value) {
  setState(() {
    _gender = value;

    switch (_gender) {
      case 0:
        debugPrint('case0');
        count++;
        debugPrint('$count');
        break;

      case 1:
        debugPrint('case1');
        this.count++;
        this.count++;
        debugPrint('$count');
        break;
    }
  });
}

String gender() {
  if (count == 1) {
    debugPrint('$count');
    return 'Male';
  } else if (count == 3) {
    debugPrint('$count');
    return 'Female';
  } else {
    debugPrint('$count');
  }
}
我想从我的
\u handlerRadioValuegender()
函数更新我的计数值,当
gender()
访问它时,它应该根据该值返回值