Flutter:ExpansionTile 小部件中 TextEditingController 的多光标

Flutter : multi cursor of TextEditingController in an ExpansionTile widget

我在 ExpansionTile 中有几个 TextEditingController。

当我点击其中之一时,我会在所有 TextEditingController 上获得多个光标。

当我将文本放入一个 TextEditingController(或任何操作)时:它会影响同一个 ExpansionTile 小部件中的所有其他文本。

    widget build(){
               ...
               ...
    
               ExpansionTile(
                              title: Container(
                                  width: double.infinity,
    
                                  child: Text("Parametre vitaux",
                                    style: TextStyle(fontSize: 18),)),
                              trailing: Icon(Icons.arrow_drop_down, size: 32,
                                color: Colors.black,),
                              onExpansionChanged: (value) {
                                setState(() {
                                  // isExpand=value;
                                });
                              },
    
                              children: [
                                listmesures()
    
                              ]
                          )
    }

      Widget listmesures() {
        return Container(child:
        ListView(
          shrinkWrap: true,
          scrollDirection: Axis.vertical,
    
          children: [
            TextFormField(
              keyboardType: TextInputType.phone,
              focusNode: f2,
              controller: _poidsController,
              style: GoogleFonts.lato(
                  fontSize: 18, fontWeight: FontWeight.bold),
              decoration: InputDecoration(
                contentPadding:
                EdgeInsets.only(left: 20, top: 10, bottom: 10),
                border: OutlineInputBorder(
                  borderRadius:
                  BorderRadius.all(Radius.circular(90.0)),
                  borderSide: BorderSide.none,
                ),
                filled: true,
                fillColor: Colors.grey[350],
                hintText: 'Poids Kg*',
                hintStyle: GoogleFonts.lato(
                  color: Colors.black26,
                  fontSize: 18,
                  fontWeight: FontWeight.w800,
                ),
              ),
              validator: (value) {
                if (value.isEmpty) {
                  return 'entrez poids';
                }
                return null;
              },
              onFieldSubmitted: (String value) {
                f2.unfocus();
                FocusScope.of(context).requestFocus(f3);
              },
              textInputAction: TextInputAction.next,
            ),
    
            SizedBox(
              height: 10,
            ),
    
            TextFormField(
              keyboardType: TextInputType.phone,
              focusNode: f2,
              controller: _tempController,
              style: GoogleFonts.lato(
                  fontSize: 18, fontWeight: FontWeight.bold),
              decoration: InputDecoration(
                contentPadding:
                EdgeInsets.only(left: 20, top: 10, bottom: 10),
                border: OutlineInputBorder(
                  borderRadius:
                  BorderRadius.all(Radius.circular(90.0)),
                  borderSide: BorderSide.none,
                ),
                filled: true,
                fillColor: Colors.grey[350],
                hintText: 'Temperature*',
                hintStyle: GoogleFonts.lato(
                  color: Colors.black26,
                  fontSize: 18,
                  fontWeight: FontWeight.w800,
                ),
              ),
              validator: (value) {
                if (value.isEmpty) {
                  return 'entrez temperature';
                }
                return null;
              },
              onFieldSubmitted: (String value) {
                f2.unfocus();
                FocusScope.of(context).requestFocus(f3);
              },
              textInputAction: TextInputAction.next,
            ),
           .....
    
          ],
        ));
      }

ExpansionTile:这是一个简单实用的小部件。此小部件可让您创建具有类似于 ListTile 功能的折叠或展开视图。它就像一个 ListTile,会在点击标题时展开。

TextEditingController : 将 TextEditingController 连接到文本字段。

我已经使用不同的 focusNode 解决了。