简体   繁体   English

当我将 TextFormField 放入 PageView 时,颤动避免调整屏幕大小

[英]Flutter avoiding resize screen when i have TextFormField into PageView

in this simplified code i have two TextFormField into one of flutter PageView pages, that they are into another class which that extended from Container , not any Scaffold , now when i click into one of this TextFormFields , resizeToAvoidBottom* don't work in my code在这个简化的代码中,我有两个TextFormField到一个 flutter PageView页面中,它们是从Container扩展的另一个类,而不是任何Scaffold ,现在当我点击这个TextFormFields ,resizeToAvoidBottom* 在我的代码中不起作用

  Widget build(BuildContext context) {
    return Consumer<ThemeManager>(builder: (context, theme, child) {
      return Directionality(
        textDirection: TextDirection.rtl,
        child: Scaffold(
          key: _scaffoldKey,
          backgroundColor: theme.accentColor,
          resizeToAvoidBottomPadding: false,
          resizeToAvoidBottomInset: false,
          body: NotificationListener<OverscrollIndicatorNotification>(
            onNotification: (overScroll) {
              overScroll.disallowGlow();
              return false;
            },
            child: Container(
              width: double.infinity,
              height: double.infinity,
              child: IntrinsicHeight(
                child: Stack(
                  children: <Widget>[
                    Container(
                      width: MediaQuery.of(context).size.width,
                      height: MediaQuery.of(context).size.height - 50,
                      child: Column(
                        mainAxisSize: MainAxisSize.max,
                        children: <Widget>[
                          BuildLoginHeaderScreen(theme: theme),
                          Expanded(
                            child: PageView(
                              controller: _pageController,
                              children: <Widget>[
                                ... // contains two TextFormFields
                              ],
                            ),
                          ),
                        ],
                      ),
                    ),
                  ],
                ),
              ),
            ),
          ),
        ),
      );
    });
  }

You can go around using resizeToAvoidBottomPadding by wrapping appropriate part of your code with SingleChildScrollView .您可以使用到处resizeToAvoidBottomPadding通过包装你的代码的适当部分SingleChildScrollView For example例如

child: SingleChildScrollView( 
      child: Column(
               mainAxisSize: MainAxisSize.max,
               children: <Widget>[
                    BuildLoginHeaderScreen(theme: theme),
                    Expanded(
                        child: PageView(
                             controller: _pageController,
                             children: <Widget>[
                                ... // contains two TextFormFields
                              ],
                            ),
                     ),
              ],
      ),

),

This will prevent pixel overflow when the keyboard reduces the view area.当键盘缩小视图区域时,这将防止像素溢出。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Flutter TextFormField 聚焦时重新加载当前屏幕 - Flutter TextFormField reloads current screen when focused 将 Form 与 TextFormField 一起使用时颤动空白屏幕 - Flutter blank screen when using Form with TextFormField Flutter TextFormField onSaved在屏幕上不可见时不调用 - Flutter TextFormField onSaved no called when not visible on screen 当 TextField 或 TextFormField 获得焦点时,在 flutter 中将屏幕底部推到键盘顶部 - Push screen bottom on top of keyboard in flutter when TextField or TextFormField is focused 刷新页面浏览量颤动中的屏幕时如何返回上一页 - how to go back to previous page when refresh the screen in pageview flutter Flutter 在带有 GoogleMaps 屏幕的 PageView 上出现错误 - Flutter error on a PageView with GoogleMaps Screen 将颤动的 PageView 与屏幕左侧对齐 - Align a flutter PageView to the screen left Flutter :(如何)我能否拥有每个都依赖于Provider的小部件的PageView? - Flutter: (How) Can I have a PageView of widgets that each rely on Provider? 在 Flutter 中调整 TextFormField 的 prefixIcon 的大小(高度和宽度)不起作用 - Resize (height and width) of an prefixIcon of TextFormField in Flutter is not working Flutter PageView 子项在我使用 PageView -&gt; ListView | 时一起滚动 SingleChildScrollView - Flutter PageView children scrolled together when i am using PageView -> ListView | SingleChildScrollVIew
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM