我是 Flutter+Dart 的新手,并试图增加字体大小,但很难理解文档 + 实现我的工作。这是文件。我该如何解决我的问题?
import 'package:flutter/material.dart';
void main() => runApp(NewApp());
class NewApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new MaterialApp(
home: new Scaffold(
appBar: new AppBar(
title: new Text('App Header'),
),
body: new Column(
children: [
new Container(
margin: new EdgeInsets.all(10.0),
child: new Card(
child: new Column(
children: <Widget>[
new Container(
padding: new EdgeInsets.all(10.0),
child: new Text('Hello Macaw'),
),
],
),
),
)
],
),
),
);
}
}
Run Code Online (Sandbox Code Playgroud)
小智 12
一开始,这很难理解和实施。但是一旦你理解了,你就会爱上 Flutter 框架。这是解决方案:
new Text('Hello Macaw',style: TextStyle(fontSize: 16.0, fontWeight: FontWeight.bold),),
Run Code Online (Sandbox Code Playgroud)
之后,格式化代码。就是这样。让我知道它是否有效。
您可以使用 的style
属性Text
来更改 的某些属性Text
。
例子:
Text(
"Your text",
style: TextStyle(
fontSize: 20.0,
color: Colors.red,
fontWeight: FontWeight.w600,
),
)
Run Code Online (Sandbox Code Playgroud)
使用预定义style
为Text
您提供标准fontSize
和fontWeight
为Text
.
你可以像这样使用它们
style: Theme.of(context).textTheme.XYZ
Run Code Online (Sandbox Code Playgroud)
XYZ
可以是body1
,body2
,title
,subhead
,headline
等。
归档时间: |
|
查看次数: |
11069 次 |
最近记录: |