Использование SingleChildScrollview внутри содержимого виджета Column не прокручивается - PullRequest
0 голосов
/ 08 января 2020
Widget build(BuildContext context) {
    return Scaffold(
      resizeToAvoidBottomInset: false,
      backgroundColor: Colors.white,
      body: Container(
        child: Column(
          children: <Widget>[
            Stack(
              fit: StackFit.loose,
              children: <Widget>[
                HeadersVC(),
                Container(
                  margin: EdgeInsets.only(top: 40.0),
                  child: Row(
                    mainAxisAlignment: MainAxisAlignment.start,
                    crossAxisAlignment: CrossAxisAlignment.center,
                    children: <Widget>[
                      FlatButton(
                        splashColor: Colors.transparent,
                        highlightColor: Colors.transparent,
                        onPressed: () {
                          Navigator.pop(context);
                        },
                        child: Icon(
                          Icons.arrow_back,
                          size: 30,
                          color: Colors.white,
                        ),
                      ),
                      Text(
                        widget.headertitleladderPre,
                        style: TextStyle(
                            fontSize: 22.0,
                            color: Colors.white,
                            fontWeight: FontWeight.bold),
                      ),
                    ],
                  ),
                )
              ],
            ),
            SingleChildScrollView(
              padding: EdgeInsets.only(top: 20.0, left: 30.0, right: 30.0),
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.stretch,
                children: <Widget>[
                  Padding(
                    padding: EdgeInsets.only(top: 10.0),
                  ),
                  //******************************************** Date Picker  */
                  TextFormField(
                    onTap: () async {
                      FocusScope.of(context).requestFocus(new FocusNode());
                      _selectDate(context);
                    },
                    decoration: InputDecoration(
                        enabledBorder: UnderlineInputBorder(
                            borderSide:
                                BorderSide(color: Colors.black26, width: 1.5)),
                        contentPadding: EdgeInsets.only(left: 0.0, right: 0.0),
                        labelText: formatDate(formatedDate),
                        labelStyle: TextStyle(
                            fontFamily: "Montserrat", color: Colors.black),
                        suffixIcon: new Padding(
                          padding: const EdgeInsets.only(
                              top: 0.0, left: 0.0, right: 0.0, bottom: 0.0),
                          child: SizedBox(
                            height: 15,
                            child: Icon(
                              Icons.calendar_today,
                              color: Colors.red,
                            ),
                          ),
                        )),
                  ),
                  Padding(
                    padding: EdgeInsets.only(left: 0.0, top: 10.0),
                  ),
                  //******************************************** DropDown Button  */
                  Container(
                    child: DropdownButton(
                      underline: Container(
                        height: 1.0,
                        decoration: const BoxDecoration(
                            border: Border(
                                bottom: BorderSide(
                                    color: Colors.black26, width: 1.5))),
                      ),
                      value: _selectedladleno,
                      items: _dropDownladleItems,
                      onChanged: changedDropDownItem,
                      isExpanded: true,
                      isDense: false,
                      icon: Icon(
                        Icons.arrow_drop_down,
                        color: Colors.red,
                      ),
                      iconSize: 30,
                      elevation: 12,
                      style: TextStyle(
                        fontSize: 15,
                      ),
                    ),
                  ),
                  //******************************************** Radio Button  */
                  ButtonBar(
                    alignment: MainAxisAlignment.start,
                    buttonPadding: EdgeInsets.only(left: 0.0),
                    children: <Widget>[
                      Radio(
                        groupValue: _character,
                        onChanged: (SingingCharacter value) {
                          setState(() {
                            _character = value;
                            print(_character);
                          });
                        },
                        value: SingingCharacter.New,
                        activeColor: Colors.red,
                      ),
                      Text(
                        "New",
                        style: TextStyle(fontSize: 13.0),
                      ),
                      Radio(
                        groupValue: _character,
                        onChanged: (SingingCharacter value) {
                          setState(() {
                            _character = value;
                            print(_character);
                          });
                        },
                        value: SingingCharacter.Repair,
                        activeColor: Colors.red,
                      ),
                      Text(
                        "Repair",
                        style: TextStyle(fontSize: 13.0),
                      ),
                      Radio(
                        groupValue: _character,
                        onChanged: (SingingCharacter value) {
                          setState(() {
                            _character = value;
                            print(_character.toString());
                          });
                        },
                        value: SingingCharacter.OnlyMachineChange,
                        activeColor: Colors.red,
                      ),
                      Text(
                        "Machine Change",
                        style: TextStyle(fontSize: 13.0),
                      ),
                    ],
                  ),
                  //******************************************** Machine Number  */
                  TextFormField(
                    decoration: InputDecoration(
                        labelText: "Machine Number *",
                        labelStyle: TextStyle(
                            fontFamily: "Montserrat", color: Colors.black)),
                  ),
                  TextFormField(
                    decoration: InputDecoration(
                        labelText: "Well Block Party *",
                        labelStyle: TextStyle(
                            fontFamily: "Montserrat", color: Colors.black)),
                  ),
                  TextFormField(
                    decoration: InputDecoration(
                        labelText: "Well Block Party *",
                        labelStyle: TextStyle(
                            fontFamily: "Montserrat", color: Colors.black)),
                  ),
                  TextFormField(
                    decoration: InputDecoration(
                        labelText: "Well Block Party *",
                        labelStyle: TextStyle(
                            fontFamily: "Montserrat", color: Colors.black)),
                  ),
                  TextFormField(
                    decoration: InputDecoration(
                        labelText: "Well Block Party *",
                        labelStyle: TextStyle(
                            fontFamily: "Montserrat", color: Colors.black)),
                  ),
                  TextFormField(
                    decoration: InputDecoration(
                        labelText: "Well Block Party *",
                        labelStyle: TextStyle(
                            fontFamily: "Montserrat", color: Colors.black)),
                  ),
                  TextFormField(
                    decoration: InputDecoration(
                        labelText: "Well Block Party *",
                        labelStyle: TextStyle(
                            fontFamily: "Montserrat", color: Colors.black)),
                  ),
                  TextFormField(
                    decoration: InputDecoration(
                        labelText: "Well Block Party *",
                        labelStyle: TextStyle(
                            fontFamily: "Montserrat", color: Colors.black)),
                  ),
                  TextFormField(
                    decoration: InputDecoration(
                        labelText: "Well Block Party *",
                        labelStyle: TextStyle(
                            fontFamily: "Montserrat", color: Colors.black)),
                  ),
                  TextFormField(
                    decoration: InputDecoration(
                        labelText: "Well Block Party *",
                        labelStyle: TextStyle(
                            fontFamily: "Montserrat", color: Colors.black)),
                  )
                ],
              ),
            )
          ],
        ),
      ),
    );
  }

