Flutter 如何将自定义小部件作为后缀放入 formtextfield?

Flutter how i can put custom widget to formtextfield as a suffix?

我有一个表单文本字段,我想将文本按钮作为我忘记密码的后缀。但是当我尝试添加时,我什么也看不到。

我的代码:

 TextFormField(   
            decoration: InputDecoration(
              suffix:TextButton(child: Text("Şifremi Unuttum?"),onPressed: (){}) 
              ),
              floatingLabelStyle: TextStyle(
                  color: isFocused
                      ? Color.fromARGB(255, 141, 56, 211)
                      : Color.fromARGB(255, 91, 103, 125),
                  fontWeight: FontWeight.w500,
                  fontSize: 14),
            ),
          ),

当我检查后缀时想要一个小部件。所以我给了它,但它没有显示这里的问题是什么?感谢您的帮助!!

你的源代码对我来说一切正常。 TextButton 显示正确。我将附上下面的代码以及屏幕截图,我在其中添加了缺少的标签,因为您使用了它的样式和一个条件,如果您忘记了密码,然后在后缀中显示一个文本按钮:

class _MyHomePageState extends State<MyHomePage> {
  static bool isFocused = true;
  static bool isForgotPassword = true;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: const Text("App bar"),
        ),
        body: TextFormField(
          initialValue: "My Text",
          decoration: InputDecoration(
            suffix: isForgotPassword ? TextButton(
                child: const Text("Şifremi Unuttum?"), onPressed: () {}) : null,
            label: const Text(
              "Floating Label",
              style: TextStyle(fontSize: 25),
            ),
            floatingLabelStyle: TextStyle(
                color: isFocused
                    ? const Color.fromARGB(255, 141, 56, 211)
                    : const Color.fromARGB(255, 91, 103, 125),
                fontWeight: FontWeight.w500,
                fontSize: 14),
          ),
        ));
  }
}

Screenshot of app screen with 2 false booleans