簡體   English   中英

Flutter ReorderableListView - 拖動 拖動時靈活項會增長到屏幕大小

[英]Flutter ReorderableListView - dragged Flexible item grows to screen size when dragged

我有一個使用 ReorderableListView 的應用程序,但我有一個包含它自己的列表視圖的項目,當我拖動它時,它的高度會增長到屏幕高度。 過渡完成后,項目將恢復到其原始大小。 未拖動時的外觀:在此處輸入圖像描述

與拖動時的外觀(項目增長到屏幕大小):在此處輸入圖像描述

這是項目小部件:

  Widget build(BuildContext context) {
return Container(
  height: null,
  child: Row(
    mainAxisSize: MainAxisSize.max,
    children: <Widget>[
      Flexible(
        child: Column(
          children: <Widget>[
            SizedBox(
              height: 10,
            ),
            Row(
              children: <Widget>[
                Expanded(
                  child: Container(
                    child: Directionality(
                      textDirection: TextDirection.rtl,
                      child: Theme(
                        data: new ThemeData(
                          primaryColor: Colors.black,
                          primaryColorDark: Colors.black,
                        ),
                        child: TextField(
                          style: TextStyle(
                            height: 1,
                          ),
                          decoration: new InputDecoration(
                            labelText: "רשומה חדשה",
                            fillColor: Colors.white,
                            border: new OutlineInputBorder(
                              borderRadius: new BorderRadius.circular(25.0),
                              borderSide: new BorderSide(
                                  color: Colors.black
                                      ,width: 1
                              ),
                            ),
                            //fillColor: Colors.green
                          ),
                          focusNode: _mainFocusNode,
                          controller: _textController,
                          keyboardType: TextInputType.multiline,
                          maxLines: null,
                        ),
                      ),
                    ),
                  ),
                ),
                Container(
                  width: 40,
                  child: InkWell(
                    child: IconButton(
                      onPressed: () {
                        setState(() {
                          if (_textController.text.length > 0) {
                            _rows.add(_textController.text);
                            listHolderManager.updateValue(0);
                            _textController.text = "";
                            _counter += 1;
                          }
                        });
                      },
                      icon: new Icon(MaterialIcons.add_circle),
                    ),
                  ),
                )
              ],
            ),
            SizedBox(
              height: 10,
            ),
            Container(
                decoration: BoxDecoration(
                    border: Border.all(
                  color: Colors.black,
                )),
                child: _buildStringsList())
          ],
        ),
      ),
    ],
  ),
);

}

我知道為什么 Flexible(我也嘗試過 Expanded 代替它)會導致它,但我不知道另一種解決方案,謝謝!

ListView正在嘗試使用所有可用空間。 將其包裝在Container中並將height傳遞給容器構造函數。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM