简体   繁体   English

Flutter 文字黄色下划线

[英]Flutter text yellow underline

Can anybody know what's wrong with my code cause im getting a yellow underline text.任何人都可以知道我的代码有什么问题导致我收到黄色下划线文本。 enter image description here Here is my code:在此处输入图片描述这是我的代码:

 Widget build(BuildContext context) {
    return Scaffold(
      body: Container(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            Padding(
                padding: EdgeInsetsDirectional.fromSTEB(10, 100, 10, 460),
                child: RichText(
                  text: TextSpan(
                      style: DefaultTextStyle.of(context).style,
                      children: [
                        TextSpan(
                            text: "asdad",
                            style:
                                TextStyle(color: Colors.black.withOpacity(0.6)))
                      ]),
                )),
            const TextField(
              decoration: InputDecoration(
                  hintText: 'What s your name?', border: OutlineInputBorder()),
            ),
          ],
        ),
      ),
    );
  }

I've tried to wrap with MaterialApp, not working我试过用 MaterialApp 包装,但没有用

You need to have a MaterialApp and you should not have everything in only one widget like this.你需要有一个 MaterialApp,你不应该像这样只在一个小部件中拥有所有东西。

DefaultTextStyle.of(context).style is not able to reach the MaterialApp to get the default text style. DefaultTextStyle.of(context).style 无法到达 MaterialApp 以获取默认文本样式。 It has to be in another widget class (or a Builder widget) so that the context lets you reach the MaterialApp.它必须在另一个小部件 class(或 Builder 小部件)中,以便上下文可以让您到达 MaterialApp。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM