flutter - 如何在颤动中将文本字段内的文本与底部对齐?
问题描述
所以我想把里面的文字放在TextField
最底部。
import 'package:flutter/material.dart';
void main() => runApp(const Home());
class Home extends StatelessWidget {
const Home({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: Center(
child: TextField(
textAlignVertical: TextAlignVertical(y: -0.0),
decoration: InputDecoration(filled: true)
),
),
),
);
}
}
我尝试使用textAlignVertical
但它不起作用。
解决方案
尝试添加contentPadding
:
import 'package:flutter/material.dart';
void main() => runApp(const Home());
class Home extends StatelessWidget {
const Home({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: Center(
child: TextField(
textAlignVertical: TextAlignVertical(y: -0.0),
decoration: InputDecoration(
filled: true,
contentPadding: EdgeInsets.only(bottom: 0.0), //here
),
),
),
),
);
}
}
推荐阅读
- ios - pushViewController 仅在 iPad 上不起作用
- sql-server - Oracle dbms_xplan.Display() 等效于 SQL Server 2017
- arrays - 索引匹配多个条件和多行谷歌表
- python - Django Rest Framework PUT 请求返回 500,但更新数据
- javascript - 鼠标悬停时如何使用 DOM 更改可见性 css 属性
- html - 是否可以让我的列式 div 框响应使用 css 的小型设备?或者我可以使用引导程序吗?
- angular - 错误:- StaticInjectorError(AppModule) - ngx-bootstrap-product-tour
- javascript - 为什么我的 SVG 图像在 chrome 上完美显示,但是当我在 iPhone 上打开它时,它根本不显示?
- jquery - Chrome 扩展:$.ajax 不是函数
- css - 使用宽度过渡时如何防止 Chrome 闪烁?