Я получил ошибку как-то так:

Выполнение горячей перезагрузки ... ⣟ трепетание: ══╡ ИСКЛЮЧЕНИЕ ВЫДЕРЖИЛОСЯ ПРИ ПОЛУЧЕНИИ БИБЛИОТЕКИ ╞═════════════ ════════════════════════════════════════════ Флаттер: следующее утверждение было брошенный во время макета: флаттер: RenderFlex переполнен на 158 пикселей внизу. flutter: flutter: соответствующий виджет, вызывающий ошибки, был: flutter: файл столбца: ///Users/baps/Projects/Flutter%20Projects/TRLApp/trlapp/lib/ladlePreheating.dart: 64: 16 flutter: flutter: переполнение RenderFlex имеет ориентацию Axis.vertical. flutter: край переполненного RenderFlex был отмечен при рендеринге желтым и чередующимся черным полосатым узором. Обычно это вызвано тем, что содержимое слишком велико для RenderFlex. Флаттер: рассмотрите возможность применения коэффициента сгибания (например, с помощью виджета «Расширение»), чтобы заставить дочерние элементы флаттера: RenderFlex вписываться в доступное пространство вместо того, чтобы иметь размер в натуральную величину. трепетание: это считается ошибочным условием, поскольку оно указывает на наличие содержимого, которое не может быть трепетать: видно. Если содержимое на законных основаниях превышает доступное пространство, рассмотрите возможность его обрезки с помощью виджета флаттера: ClipRect, прежде чем помещать его в flex, или используйте прокручиваемый контейнер, а не флекс, флаттер: как ListView. flutter: Специфика c RenderFlex, о которой идет речь: AnimatedBuilder ← DefaultTextStyle ← AnimatedDefaultTextStyle ← флаттер: _InkFeatures- [GlobalKey # 9c17 c рендеринг рукописного ввода] ← NotificationListener ← флаттер: PhysicalModel ← ⋯ флаттер: parentData: offset = Offset (0.0, 0.0); id = _ScaffoldSlot.body (можно использовать размер) flutter: constraints: BoxConstraints (0.0 <= w <= 414.0, 0.0 <= h <= 736.0) flutter: size: Size (414.0, 736.0) flutter: направление: вертикальное flutter: mainAxisAlignment : начальный флаттер: mainAxisSize: максимальный флаттер: crossAxisAlignment: центральный флаттер: вертикальный Направление: нисходящий флаттер: ◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢ ◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢ ◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤ трепетание: ═════════════════════════════ ══════════════════════════════════════════════════ ═════════════════════ </p>

