flutter - 如何在不弄乱实际布局顺序的情况下使用 ScrollView?
问题描述
我正在制作一个登录屏幕,据我所知,我需要使用SingleChildScrollView以防止在 TextFields 聚焦时出现“黄色条纹”问题。
每当我添加SingleChildScrollView时,也许我会丢失任何类型的小部件对齐,因为 MainAxisAlignment 不再起作用:
SignleChildScrollView的外观如何:SingleChildScrollView 的屏幕截图
它应该是什么样子:没有 SingleChildScrollView 的屏幕截图
我什么都试过了,但就是想不通。
body: SafeArea(
child: SingleChildScrollView(
child: Column(
mainAxisAlignment: MainAxisAlignment.end,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Container(
padding: EdgeInsets.only(bottom: 50),
child: TypeScript(textTypeScript: tsLogin),
),
Container(
width: MediaQuery.of(context).size.width / 1.2,
child: Column(
children: [
emailField,
SizedBox(height: 20),
passwordField,
Container(
height: 80,
padding: EdgeInsets.only(top: 10),
alignment: Alignment.topRight,
//child: passwordRecovery,
),
Container(
child: loginButton,
),
SizedBox(
height: 52,
width: MediaQuery.of(context).size.height; / 2,
child: orStripe,
),
Container(
padding: EdgeInsets.only(bottom: 10),
child: signButton,
),
],
),
),
],
),
),
),
);
}
}
解决方案
尝试将 SingleChildscrollview 替换为以下内容:
CustomScrollView(
slivers[
SliverFillRemaining(
hasScrollBody: false,
child: YourChildWidget(),
),
),
)
推荐阅读
- google-cloud-platform - Google Data Studio - 在 GCP 审核日志中跟踪查看者凭据
- php - PHP Laravel 基于条件的交替推送
- typescript - 用于访问可能尚未创建的动态键:值对的正确 Typescript 语法
- blackhole - 由二元致密物体系统产生的引力波的自旋加权球谐函数
- javascript - babel-plugin-proposal-decorators 不工作
- r - 是否有多种 POSIXct 日期格式,如果有,如何在 R 中将一种 POSIXct 日期格式转换为另一种 POSIXct 日期格式?
- swift - Swift NSSecureCoding 在展开时意外发现 nil
- leaflet - 传单 - onEachFeature 未显示来自维基媒体的图像
- c++ - 模板中std::array的大小是如何计算的
- python - 如何将数据框扩展到更大的数据框?