1. 程式人生 > 其它 >直播app系統原始碼,在 Flutter 中更改文字的字體系列

直播app系統原始碼,在 Flutter 中更改文字的字體系列

直播app系統原始碼,在 Flutter 中更改文字的字體系列實現的相關程式碼

將資產和字型新增到 pubspec.yaml 檔案中的 flutter 屬性。您可以嚮應用程式新增一種或多種字體系列。在本教程中,我們將新增兩種字型。

flutter:

 uses-material-design: true
assets:
- assets/font/
fonts:
- family: Font1
fonts:
- asset: assets/font/font1.ttf
- family: Font2
fonts:
- asset: assets/font/font2.ttf

main.dart

import 'package:flutter/material.dart';
void main() {
runApp(MaterialApp(
home: MyApp(),
));
}
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: new Text("Flutter Tutorial - googleflutter.com"),
),
body: Center(
child: Column(children: <Widget>[
Container(
padding: EdgeInsets.all(20),
child: Text(
'Welcome to Flutter Tutorial by googleflutter.com',
style: TextStyle(
fontFamily: "Font1", fontSize: 40, fontWeight: FontWeight.bold),
),
),
Container(
padding: EdgeInsets.all(20),
child: Text(
'Welcome to Flutter Tutorial by googleflutter.com',
style: TextStyle(
fontFamily: "Font2",
fontSize: 40,
fontWeight: FontWeight.bold),
)),
])),
);
}
}

以上就是 直播app系統原始碼,在 Flutter 中更改文字的字體系列實現的相關程式碼,更多內容歡迎關注之後的文章