flutter - Flutter - 底部工作表如何将文本字段移动到底部
问题描述
我希望 TextField 显示在屏幕底部。
return Column(
children: [
const _Title(),
Stack(
children: [
ListView(
shrinkWrap: true,
children: const [
_Message(),
],
),
const TextField(
decoration: InputDecoration(
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(
color: Colors.grey,
),
),
border: OutlineInputBorder(),
hintText: 'Enter a search term',
),
),
],
),
],
如果我将 Wrap 我的 Textfield Widget 放在位置 bottom:0 我会得到一个 hasSize 错误。
解决方案
Stack
首先,用一个小部件包装Expanded
它,以便它占据整个垂直可用空间。
然后,用 a 包裹TextField
a Positioned
,除了设置bottom
为零之外,您还需要将left
and设置为right
您想要的任何值。
return Column(
children: [
const _Title(),
Expanded(
child: Stack(
children: [
ListView(
shrinkWrap: true,
children: const [
_Message(),
],
),
Positioned(
bottom: 0,
left: 0,
right: 0,
child: const TextField(
decoration: InputDecoration(
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(
color: Colors.grey,
),
),
border: OutlineInputBorder(),
hintText: 'Enter a search term',
),
),
),
],
),
),
],
);
推荐阅读
- c# - System.TypeLoadException:asp.net 核心中的“Microsoft.AspNetCore.Mvc.Razor.Internal.FileProviderRazorProjectFileSystem”类型中的“方法“GetItem”
- linux - 使用管道和awk编写单行程序
- amazon-web-services - 使用多个 ingress-nginx 控制器时,入口资源从错误的入口控制器获取地址
- sql - 自联接表并将两个查询中的联接列包含为单列
- amazon - 亚马逊MWS中的暂存器的日期范围报告,用于使用自定义交易类型的每日订单报告?
- android - Ionic android 发布(已签名)APK 无法正常工作
- java - 从0到10的20个随机数数组。如何计算其中的特定数字?
- python - 概率分布导致“进程以退出代码 137 完成(被信号 9:SIGKILL 中断)”
- php - 如何访问配置 php 值(多维数组)到 PHP 中的类函数
- charts - Google Charts-如何在折线图中更改正负轴值的线条颜色