Ответы [ 3 ]

0 голосов
/ 08 января 2020

Решение: вам нужно использовать SingleChildScrollView перед столбцом. Если вы хотите сохранить отдельную часть стека, вы можете использовать CustomScrollView. CustomScrollView

  Widget build(BuildContext context) {
return Scaffold(
    resizeToAvoidBottomInset: false,
    backgroundColor: Colors.white,
    body: SingleChildScrollView(
      padding: EdgeInsets.only(top: 20.0, left: 30.0, right: 30.0),
      child: Container(
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.stretch,
          children: <Widget>[
            Stack(
              fit: StackFit.loose,
              children: <Widget>[
                Container(
                  margin: EdgeInsets.only(top: 40.0),
                  child: Row(
                    mainAxisAlignment: MainAxisAlignment.start,
                    crossAxisAlignment: CrossAxisAlignment.center,
                    children: <Widget>[
                      FlatButton(
                        splashColor: Colors.transparent,
                        highlightColor: Colors.transparent,
                        onPressed: () {
                          Navigator.pop(context);
                        },
                        child: Icon(
                          Icons.arrow_back,
                          size: 30,
                          color: Colors.white,
                        ),
                      ),
                      Text(
                        "headertitleladderPre",
                        style: TextStyle(
                            fontSize: 22.0,
                            color: Colors.white,
                            fontWeight: FontWeight.bold),
                      ),
                    ],
                  ),
                )
              ],
            ),
            Padding(
              padding: EdgeInsets.only(top: 10.0),
            ),
            //******************************************** Date Picker  */
            TextFormField(
              onTap: () async {},
              decoration: InputDecoration(
                  enabledBorder: UnderlineInputBorder(
                      borderSide:
                          BorderSide(color: Colors.black26, width: 1.5)),
                  contentPadding: EdgeInsets.only(left: 0.0, right: 0.0),
                  labelText: "formatedDate",
                  labelStyle: TextStyle(
                      fontFamily: "Montserrat", color: Colors.black),
                  suffixIcon: new Padding(
                    padding: const EdgeInsets.only(
                        top: 0.0, left: 0.0, right: 0.0, bottom: 0.0),
                    child: SizedBox(
                      height: 15,
                      child: Icon(
                        Icons.calendar_today,
                        color: Colors.red,
                      ),
                    ),
                  )),
            ),
            Padding(
              padding: EdgeInsets.only(left: 0.0, top: 10.0),
            ),
            //******************************************** DropDown Button  */
            Container(
              child: DropdownButton<String>(
                value: dropdownValue,
                icon: Icon(Icons.arrow_downward),
                iconSize: 24,
                elevation: 16,
                style: TextStyle(color: Colors.deepPurple),
                underline: Container(
                  height: 2,
                  color: Colors.deepPurpleAccent,
                ),
                onChanged: (String newValue) {},
                items: <String>['One', 'Two', 'Free', 'Four']
                    .map<DropdownMenuItem<String>>((String value) {
                  return DropdownMenuItem<String>(
                    value: value,
                    child: Text(value),
                  );
                }).toList(),
              ),
            ),
            //******************************************** Radio Button  */
            ButtonBar(
              alignment: MainAxisAlignment.start,
              buttonPadding: EdgeInsets.only(left: 0.0),
              children: <Widget>[
                Text("Radio Here"),
                Text(
                  "New",
                  style: TextStyle(fontSize: 13.0),
                ),
                Text("One More Radio Here"),
                Text(
                  "Repair",
                  style: TextStyle(fontSize: 13.0),
                ),
                Text("One More Radio Here"),
                Text(
                  "Machine Change",
                  style: TextStyle(fontSize: 13.0),
                ),
              ],
            ),
            //******************************************** Machine Number  */
            TextFormField(
              decoration: InputDecoration(
                  labelText: "Machine Number *",
                  labelStyle: TextStyle(
                      fontFamily: "Montserrat", color: Colors.black)),
            ),
            TextFormField(
              decoration: InputDecoration(
                  labelText: "Well Block Party *",
                  labelStyle: TextStyle(
                      fontFamily: "Montserrat", color: Colors.black)),
            ),
            TextFormField(
              decoration: InputDecoration(
                  labelText: "Well Block Party *",
                  labelStyle: TextStyle(
                      fontFamily: "Montserrat", color: Colors.black)),
            ),
            TextFormField(
              decoration: InputDecoration(
                  labelText: "Well Block Party *",
                  labelStyle: TextStyle(
                      fontFamily: "Montserrat", color: Colors.black)),
            ),
            TextFormField(
              decoration: InputDecoration(
                  labelText: "Well Block Party *",
                  labelStyle: TextStyle(
                      fontFamily: "Montserrat", color: Colors.black)),
            ),
            TextFormField(
              decoration: InputDecoration(
                  labelText: "Well Block Party *",
                  labelStyle: TextStyle(
                      fontFamily: "Montserrat", color: Colors.black)),
            ),
            TextFormField(
              decoration: InputDecoration(
                  labelText: "Well Block Party *",
                  labelStyle: TextStyle(
                      fontFamily: "Montserrat", color: Colors.black)),
            ),
            TextFormField(
              decoration: InputDecoration(
                  labelText: "Well Block Party *",
                  labelStyle: TextStyle(
                      fontFamily: "Montserrat", color: Colors.black)),
            ),
            TextFormField(
              decoration: InputDecoration(
                  labelText: "Well Block Party *",
                  labelStyle: TextStyle(
                      fontFamily: "Montserrat", color: Colors.black)),
            ),
            TextFormField(
              decoration: InputDecoration(
                  labelText: "Well Block Party *",
                  labelStyle: TextStyle(
                      fontFamily: "Montserrat", color: Colors.black)),
            )
          ],
        ),
      ),
    ));

}

0 голосов
/ 08 января 2020

SingleChildScrollView следует обернуть вокруг Column:

Scaffold(
  resizeToAvoidBottomInset: false,
  backgroundColor: Colors.white,
  body: Container(
    child: SingleChildScrollView( // <--- Put it here.
        child: Column( // <--- Your Column.
0 голосов
/ 08 января 2020

Пропущено расширение ScrollView, поскольку контейнер Column не будет знать, сколько места ему нужно занять, и поэтому он вычисляет размер, превышающий размер экрана.

Так что просто поместите Expanded в это:

...
Expanded(
                child: SingleChildScrollView(
                  padding:...

output

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...