支架内步进视图小部件中的底部像素溢出

时间:2019-01-07 06:13:39

标签: dart flutter

我有一个包含Stepper小部件的Flutter应用。我的步进器包裹着Scaffold。在我的步进器中,包含Column和两个TextFormField

每当我触摸TextFormField中的输入文本字段时,键盘就会显示警告/错误底部像素溢出11个像素。

我已经尝试在页面resizeToAvoidBottomPadding: false的脚手架上添加root.dart。它确实消除了由11个像素的警告/错误溢出的底部像素。但是我的“ BottomAppNavigation”却消失了,就像这样:

https://i.imgur.com/io5lHwJ.png

还已经在页面singleChildScrollView的脚手架上添加了root.dart,但出现了错误:

I/flutter (21466): The following RenderObject was being processed when the exception was fired:
I/flutter (21466):   RenderStack#d0145 relayoutBoundary=up16 NEEDS-LAYOUT NEEDS-PAINT

Root.dart

return Scaffold(
        body: PageView(
          children: [
            HomePage(
                userId: _userId,
                auth: widget.auth,
                onSignedOut: _onSignedOut),
            MyStepper(),
            Account("Account screen"),
          ],
          onPageChanged: onPageChanged,
          controller: _pageController,
 ),

MyStepper()正在调用其他dart文件。这是MyStepper()页面代码:

MyStepper.dart

Widget build(BuildContext context) {
return MaterialApp(
  theme: ThemeData(
    primarySwatch: Colors.lightGreen,
  ),
  title: 'App',
  home: Scaffold(
      appBar: AppBar(title: Text('Add Device')),
      body: Stack(
        children: <Widget>[
          _myStepper(),
          Align(
            alignment: Alignment.bottomCenter,
            child: _buttonBottomBar(),
          )
        ],
      )),
);
}

Widget _myStepper() {
return Stepper(
  type: StepperType.horizontal,
  currentStep: _currentStep,
  onStepTapped: (int step) => setState(() => _currentStep = step),
  controlsBuilder: _createEventControlBuilder,
  onStepContinue:
      _currentStep < 2 ? () => setState(() => _currentStep += 1) : null,
  onStepCancel:
      _currentStep > 0 ? () => setState(() => _currentStep -= 1) : null,
  steps: <Step>[
    Step(
      title: Text('Connect'),
      content:
          _stepOne(),
      isActive: _currentStep >= 0,
      state: _currentStep >= 0 ? StepState.complete : StepState.disabled,
    ),
  ],
);
}

Widget _stepOne() {
return Column(
      children: <Widget>[
        TextFormField(
          onSaved: (String value) {
            data.ssid = value;
          },
          maxLines: 1,
          validator: (value) {
            if (value.isEmpty || value.length < 1) {
              return 'SSID!';
            }
          },
          decoration: InputDecoration(
              labelText: 'enter SSID',
              hintText: 'enter SSID',
              icon: const Icon(Icons.wifi),
              labelStyle:
              TextStyle(decorationStyle: TextDecorationStyle.solid)),
        ),
        TextFormField(
          onSaved: (String value) {
            data.password = value;
          },
          maxLines: 1,
          validator: (value) {
            if (value.isEmpty || value.length < 1) {
              return 'password SSID!';
            }
          },
          decoration: InputDecoration(
              labelText: 'pass SSID',
              hintText: 'pass SSID',
              icon: const Icon(Icons.signal_wifi_4_bar_lock),
              labelStyle:
              TextStyle(decorationStyle: TextDecorationStyle.solid)),
        ),
      ],
);
}

0 个答案:

没有答案