Flutter无法在文本中使用Google字体
当我尝试使用Google_fonts时,我会收到这样的错误。我还导入了库,并将“ google_fonts: ^3.0.1”添加到“ pub.yml”文件中。 。
“我添加了 =“控制台错误映像”>
void main() {
runApp(BenimUyg());
}
class BenimUyg extends StatelessWidget {
const BenimUyg({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold(
backgroundColor: Colors.brown[300],
body: SafeArea(
child: Center(
child: Column(
mainAxisSize: MainAxisSize.min,
children: const <Widget>[
CircleAvatar(
backgroundColor: Colors.lime,
backgroundImage: AssetImage("assets/images/kahve.jpg"),
radius: 70,
),
Text(
"Flutter Kahvecisi",
style: TextStyle(
fontSize: 40,
fontFamily: "Courgette",
color: Colors.brown,
),
),
// ignore: unnecessary_const
Text(
"Çok Yakındasınız",
style: GoogleFonts.pacifico(
textStyle: TextStyle(
color: Colors.lime,
),
),
),
],
),
),
),
),
);
}
}
When I try to use google_fonts I get an error like this. I also imported the library and added " google_fonts: ^3.0.1" to the "pub.yml" file.
" I added.
void main() {
runApp(BenimUyg());
}
class BenimUyg extends StatelessWidget {
const BenimUyg({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold(
backgroundColor: Colors.brown[300],
body: SafeArea(
child: Center(
child: Column(
mainAxisSize: MainAxisSize.min,
children: const <Widget>[
CircleAvatar(
backgroundColor: Colors.lime,
backgroundImage: AssetImage("assets/images/kahve.jpg"),
radius: 70,
),
Text(
"Flutter Kahvecisi",
style: TextStyle(
fontSize: 40,
fontFamily: "Courgette",
color: Colors.brown,
),
),
// ignore: unnecessary_const
Text(
"Çok Yakındasınız",
style: GoogleFonts.pacifico(
textStyle: TextStyle(
color: Colors.lime,
),
),
),
],
),
),
),
),
);
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
该问题来自
儿童:const&lt; widget&gt; [
删除const
。The issue is coming from
children: const <Widget>[
removeconst
.