📜  如何防止用户在文本字段颤动中输入空值 - 无论代码示例

📅  最后修改于: 2022-03-11 15:00:25.458000             🧑  作者: Mango

代码示例1
FloatingActionButton(
            onPressed: ()async {
//                setstring(String result){
//                  widget.updatestring = result;
//                  return widget.updatestring;
//                }
                String result1 =   await Navigator.push( // string which stores the user entered value
                  context,
                  MaterialPageRoute(
                    builder: (context) => InputScreen(), //screen which has TextField
                  ));
              setState(() {
//                widget.updatestring = result1;
                TodoList(result1);
//              setstring(result1);
                addItem(result1, false); // function which adds the entered task in a list
              });
            },
            heroTag: "btn2",
            child: Icon(Icons.add, color: Color(whitecolor),), backgroundColor: Color(redcolor),),