flutter - 去除颤动的TextField标签文本背景颜色
问题描述
代码
Widget searchButton() {
return TextField(
decoration: InputDecoration(
labelText: "Arama",
hintText: "Ara",
labelStyle: TextStyle(color: Colors.yellow,backgroundColor: Colors.red),
hintStyle: Theme.of(context).textTheme.button,
),
);
}
我想完全去除这张图片中的背景颜色(红色)(我不是说透明的)
解决方案
您不想要红色,您可以轻松地将其从标签样式中删除,labelStyle: TextStyle(color: Colors.yellow, backgroundColor: Colors.red),只需删除这一行中的背景颜色:Colors.red 。
在我的代码中,我在 Text 后面没有任何 trasprated 框,这是我的代码:
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({Key? key}) : super(key: key);
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
Widget searchButton() {
return TextField(
decoration: InputDecoration(
labelText: "Arama",
hintText: "Ara",
labelStyle:
TextStyle(color: Colors.yellow),
hintStyle: Theme.of(context).textTheme.button,
),
);
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(),
body: Container(child: searchButton()),
),
);
}
}
推荐阅读
- kotlin - 我如何才能发现configurations.default.collect 在Gradle 中的含义?
- type-conversion - 在 VHDL 中将无符号组件实现到 ALU 的条件时出现问题
- python - 使用 SQL 中的 Python List 作为参数
- python - Python - 返回一个函数对象是什么意思?
- regex - VBA 正则表达式匹配电子邮件
- java - 为什么 While 循环后的布尔变量仍然为真?
- ms-access - 带有条件的 MS Access 交叉表查询
- react-native - 在 componentDidUpdate 中更新状态会导致无限循环
- scala - akka ActorSystem 进程如何从actor接收
- .net-core - Azure Pipelines 上的 VsTest 任务仅运行两种测试方法中的一种?