当我尝试在TextField中键入时,Flutter避免扩展布局

时间:2019-05-25 13:05:45

标签: flutter flutter-layout

在扑通实现的简单布局中,我有一个简单的形式,它是父小部件的子代。在这种情况下,当我尝试键入TextField的页面时,将页面大小调整为最小屏幕大小,而我想避免这种情况

enter image description here

resizeToAvoidBottomPadding: false,无效

Logcat:

The specific RenderFlex in question is: RenderFlex#864a2 relayoutBoundary=up2 OVERFLOWING:
  needs compositing
  creator: Column ← DecoratedBox ← Container ← Directionality ← MediaQuery ←
    LayoutId-[<_ScaffoldSlot.body>] ← CustomMultiChildLayout ← AnimatedBuilder ← DefaultTextStyle ←
    AnimatedDefaultTextStyle ← _InkFeatures-[GlobalKey#9a5c5 ink renderer] ←
    NotificationListener<LayoutChangedNotification> ← ⋯
  parentData: <none> (can use size)
  constraints: BoxConstraints(0.0<=w<=298.0, 0.0<=h<=123.1)
  size: Size(298.0, 123.1)
  direction: vertical
  mainAxisAlignment: start
  mainAxisSize: max
  crossAxisAlignment: start
  textDirection: rtl
  verticalDirection: down

我的代码:

return Form(
  key: _formKey,
  child: Container(
    margin: EdgeInsets.fromLTRB(12.0, 5.0, 12.0, 0.0),
    child: Card(
      color: Colors.indigo[400],
      child: Padding(
        padding: const EdgeInsets.fromLTRB(15.0, 0.0, 15.0, 15.0),
        child: Scaffold(
          resizeToAvoidBottomPadding: false,
          body: Directionality(
            textDirection: TextDirection.rtl,
            child: Container(
                color: Colors.indigo[400],
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: <Widget>[
                    Padding(
                      padding:
                          const EdgeInsets.fromLTRB(8.0, 20.0, 8.0, 8.0),
                      child: Center(
                          child: Text(
                        Strings.pleaseFillYourInformation,
                        style: TextStyle(
                          fontFamily: 'IranSansBold',
                          fontSize: 14.0,
                          color: Colors.white,
                        ),
                      )),
                    ),
                    Divider(
                      color: Colors.white.withOpacity(0.5),
                    ),
                    SingleChildScrollView(
                      child: Column(
                        crossAxisAlignment: CrossAxisAlignment.start,
                        children: <Widget>[
                          Padding(
                            padding: const EdgeInsets.fromLTRB(
                                8.0, 8.0, 2.0, 8.0),
                            child: Text(
                              Strings.youName + Strings.inputRequired
                            ),
                          ),
                          TextFormField(
                            keyboardType: TextInputType.text,
                            controller: nameAndFamilyController,
                            maxLines: 1,
                            decoration: InputDecoration(
                                contentPadding: EdgeInsets.all(10.0),
                                hintText:
                                    Strings.pleaseEnterYourNameAndFamily,
                                border: OutlineInputBorder(
                                  borderRadius: BorderRadius.all(
                                      Radius.circular(5.0)),
                                )),
                          ),
                        ],
                      ),
                    ),
                  ],
                )),
          ),
        ),
      ),
    ),
  ),
);

0 个答案:

没有答案