Flutter中文本的黄色下划线的路由原因是什么

时间:2019-06-24 03:19:01

标签: flutter dart flutter-dependencies

我是Flutter的新手。我正在准备登录页面。同样,我正在使用“文本”小部件。为此,我得到了黄色双下划线。

我正在尝试使用脚手架作为路线布局

return new Scaffold(
  body: Container(
    decoration: BoxDecoration(
      image: DecorationImage(
        image: AssetImage("assets/images/bg.png"),
        fit: BoxFit.cover,
      ),
    ),
    child: MaterialApp(
      home: SingleChildScrollView(
        child:Text('Test')
      ),
    ),
  ),
);

Here is my Screenshot

2 个答案:

答案 0 :(得分:0)

只需更改Scaffold的父级,MaterialApp应该是所有小部件树的父级。

  return MaterialApp(
      home: Scaffold(
        body: Container(
          decoration: BoxDecoration(
            image: DecorationImage(
              image: AssetImage("assets/images/bg.png"),
              fit: BoxFit.cover,
            ),
          ),
          child: SingleChildScrollView(child: Text('Test')),
        ),
      ),
    );

答案 1 :(得分:0)

    Remove all other only use text   

 return new Scaffold(
          body: Container(
            decoration: BoxDecoration(
              image: DecorationImage(
                image: AssetImage("assets/images/bg.png"),
                fit: BoxFit.cover,
              ),
            ),
            child: new Text(
                     "your text",
                      maxLines: 3,
                      style: TextStyle(
                        fontWeight: FontWeight.bold,
                        fontSize: 18,
                      ),
                    ),;
          ),
        );