20

Flutter开发Linux程序中文乱码解决

 4 years ago
source link: https://blog.lacia.cn/2020/12/08/Flutter%E5%BC%80%E5%8F%91Linux%E7%A8%8B%E5%BA%8F%E4%B8%AD%E6%96%87%E4%B9%B1%E7%A0%81%E8%A7%A3%E5%86%B3/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Flutter开发Linux程序中文乱码解决

盲猜由于字体缺失导致乱码,于是我把字体加过去

下载微软雅黑字体,也可以直接从 Windows 里复制一个

字体文件放在项目根目录 fonts 中对应 pubspec.yaml 配置

pubspec.yaml 配置

flutter:
fonts:
- family: cn
fonts:
- asset: fonts/msyh.ttc

main.dart 配置

void main() {
runApp(MyApp());
}

class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
debugShowCheckedModeBanner: false,
theme: ThemeData(
primarySwatch: Colors.blue,
// 配置字体
fontFamily: 'cn'
),
home: HomePage(),
);
}
}

Recommend

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK