【问题标题】:I'm new to flutter and I want to add another text, How can I do it?我是 flutter 的新手,我想添加另一个文本,我该怎么做?
【发布时间】:2023-02-03 02:15:03
【问题描述】:
class MyApp extends StatelessWidget {
  const MyApp({super.key});
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: ThemeData(
        primarySwatch: Colors.lightBlue,
        scaffoldBackgroundColor: const Color(0xFFb4c8ea),
      ),
      home: const MyText(),
    );
  }
}

class MyText extends StatelessWidget {
  const MyText({super.key});
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: Text(
          "RAYCAN",
          style: new TextStyle(
            color: const Color(0xFF69418b),
            height: -2,
            fontStyle: FontStyle.normal,
            fontWeight: FontWeight.bold,
            fontSize: 58,
            letterSpacing: 2,
            wordSpacing: 1,
            fontFamily: "LilitaOne",
          ),
        ),
      ),
    );
  }
}

我尝试了很多东西但似乎没有用,也许我应该改变一些东西但我不知道我在做什么。我应该怎么做?感谢您的帮助

【问题讨论】:

    标签: flutter dart


    【解决方案1】:

    您可以像这样使用列或行小部件,而不是直接使用文本:

    return Scaffold(
      body: Center(
        child:Column(
        children:[
          Text(
          "RAYCAN",
          style: new TextStyle(
            color: const Color(0xFF69418b),
            height: -2,
            fontStyle: FontStyle.normal,
            fontWeight: FontWeight.bold,
            fontSize: 58,
            letterSpacing: 2,
            wordSpacing: 1,
            fontFamily: "LilitaOne",
          ),
        ),
         Text(
          "RAYCAN",
          style: new TextStyle(
            color: const Color(0xFF69418b),
            height: -2,
            fontStyle: FontStyle.normal,
            fontWeight: FontWeight.bold,
            fontSize: 58,
            letterSpacing: 2,
            wordSpacing: 1,
            fontFamily: "LilitaOne",
          ),
        ),
      
     ],)
      ),
    );
    

    【讨论】:

      猜你喜欢
      • 2022-12-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-01-22
      • 1970-01-01
      • 2022-11-17
      • 2020-09-16
      • 2019-08-25
      相关资源
      最近更新 更多