【问题标题】:what is the route cause of Yellow underline for the Text in FlutterFlutter中文本黄色下划线的路由原因是什么
【发布时间】:2019-11-05 20:11:30
【问题描述】:

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

我正在尝试使用 Scaffold 作为路线布局进行修复

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')
      ),
    ),
  ),
);

【问题讨论】:

标签: flutter dart flutter-dependencies


【解决方案1】:

只需更改 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')),
        ),
      ),
    );

【讨论】:

    【解决方案2】:
        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,
                          ),
                        ),;
              ),
            );
    

    【讨论】:

      猜你喜欢
      • 2022-11-30
      • 2021-11-30
      • 2020-06-04
      • 2021-04-17
      • 1970-01-01
      • 2018-04-17
      • 1970-01-01
      • 1970-01-01
      • 2021-02-14
      相关资源
      最近更新 更多