这是代码:(请回复我似乎找不到的错误
import 'package:flutter/material.dart';
void main() => runApp(MaterialApp(
home: Scaffold(
appBar: AppBar(
title: Text('MyApp'),
centerTitle: true,
backgroundColor: Colors.cyan[300],
),
body: Center(
child: Text(
'This is MyApp',
style: TextStyle(
fontSize: 20.0,
fontWeight: FontWeight.bold,
letterSpacing: 2.0,
color: Colors.blueGrey,
fontFamily:
),
),
),
floatingActionButton: FloatingActionButton(
onPressed: () {},
child: Text(' CLICK!'),
backgroundColor: Colors.cyan[300],
),
),
));
答案 0 :(得分:0)
您忘记添加字体系列值。
示例:fontFamily: 'Raleway'
更新代码
import 'package:flutter/material.dart';
void main() => runApp(MaterialApp(
home: Scaffold(
appBar: AppBar(
title: Text('MyApp'),
centerTitle: true,
backgroundColor: Colors.cyan[300],
),
body: Center(
child: Text(
'This is MyApp',
style: TextStyle(
fontSize: 20.0,
fontWeight: FontWeight.bold,
letterSpacing: 2.0,
color: Colors.blueGrey,
fontFamily: 'Raleway',
),
),
),
floatingActionButton: FloatingActionButton(
onPressed: () {},
child: Text(' CLICK!'),
backgroundColor: Colors.cyan[300],
),
),
));
答案 1 :(得分:0)
您尚未定义 fontFamily 值。 您必须先导入字体,然后才能定义它。 用于设置自定义字体。
按照以下步骤添加自定义字体 - https://flutter.dev/docs/cookbook/design/fonts
并且请让您的代码看起来干净简单,或者像这样发布。