简体   繁体   English

在 Android Studio 中未触发 Flutter setState

[英]Flutter setState isn't triggered in Android studio

I'm absolutely new to programming and Flutter as well, so sorry for my silly question but I can't find in Google the reason why when I'm starting to type setState in Android studio it isn't popped up (from code helper) and I'm forced to remember the right spelling for this method.我对编程和 Flutter 也完全陌生,很抱歉我的愚蠢问题,但我无法在 Google 中找到当我开始在 Android Studio 中键入 setState 时它没有弹出的原因(来自代码助手) 我不得不记住这种方法的正确拼写。

Hope you can help me because I really can't understand how to fix it.希望你能帮助我,因为我真的不明白如何解决它。

Thanks in advance for any comments.提前感谢您的任何评论。

class InputPage extends StatefulWidget {
  @override
  _InputPageState createState() => _InputPageState();
}

class _InputPageState extends State<InputPage> {
  late Gender selectedGender;
  int height = 180;
  int weight = 60;
  int age = 19;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('BMI CALCULATOR'),
      ),
      body: Column(
        crossAxisAlignment: CrossAxisAlignment.stretch,
        children: <Widget>[
          Expanded(
            child: Row(
              children: <Widget>[
                Expanded(
                  child: ReusableCard(
                    onPress: () {
                      setState(() {
                        selectedGender = Gender.male;
                      });
                    },
                    colour: selectedGender == Gender.male
                        ? kActiveCardColour
                        : kInactiveCardColour,
                    cardChild: IconContent(
                      icon: FontAwesomeIcons.mars,
                      label: 'MALE',
                    ),
                  ),
                ),
label: selectedGender == Gender.male?'MALE':"FEMALE",

You added male directly.您直接添加了男性。 Please make it display based on selectedGender.请根据 selectedGender 显示。

It also happens to me, but apparently it is a change in the version of Android Studio (if you are working with Android Studio), personally I have not wanted to rollback because it is a lot of work, but in a few weeks it has not been corrected by means of some update or something like that I think it will be time to do it这也发生在我身上,但显然这是 Android Studio 版本的变化(如果你正在使用 Android Studio),我个人不想回滚,因为它需要做很多工作,但几周后它就有了没有通过一些更新或类似的方法得到纠正,我认为是时候做这件事了

By the way, neither setState nor initState nor several other methods work顺便说一句,setState 和 initState 以及其他几种方法都不起作用

My current version of Android Studio is as follows我当前的Android Studio版本如下

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM