flutter 调用函数时方法onTap()出错

x4shl7ld  于 2023-02-25  发布在  Flutter
关注(0)|答案(1)|浏览(142)
TextField(
                    textAlign: TextAlign.center,
                    obscureText: _obscureText,
                    onChanged: (value) {
                      //Do something with the user input.
                      password = value;
                    },
                    style: const TextStyle(color: Colors.black),
                    decoration: const InputDecoration(
                      hintText: 'Enter your Password.',
                      hintStyle: TextStyle(color: Colors.black26),
                      suffix: InkWell(
                        child: Icon(Icons.visibility),
                        onTap: _togglePasswordView,
                        //here is error in onTap
                        
                      ),
                      contentPadding:
                      EdgeInsets.symmetric(vertical: 10.0, horizontal: 20.0),
                      border: OutlineInputBorder(
                        borderRadius: BorderRadius.all(Radius.circular(32.0)),
                      ),
                    

  void _togglePasswordView() {
    setState(() {
      _obscureText = !_obscureText;
    });
  }
}

这是该页面的所有代码,后缀中的onTap函数存在错误。错误消息显示//无效常量值//错误的图像如下所示x1c 0d1x,

kkbh8khc

kkbh8khc1#

装饰:常量输入装饰
您将输入修饰定义为常量,但出错时它不是常量。删除常量

相关问题